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
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • chapterx-frontend/src/components/admin/ContentModerationTable.tsx

    ra6e33d1 re882b92  
    2020    deleteStory(story.story_id)
    2121    addNotification({
    22       user_id: story.user_id,
    23       type: 'system',
    24       title: 'Story Removed',
    25       message: `Your story "${story.title}" has been removed by an administrator.`,
     22      userId: story.user_id,
     23      contentType: 'system',
     24      content: `Your story "${story.title}" has been removed by an administrator.`,
    2625    })
    2726    addToast(`"${story.title}" removed from platform`, 'info')
  • chapterx-frontend/src/components/story/CommentSection.tsx

    ra6e33d1 re882b92  
    8080      if (currentUser.user_id !== authorUserId) {
    8181        await addNotification({
    82           recipientUserId: authorUserId,
    83           type: 'comment',
     82          userId: authorUserId,
     83          contentType: 'comment',
    8484          content: `${currentUser.username} commented: "${text.trim().slice(0, 60)}${text.length > 60 ? '...' : ''}"`,
     85          storyId,
    8586          link: `/story/${storyId}`,
    8687        })
  • chapterx-frontend/src/components/story/LikeButton.tsx

    ra6e33d1 re882b92  
    5959        if (currentUser.user_id !== authorUserId) {
    6060          await addNotification({
    61             recipientUserId: authorUserId,
    62             type: 'like',
     61            userId: authorUserId,
     62            contentType: 'like',
    6363            content: `${currentUser.username} liked your story.`,
     64            storyId,
    6465            link: `/story/${storyId}`,
    6566          })
  • chapterx-frontend/src/components/writer/CollaboratorManager.tsx

    ra6e33d1 re882b92  
    6262    addCollaboration(newCollab)
    6363    addNotification({
    64       recipientUserId: user.user_id,
    65       type: 'collaboration',
     64      userId: user.user_id,
     65      contentType: 'collaboration',
    6666      content: `You've been invited to collaborate on "${storyTitle}" as ${selectedRole}.`,
     67      storyId,
    6768      link: `/story/${storyId}`,
    6869    })
  • 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.