| 1 | import z from 'zod' |
| 2 | import { |
| 3 | customFieldDefinitionCreateSchema, |
| 4 | customFieldDefinitionUpdateSchema, |
| 5 | } from '@/lib/custom-fields' |
| 6 | import { billingFrequencyEnum } |
| 7 | |
| 8 | const clientInvolvementToggleSchema = z |
| 9 | |
| 10 | const orgClientInvolvementValueSchema = z |
| 11 | proposals: clientInvolvementToggleSchema, |
| 12 | requirements: clientInvolvementToggleSchema, |
| 13 | milestones: clientInvolvementToggleSchema, |
| 14 | timesheets: clientInvolvementToggleSchema, |
| 15 | expenses: clientInvolvementToggleSchema, |
| 16 | invoices: clientInvolvementToggleSchema, |
| 17 | }) |
| 18 | |
| 19 | export type ClientInvolvementValue |
| 20 | typeof orgClientInvolvementValueSchema |
| 21 | > |
| 22 | |
| 23 | export const updateOrgClientInvolvementSchema = |
| 24 | organizationId: z.string |
| 25 | clientInvolvement: orgClientInvolvementValueSchema, |
| 26 | }) |
| 27 | |
| 28 | export const renameOrganizationSchema = |
| 29 | organizationId: z.string |
| 30 | name: z.string |
| 31 | slug: z |
| 32 | .string() |
| 33 | .min(1, ' |
| 34 | .max(100) |
| 35 | .regex(/^[a-z0-9 |
| 36 | }) |
| 37 | |
| 38 | export type BillingFrequency |
| 39 | |
| 40 | export const timesheetDurationOptions = |
| 41 | 'weekly', |
| 42 | 'biweekly', |
| 43 | 'monthly', |
| 44 | ] as const |
| 45 | export type TimesheetDuration |
| 46 | |
| 47 | export const updateTimesheetDefaultsSchema = |
| 48 | organizationId: z.string |
| 49 | defaultPayRate: z.number |
| 50 | defaultPayCurrency: z.string |
| 51 | defaultPayFrequency: z.enum |
| 52 | // Billing defaults are optional and fall back to the pay values in the action. |
| 53 | defaultBillingRate: z |
| 54 | .number() |
| 55 | .int() |
| 56 | .min(0, ' |
| 57 | .optional(), |
| 58 | defaultBillingCurrency: z.string |
| 59 | defaultBillingFrequency: z.enum |
| 60 | defaultTimesheetDuration: z.enum |
| 61 | }) |
| 62 | |
| 63 | export const updateInvoiceNumberTemplateSchema = |
| 64 | organizationId: z.string |
| 65 | projectId: z.string |
| 66 | invoiceNumberTemplate: z |
| 67 | .string() |
| 68 | .trim() |
| 69 | .min(1, ' |
| 70 | .max(100, ' |
| 71 | }) |
| 72 | |
| 73 | export const invoiceTimeUnitOptions = |
| 74 | export type InvoiceTimeUnit |
| 75 | |
| 76 | export const updateInvoiceImportDefaultsSchema = |
| 77 | organizationId: z.string |
| 78 | projectId: z.string |
| 79 | invoiceTimeUnit: z.enum |
| 80 | }) |
| 81 | |
| 82 | export const updateInvoiceFromDetailsSchema = |
| 83 | organizationId: z.string |
| 84 | invoiceFromName: z.string |
| 85 | invoiceFromAddress: z.string |
| 86 | }) |
| 87 | |
| 88 | export const deleteOrganizationSchema = |
| 89 | organizationId: z.string |
| 90 | confirmName: z.string |
| 91 | }) |
| 92 | |
| 93 | export const createOrgCustomFieldSchema = |
| 94 | organizationId: z.string |
| 95 | definition: customFieldDefinitionCreateSchema, |
| 96 | }) |
| 97 | |
| 98 | export const updateOrgCustomFieldSchema = |
| 99 | organizationId: z.string |
| 100 | fieldId: z.string |
| 101 | definition: customFieldDefinitionUpdateSchema, |
| 102 | }) |
| 103 | |
| 104 | export const deleteOrgCustomFieldSchema = |
| 105 | organizationId: z.string |
| 106 | fieldId: z.string |
| 107 | }) |