| 1 | import { and, asc, eq, isNull } from 'drizzle-orm' |
| 2 | import type { Metadata |
| 3 | import { redirect } |
| 4 | import { resolveProjectContext } |
| 5 | import { projectsService } |
| 6 | import type { CustomFieldDefinition |
| 7 | |
| 8 | import { createMetadata } |
| 9 | import { db } |
| 10 | import { customFields } |
| 11 | import { ProjectSettingsPageClient } |
| 12 | |
| 13 | export const metadata: |
| 14 | title: 'Project Settings', |
| 15 | description: 'Configure project preferences, defaults, and access.', |
| 16 | openGraph: { |
| 17 | images: ['/api/og?page=Settings'], |
| 18 | }, |
| 19 | twitter: { |
| 20 | images: ['/api/og?page=Settings'], |
| 21 | }, |
| 22 | }) |
| 23 | |
| 24 | export default async function |
| 25 | params, |
| 26 | }: PageProps< |
| 27 | const { org, |
| 28 | const { organization, |
| 29 | org, |
| 30 | projectSlug |
| 31 | ) |
| 32 | |
| 33 | if (!role.authorize |
| 34 | redirect( |
| 35 | `/error/403?message=${encodeURIComponent('You do not have permission to view settings |
| 36 | ) |
| 37 | } |
| 38 | |
| 39 | const canDelete = |
| 40 | |
| 41 | const settings = |
| 42 | organization.id, |
| 43 | project.id |
| 44 | ) |
| 45 | |
| 46 | const projectCustomFields: |
| 47 | .select() |
| 48 | .from(customFields) |
| 49 | .where(eq(customFields |
| 50 | .orderBy(asc(customFields |
| 51 | const orgCustomFields: |
| 52 | .select() |
| 53 | .from(customFields) |
| 54 | .where( |
| 55 | and( |
| 56 | eq(customFields.organizationId |
| 57 | isNull(customFields.projectId |
| 58 | ) |
| 59 | ) |
| 60 | .orderBy(asc(customFields |
| 61 | |
| 62 | return ( |
| 63 | <ProjectSettingsPageClient |
| 64 | canDelete={canDelete} |
| 65 | organizationId={organization.id |
| 66 | orgCustomFields={orgCustomFields} |
| 67 | orgSlug={org} |
| 68 | project={{ |
| 69 | id: project.id |
| 70 | name: project.name |
| 71 | slug: project.slug |
| 72 | dueDate: project.dueDate |
| 73 | }} |
| 74 | projectCustomFields={projectCustomFields} |
| 75 | settings={settings} |
| 76 | /> |
| 77 | ) |
| 78 | } |