diff --git a/app/lib/actions/locationActions.ts b/app/lib/actions/locationActions.ts index a90ee43..940d948 100644 --- a/app/lib/actions/locationActions.ts +++ b/app/lib/actions/locationActions.ts @@ -18,7 +18,7 @@ export type State = { generateTenantCode?: string[]; tenantFirstName?: string[]; tenantLastName?: string[]; - autoTenantNotification?: string[]; + autoBillFwd?: string[]; tenantEmail?: string[]; }; message?:string | null; @@ -35,7 +35,7 @@ const FormSchema = (t:IntlTemplateFn) => z.object({ generateTenantCode: z.boolean().optional().nullable(), tenantFirstName: z.string().optional().nullable(), tenantLastName: z.string().optional().nullable(), - autoTenantNotification: z.boolean().optional().nullable(), + autoBillFwd: z.boolean().optional().nullable(), tenantEmail: z.string().email(t("tenant-email-invalid")).optional().or(z.literal("")).nullable(), addToSubsequentMonths: z.boolean().optional().nullable(), updateScope: z.enum(["current", "subsequent", "all"]).optional().nullable(), @@ -62,7 +62,7 @@ const FormSchema = (t:IntlTemplateFn) => z.object({ path: ["tenantLastName"], }) .refine((data) => { - if (data.autoTenantNotification) { + if (data.autoBillFwd) { return !!data.tenantEmail && data.tenantEmail.trim().length > 0; } return true; @@ -90,7 +90,7 @@ export const updateOrAddLocation = withUser(async (user:AuthenticatedUser, locat generateTenantCode: formData.get('generateTenantCode') === 'on', tenantFirstName: formData.get('tenantFirstName') || null, tenantLastName: formData.get('tenantLastName') || null, - autoTenantNotification: formData.get('autoTenantNotification') === 'on', + autoBillFwd: formData.get('autoBillFwd') === 'on', tenantEmail: formData.get('tenantEmail') || null, addToSubsequentMonths: formData.get('addToSubsequentMonths') === 'on', updateScope: formData.get('updateScope') as "current" | "subsequent" | "all" | undefined, @@ -110,7 +110,7 @@ export const updateOrAddLocation = withUser(async (user:AuthenticatedUser, locat generateTenantCode, tenantFirstName, tenantLastName, - autoTenantNotification, + autoBillFwd, tenantEmail, addToSubsequentMonths, updateScope, @@ -148,7 +148,7 @@ export const updateOrAddLocation = withUser(async (user:AuthenticatedUser, locat generateTenantCode: generateTenantCode || false, tenantFirstName: tenantFirstName || null, tenantLastName: tenantLastName || null, - autoTenantNotification: autoTenantNotification || false, + autoBillFwd: autoBillFwd || false, tenantEmail: tenantEmail || null, } } @@ -174,7 +174,7 @@ export const updateOrAddLocation = withUser(async (user:AuthenticatedUser, locat generateTenantCode: generateTenantCode || false, tenantFirstName: tenantFirstName || null, tenantLastName: tenantLastName || null, - autoTenantNotification: autoTenantNotification || false, + autoBillFwd: autoBillFwd || false, tenantEmail: tenantEmail || null, } } @@ -193,7 +193,7 @@ export const updateOrAddLocation = withUser(async (user:AuthenticatedUser, locat generateTenantCode: generateTenantCode || false, tenantFirstName: tenantFirstName || null, tenantLastName: tenantLastName || null, - autoTenantNotification: autoTenantNotification || false, + autoBillFwd: autoBillFwd || false, tenantEmail: tenantEmail || null, } } @@ -210,7 +210,7 @@ export const updateOrAddLocation = withUser(async (user:AuthenticatedUser, locat generateTenantCode: generateTenantCode || false, tenantFirstName: tenantFirstName || null, tenantLastName: tenantLastName || null, - autoTenantNotification: autoTenantNotification || false, + autoBillFwd: autoBillFwd || false, tenantEmail: tenantEmail || null, yearMonth: yearMonth, bills: [], @@ -279,7 +279,7 @@ export const updateOrAddLocation = withUser(async (user:AuthenticatedUser, locat generateTenantCode: generateTenantCode || false, tenantFirstName: tenantFirstName || null, tenantLastName: tenantLastName || null, - autoTenantNotification: autoTenantNotification || false, + autoBillFwd: autoBillFwd || false, tenantEmail: tenantEmail || null, yearMonth: { year: monthData.year, month: monthData.month }, bills: [], diff --git a/app/lib/db-types.ts b/app/lib/db-types.ts index e932b8f..4789525 100644 --- a/app/lib/db-types.ts +++ b/app/lib/db-types.ts @@ -50,7 +50,7 @@ export interface BillingLocation { /** (optional) tenant last name */ tenantLastName?: string | null; /** (optional) whether to automatically notify tenant */ - autoTenantNotification?: boolean | null; + autoBillFwd?: boolean | null; /** (optional) tenant email */ tenantEmail?: string | null; }; diff --git a/app/ui/LocationEditForm.tsx b/app/ui/LocationEditForm.tsx index ae6bf85..eb08593 100644 --- a/app/ui/LocationEditForm.tsx +++ b/app/ui/LocationEditForm.tsx @@ -33,8 +33,8 @@ export const LocationEditForm: FC = ({ location, yearMont ); // Track whether to automatically notify tenant (use persisted value from database) - const [autoTenantNotification, setAutoTenantNotification] = useState( - location?.autoTenantNotification ?? false + const [autoBillFwd, setautoBillFwd] = useState( + location?.autoBillFwd ?? false ); // Track tenant field values for real-time validation @@ -147,16 +147,16 @@ export const LocationEditForm: FC = ({ location, yearMont - {autoTenantNotification && ( + {autoBillFwd && (