From e9012ed23157923a6f243437535faac54a02f5e1 Mon Sep 17 00:00:00 2001 From: Knee Cola Date: Tue, 30 Dec 2025 11:09:21 +0100 Subject: [PATCH] (refactor) renames autoBillFwd > billFwdEnabled --- .gitignore | 2 ++ web-app/app/lib/actions/locationActions.ts | 20 ++++++++++---------- web-app/app/lib/db-types.ts | 8 +++++--- web-app/app/ui/LocationEditForm.tsx | 12 ++++++------ 4 files changed, 23 insertions(+), 19 deletions(-) diff --git a/.gitignore b/.gitignore index aa3a3b1..d378de6 100644 --- a/.gitignore +++ b/.gitignore @@ -52,3 +52,5 @@ mongo-backup/ .serena/ *.serena-memory mongo-backup/ + +.git/ \ No newline at end of file diff --git a/web-app/app/lib/actions/locationActions.ts b/web-app/app/lib/actions/locationActions.ts index af79304..1be8528 100644 --- a/web-app/app/lib/actions/locationActions.ts +++ b/web-app/app/lib/actions/locationActions.ts @@ -20,7 +20,7 @@ export type State = { tenantName?: string[]; tenantStreet?: string[]; tenantTown?: string[]; - autoBillFwd?: string[]; + billFwdEnabled?: string[]; tenantEmail?: string[]; tenantEmailStatus?: string[]; billFwdStrategy?: string[]; @@ -43,7 +43,7 @@ const FormSchema = (t:IntlTemplateFn) => z.object({ tenantName: z.string().max(30).optional().nullable(), tenantStreet: z.string().max(27).optional().nullable(), tenantTown: z.string().max(27).optional().nullable(), - autoBillFwd: z.boolean().optional().nullable(), + billFwdEnabled: z.boolean().optional().nullable(), tenantEmail: z.string().email(t("tenant-email-invalid")).optional().or(z.literal("")).nullable(), tenantEmailStatus: z.enum([EmailStatus.Unverified, EmailStatus.VerificationPending, EmailStatus.Verified, EmailStatus.Unsubscribed]).optional().nullable(), billFwdStrategy: z.enum(["when-payed", "when-attached"]).optional().nullable(), @@ -84,7 +84,7 @@ const FormSchema = (t:IntlTemplateFn) => z.object({ path: ["tenantTown"], }) .refine((data) => { - if (data.autoBillFwd || data.rentDueNotificationEnabled) { + if (data.billFwdEnabled || data.rentDueNotificationEnabled) { return !!data.tenantEmail && data.tenantEmail.trim().length > 0; } return true; @@ -122,7 +122,7 @@ export const updateOrAddLocation = withUser(async (user:AuthenticatedUser, locat tenantName: formData.get('tenantName') || null, tenantStreet: formData.get('tenantStreet') || null, tenantTown: formData.get('tenantTown') || null, - autoBillFwd: formData.get('autoBillFwd') === 'on', + billFwdEnabled: formData.get('billFwdEnabled') === 'on', tenantEmail: formData.get('tenantEmail') || null, tenantEmailStatus: formData.get('tenantEmailStatus') as "unverified" | "verification-pending" | "verified" | "unsubscribed" | undefined, billFwdStrategy: formData.get('billFwdStrategy') as "when-payed" | "when-attached" | undefined, @@ -148,7 +148,7 @@ export const updateOrAddLocation = withUser(async (user:AuthenticatedUser, locat tenantName, tenantStreet, tenantTown, - autoBillFwd, + billFwdEnabled, tenantEmail, tenantEmailStatus, billFwdStrategy, @@ -206,7 +206,7 @@ export const updateOrAddLocation = withUser(async (user:AuthenticatedUser, locat tenantName: tenantName || null, tenantStreet: tenantStreet || null, tenantTown: tenantTown || null, - autoBillFwd: autoBillFwd || false, + billFwdEnabled: billFwdEnabled || false, tenantEmail: tenantEmail || null, tenantEmailStatus: finalEmailStatus, billFwdStrategy: billFwdStrategy || "when-payed", @@ -238,7 +238,7 @@ export const updateOrAddLocation = withUser(async (user:AuthenticatedUser, locat tenantName: tenantName || null, tenantStreet: tenantStreet || null, tenantTown: tenantTown || null, - autoBillFwd: autoBillFwd || false, + billFwdEnabled: billFwdEnabled || false, tenantEmail: tenantEmail || null, tenantEmailStatus: finalEmailStatus, billFwdStrategy: billFwdStrategy || "when-payed", @@ -263,7 +263,7 @@ export const updateOrAddLocation = withUser(async (user:AuthenticatedUser, locat tenantName: tenantName || null, tenantStreet: tenantStreet || null, tenantTown: tenantTown || null, - autoBillFwd: autoBillFwd || false, + billFwdEnabled: billFwdEnabled || false, tenantEmail: tenantEmail || null, tenantEmailStatus: finalEmailStatus, billFwdStrategy: billFwdStrategy || "when-payed", @@ -287,7 +287,7 @@ export const updateOrAddLocation = withUser(async (user:AuthenticatedUser, locat tenantName: tenantName || null, tenantStreet: tenantStreet || null, tenantTown: tenantTown || null, - autoBillFwd: autoBillFwd || false, + billFwdEnabled: billFwdEnabled || false, tenantEmail: tenantEmail || null, tenantEmailStatus: tenantEmailStatus as EmailStatus || EmailStatus.Unverified, billFwdStrategy: billFwdStrategy || "when-payed", @@ -363,7 +363,7 @@ export const updateOrAddLocation = withUser(async (user:AuthenticatedUser, locat tenantName: tenantName || null, tenantStreet: tenantStreet || null, tenantTown: tenantTown || null, - autoBillFwd: autoBillFwd || false, + billFwdEnabled: billFwdEnabled || false, tenantEmail: tenantEmail || null, tenantEmailStatus: tenantEmailStatus as EmailStatus || EmailStatus.Unverified, billFwdStrategy: billFwdStrategy || "when-payed", diff --git a/web-app/app/lib/db-types.ts b/web-app/app/lib/db-types.ts index d220372..11b809e 100644 --- a/web-app/app/lib/db-types.ts +++ b/web-app/app/lib/db-types.ts @@ -75,20 +75,22 @@ export interface BillingLocation { tenantStreet?: string | null; /** (optional) tenant town */ tenantTown?: string | null; - /** (optional) whether to automatically notify tenant */ - autoBillFwd?: boolean | null; /** (optional) tenant email */ tenantEmail?: string | null; /** (optional) tenant email status */ tenantEmailStatus?: EmailStatus | null; + /** (optional) whether to automatically notify tenant */ + billFwdEnabled?: boolean | null; /** (optional) bill forwarding strategy */ billFwdStrategy?: "when-payed" | "when-attached" | null; + /** (optional) bill forwarding status */ + billFwdStatus?: "pending" | "sent" | "failed" | null; /** (optional) whether to automatically send rent notification */ rentDueNotificationEnabled?: boolean | null; /** (optional) day of month when rent is due (1-31) */ rentDueDay?: number | null; /** (optional) when was the rent due notification sent */ - rentDueNotificationEnabledSentAt?: number | null; + rentDueNotificationStatus?: "sent" | "failed" | null; /** (optional) monthly rent amount in cents */ rentAmount?: number | null; /** (optional) whether the location has been seen by tenant */ diff --git a/web-app/app/ui/LocationEditForm.tsx b/web-app/app/ui/LocationEditForm.tsx index 6a26a9f..1d74089 100644 --- a/web-app/app/ui/LocationEditForm.tsx +++ b/web-app/app/ui/LocationEditForm.tsx @@ -44,7 +44,7 @@ export const LocationEditForm: FC = ({ location, yearMont tenantEmailStatus: location?.tenantEmailStatus ?? EmailStatus.Unverified, tenantPaymentMethod: location?.tenantPaymentMethod ?? "none", proofOfPaymentType: location?.proofOfPaymentType ?? "none", - autoBillFwd: location?.autoBillFwd ?? false, + billFwdEnabled: location?.billFwdEnabled ?? false, billFwdStrategy: location?.billFwdStrategy ?? "when-payed", rentDueNotificationEnabled: location?.rentDueNotificationEnabled ?? false, rentAmount: location?.rentAmount ?? "", @@ -278,16 +278,16 @@ export const LocationEditForm: FC = ({ location, yearMont - {formValues.autoBillFwd && ( + {formValues.billFwdEnabled && (
{t("utility-bill-forwarding-strategy-label")}