Ignore:
Timestamp:
03/24/26 23:03:39 (3 months ago)
Author:
kikisrbinoska <srbinoskakristina07@…>
Branches:
main
Children:
a7550ca
Parents:
73b69b2
Message:

Added functional collaboration between users

File:
1 edited

Legend:

Unmodified
Added
Removed
  • chapterx-frontend/src/components/writer/CollaboratorManager.tsx

    r73b69b2 r7fbb91c  
    3232}) => {
    3333  const { collaborations, addCollaboration, removeCollaboration, updateCollaborationPermission } = useStoryStore()
    34   const { allUsers } = useAuthStore()
     34  const { allUsers, fetchAllUsers } = useAuthStore()
    3535  const { addNotification } = useNotificationStore()
    3636  const { addToast } = useUIStore()
     
    4343  const storyCollabs = collaborations.filter(c => c.story_id === storyId)
    4444  const collabUserIds = new Set(storyCollabs.map(c => c.user_id))
    45   const availableUsers = allUsers.filter(u => u.user_id !== ownerId && !collabUserIds.has(u.user_id))
     45  const availableUsers = allUsers.filter(u => u.user_id !== ownerId && !collabUserIds.has(u.user_id) && (u.role === 'writer' || u.role === 'admin'))
    4646
    4747  const handleInvite = () => {
     
    6262    addCollaboration(newCollab)
    6363    addNotification({
    64       user_id: user.user_id,
     64      recipientUserId: user.user_id,
    6565      type: 'collaboration',
    66       title: 'Collaboration Invite',
    67       message: `You've been invited to collaborate on "${storyTitle}" as ${selectedRole}.`,
     66      content: `You've been invited to collaborate on "${storyTitle}" as ${selectedRole}.`,
    6867      link: `/story/${storyId}`,
    6968    })
     
    8685          <span className="text-xs text-slate-500">({storyCollabs.length})</span>
    8786        </div>
    88         <Button size="sm" onClick={() => setInviteOpen(true)}>
     87        <Button size="sm" onClick={() => { fetchAllUsers(); setInviteOpen(true) }}>
    8988          <UserPlus size={14} />
    9089          Invite
     
    149148              {availableUsers.map(u => (
    150149                <option key={u.user_id} value={u.username}>
    151                   @{u.username} ({u.role})
     150                  @{u.username}
    152151                </option>
    153152              ))}
Note: See TracChangeset for help on using the changeset viewer.