| 1 | 'use client' |
| 2 | |
| 3 | import { useRouter } from '@bprogress/next/app' |
| 4 | import { FileText, Plus |
| 5 | import { Button } |
| 6 | import { |
| 7 | Empty, |
| 8 | EmptyContent, |
| 9 | EmptyDescription, |
| 10 | EmptyHeader, |
| 11 | EmptyMedia, |
| 12 | EmptyTitle, |
| 13 | } from '@/components/ui/empty' |
| 14 | import type { requirements |
| 15 | import type { Role |
| 16 | import RequirementCard from './_components/requirement-card |
| 17 | |
| 18 | type Requirement |
| 19 | |
| 20 | interface RequirementsClientProps { |
| 21 | canCreate: boolean |
| 22 | isClientInvolved?: boolean |
| 23 | orgSlug: string |
| 24 | projectSlug: string |
| 25 | requirements: Requirement |
| 26 | role: Role |
| 27 | } |
| 28 | |
| 29 | export function RequirementsClient({ |
| 30 | requirements, |
| 31 | orgSlug, |
| 32 | projectSlug, |
| 33 | canCreate, |
| 34 | role, |
| 35 | isClientInvolved, |
| 36 | }: RequirementsClientProps) |
| 37 | const newUrl = |
| 38 | const router = |
| 39 | return ( |
| 40 | <div className='w-full |
| 41 | <div className='mb-6 flex items-center justify-between |
| 42 | <h1 className='font-semibold text-2xl |
| 43 | {canCreate && requirements |
| 44 | <Button |
| 45 | kbd='c' |
| 46 | onClick={() => |
| 47 | router.push(newUrl |
| 48 | }} |
| 49 | > |
| 50 | <Plus className=' |
| 51 | New Requirement |
| 52 | </Button> |
| 53 | )} |
| 54 | </div> |
| 55 | |
| 56 | {requirements.length === |
| 57 | <Empty> |
| 58 | <EmptyHeader> |
| 59 | <EmptyMedia variant=' |
| 60 | <FileText /> |
| 61 | </EmptyMedia> |
| 62 | <EmptyTitle>No requirements yet</EmptyTitle |
| 63 | <EmptyDescription> |
| 64 | Requirements define the scope of work for this project. Create one |
| 65 | to get started. |
| 66 | </EmptyDescription> |
| 67 | </EmptyHeader> |
| 68 | {canCreate && ( |
| 69 | <EmptyContent> |
| 70 | <Button |
| 71 | kbd='c' |
| 72 | onClick={() => |
| 73 | router.push(newUrl |
| 74 | }} |
| 75 | > |
| 76 | New Requirement |
| 77 | </Button> |
| 78 | </EmptyContent> |
| 79 | )} |
| 80 | </Empty> |
| 81 | ) : ( |
| 82 | <div className='grid gap-4 sm:grid-cols-2 lg:grid-cols-3 |
| 83 | {requirements.map(( |
| 84 | <RequirementCard |
| 85 | isClientInvolved={isClientInvolved} |
| 86 | key={requirement.id |
| 87 | orgSlug={orgSlug} |
| 88 | projectSlug={projectSlug} |
| 89 | requirement={requirement} |
| 90 | role={role} |
| 91 | /> |
| 92 | ))} |
| 93 | </div> |
| 94 | )} |
| 95 | </div> |
| 96 | ) |
| 97 | } |