| 1 | import { and, asc, eq, isNull } from 'drizzle-orm' |
| 2 | import type { Metadata |
| 3 | import { projectsService } |
| 4 | import type { CustomFieldDefinition |
| 5 | import { createMetadata } |
| 6 | import { db } |
| 7 | import { customFields } |
| 8 | import { requirePermission, resolveOrgContext |
| 9 | import { SettingsPageClient } |
| 10 | |
| 11 | export const metadata: |
| 12 | title: 'Workspace Settings', |
| 13 | description: 'Configure workspace defaults, billing, and preferences.', |
| 14 | openGraph: { |
| 15 | images: ['/api/og?page=Settings'], |
| 16 | }, |
| 17 | twitter: { |
| 18 | images: ['/api/og?page=Settings'], |
| 19 | }, |
| 20 | }) |
| 21 | |
| 22 | export default async function |
| 23 | params, |
| 24 | }: PageProps< |
| 25 | const { org |
| 26 | const { organization, |
| 27 | |
| 28 | requirePermission( |
| 29 | role, |
| 30 | { organization: ['update' |
| 31 | 'You do not have permission to view settings' |
| 32 | ) |
| 33 | |
| 34 | const canDelete = |
| 35 | |
| 36 | const settings = |
| 37 | |
| 38 | const orgCustomFields: |
| 39 | .select() |
| 40 | .from(customFields) |
| 41 | .where( |
| 42 | and( |
| 43 | eq(customFields.organizationId |
| 44 | isNull(customFields.projectId |
| 45 | ) |
| 46 | ) |
| 47 | .orderBy(asc(customFields |
| 48 | |
| 49 | return ( |
| 50 | <SettingsPageClient |
| 51 | canDelete={canDelete} |
| 52 | clientInvolvement={settings.clientInvolvement |
| 53 | customFields={orgCustomFields} |
| 54 | defaultBillingCurrency={settings.billingCurrency |
| 55 | defaultBillingFrequency={settings.billingFrequency |
| 56 | defaultBillingRate={settings.billingRate |
| 57 | defaultPayCurrency={settings.payCurrency |
| 58 | defaultPayFrequency={settings.payFrequency |
| 59 | defaultPayRate={settings.payRate |
| 60 | defaultTimesheetDuration={settings.timesheetDuration |
| 61 | invoiceFromAddress={settings.invoiceFromAddress |
| 62 | invoiceFromName={settings.invoiceFromName |
| 63 | invoiceNumberTemplate={settings.invoiceNumberTemplate |
| 64 | invoiceTimeUnit={settings.invoiceTimeUnit |
| 65 | organization={organization} |
| 66 | orgSlug={org} |
| 67 | /> |
| 68 | ) |
| 69 | } |