| 1 | 'use client' |
| 2 | |
| 3 | import { Briefcase, UserPlus } from 'lucide-react' |
| 4 | import { useState } |
| 5 | import { Button } |
| 6 | import { |
| 7 | Empty, |
| 8 | EmptyDescription, |
| 9 | EmptyHeader, |
| 10 | EmptyMedia, |
| 11 | EmptyTitle, |
| 12 | } from '@/components/ui/empty' |
| 13 | import AssignProjectDialog from './_components/assign-project-dialog |
| 14 | import ClientsTable from './_components/clients-table |
| 15 | import InviteClientDialog from './_components/invite-client-dialog |
| 16 | import PendingInvitationsBlock from './_components/pending-invitations-block |
| 17 | import type { ClientsPageClientProps |
| 18 | |
| 19 | export function ClientsPageClient({ |
| 20 | organizationId, |
| 21 | orgSlug, |
| 22 | clients, |
| 23 | invitations, |
| 24 | canManage, |
| 25 | projects, |
| 26 | }: ClientsPageClientProps) |
| 27 | const [showInviteDialog, |
| 28 | const [assignProject, |
| 29 | memberId: string |
| 30 | clientName: string |
| 31 | existingProjectIds: string |
| 32 | } | null |
| 33 | |
| 34 | return ( |
| 35 | <div className='w-full |
| 36 | <div className='mb-6 flex items-center justify-between |
| 37 | <h1 className='font-semibold text-2xl |
| 38 | {canManage && ( |
| 39 | <Button onClick={ |
| 40 | <UserPlus className=' |
| 41 | Invite Client |
| 42 | </Button> |
| 43 | )} |
| 44 | </div> |
| 45 | |
| 46 | {clients.length === |
| 47 | <Empty> |
| 48 | <EmptyHeader> |
| 49 | <EmptyMedia variant=' |
| 50 | <Briefcase /> |
| 51 | </EmptyMedia> |
| 52 | <EmptyTitle>No clients yet</EmptyTitle |
| 53 | <EmptyDescription> |
| 54 | Invite clients to give them visibility into your projects. |
| 55 | </EmptyDescription> |
| 56 | </EmptyHeader> |
| 57 | </Empty> |
| 58 | ) : ( |
| 59 | <> |
| 60 | {canManage && <PendingInvitationsBlock |
| 61 | <ClientsTable |
| 62 | canManage={canManage} |
| 63 | clients={clients} |
| 64 | onAssignProject={(memberId, |
| 65 | setAssignProject({ memberId, |
| 66 | } |
| 67 | orgSlug={orgSlug} |
| 68 | /> |
| 69 | </> |
| 70 | )} |
| 71 | |
| 72 | <InviteClientDialog |
| 73 | onOpenChange={setShowInviteDialog} |
| 74 | open={showInviteDialog} |
| 75 | organizationId={organizationId} |
| 76 | /> |
| 77 | |
| 78 | <AssignProjectDialog |
| 79 | existingProjectIds={assignProject?.existingProjectIds |
| 80 | memberId={assignProject?.memberId |
| 81 | onOpenChange={(open) |
| 82 | if (!open) { |
| 83 | setAssignProject(null) |
| 84 | } |
| 85 | }} |
| 86 | open={!!assignProject} |
| 87 | projects={projects} |
| 88 | /> |
| 89 | </div> |
| 90 | ) |
| 91 | } |