Ignore:
Timestamp:
08/24/26 20:57:09 (13 days ago)
Author:
kikisrbinoska <srbinoskakristina07@…>
Branches:
main
Parents:
a6e33d1
Message:

Added corrected entitef from the ER diagram and changes for the logic to be coresponding to the ddl

Location:
chapterx-frontend/src/store
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • chapterx-frontend/src/store/notificationStore.ts

    ra6e33d1 re882b92  
    1717  notifications: Notification[]
    1818  fetchUserNotifications: (userId: number) => Promise<void>
    19   addNotification: (n: { recipientUserId: number; type: string; content: string; link?: string }) => Promise<void>
     19  addNotification: (n: { userId: number; contentType: string; content: string; storyId?: number; link?: string }) => Promise<void>
    2020  markAllRead: () => Promise<void>
    2121  markRead: (id: number) => Promise<void>
     
    3333        notification_id: n.id,
    3434        user_id: userId,
    35         type: n.type ?? 'info',
    36         title: n.type ?? 'Notification',
     35        type: n.contentType ?? 'info',
     36        title: n.contentType ?? 'Notification',
    3737        message: n.content,
    3838        link: n.link,
     
    4646  },
    4747
    48   addNotification: async ({ recipientUserId, type, content, link }) => {
     48  addNotification: async ({ userId, contentType, content, storyId, link }) => {
    4949    try {
    5050      await axios.post(`${API}/notifications`, {
    5151        content,
    52         recipientUserId,
    53         type,
     52        contentType,
     53        userId,
     54        storyId,
    5455        link,
    5556      }, { headers: getAuthHeaders() })
  • chapterx-frontend/src/store/storyStore.ts

    ra6e33d1 re882b92  
    144144        cover_image: s.image ?? undefined,
    145145        mature_content: s.matureContent,
    146         status: 'published' as StoryStatus,
     146        status: (s.status ?? 'draft') as StoryStatus,
    147147        author_username: s.writer?.user?.username ?? '',
    148148        created_at: s.createdAt,
     
    193193        name: c.name ?? c.username ?? '',
    194194        story_title: '',
    195         role: 'editor' as any,
    196         permission_level: 3 as any,
     195        role: c.role as any,
     196        permission_level: (c.permissionLevel ?? 3) as any,
    197197        joined_at: c.createdAt,
    198198      }))
     
    246246        image: imageUrl,
    247247        content: partial.content ?? story.content,
     248        status: partial.status ?? story.status,
    248249      }, { headers: getAuthHeaders() })
    249250    } catch {
     
    266267  },
    267268
    268   updateStoryStatus: (id, status) =>
     269  updateStoryStatus: (id, status) => {
    269270    set(state => ({
    270271      stories: state.stories.map(s =>
    271272        s.story_id === id ? { ...s, status, updated_at: new Date().toISOString() } : s
    272273      ),
    273     })),
     274    }))
     275    get().updateStory(id, { status })
     276  },
    274277
    275278  addChapter: async (chapter) => {
     
    407410        storyId: collab.story_id,
    408411        role: collab.role,
     412        permissionLevel: collab.permission_level,
    409413      }, { headers: getAuthHeaders() })
    410414    } catch {
     
    445449        original_text: s.originalText,
    446450        suggested_text: s.suggestedText,
    447         suggestion_type: (s.suggestionTypes?.[0] ?? 'style') as SuggestionType,
     451        suggestion_type: (s.suggestionType ?? 'style') as SuggestionType,
     452        explanation: s.explanation ?? '',
    448453        accepted: s.accepted === true ? true : s.accepted === false ? false : null,
     454        created_at: s.createdAt ?? new Date().toISOString(),
    449455        applied_at: s.appliedAt ?? undefined,
    450456      }))
     
    506512        originalText: suggestion.original_text,
    507513        suggestedText: suggestion.suggested_text,
     514        suggestionType: suggestion.suggestion_type,
    508515        storyId: suggestion.chapter_id,
    509516      }, { headers: getAuthHeaders() })
Note: See TracChangeset for help on using the changeset viewer.