From 4906cc19904c897aeb7bc7dc653c9b058934aff6 Mon Sep 17 00:00:00 2001 From: Knee Cola Date: Tue, 30 Dec 2025 10:45:48 +0100 Subject: [PATCH] (refactor) rename: rentDueNotification > rentDueNotificationEnabled --- sprints/sprint--confirm-unsubscribe.md | 4 ++-- web-app/app/lib/actions/locationActions.ts | 22 +++++++++++----------- web-app/app/lib/db-types.ts | 4 +++- web-app/app/ui/LocationEditForm.tsx | 12 ++++++------ 4 files changed, 22 insertions(+), 20 deletions(-) diff --git a/sprints/sprint--confirm-unsubscribe.md b/sprints/sprint--confirm-unsubscribe.md index 10a8b14..393e46a 100644 --- a/sprints/sprint--confirm-unsubscribe.md +++ b/sprints/sprint--confirm-unsubscribe.md @@ -19,8 +19,8 @@ The web page served at this path contains an text explanation and "Verify e-mail The text includes the following information: * what the web app is about - very short into -* why the e-mail was sent = because the landloard of the property `BillingLocation.name` configured the rent (`BillingLocation.rentDueNotification`) and/or utility bills (`BillingLocation.billFwdStrategy`) to be delivered to that e-mail address -* what will hapen if he/she clicks on the "Verify e-mail" button = they will be receiving rent due (`BillingLocation.rentDueNotification`) or utility bills due (`BillingLocation.billFwdStrategy`) notification or both - 2x a month - depending on the config set by the landloard +* why the e-mail was sent = because the landloard of the property `BillingLocation.name` configured the rent (`BillingLocation.rentDueNotificationEnabled`) and/or utility bills (`BillingLocation.billFwdStrategy`) to be delivered to that e-mail address +* what will hapen if he/she clicks on the "Verify e-mail" button = they will be receiving rent due (`BillingLocation.rentDueNotificationEnabled`) or utility bills due (`BillingLocation.billFwdStrategy`) notification or both - 2x a month - depending on the config set by the landloard * opt-out infomation (they can ignore this e-mail, but can also opt-out at any moment) If the user clicks the button "Verify e-mail" this triggers update of `BillingLocation.tenantEmailStatus`. diff --git a/web-app/app/lib/actions/locationActions.ts b/web-app/app/lib/actions/locationActions.ts index d548d2f..af79304 100644 --- a/web-app/app/lib/actions/locationActions.ts +++ b/web-app/app/lib/actions/locationActions.ts @@ -24,7 +24,7 @@ export type State = { tenantEmail?: string[]; tenantEmailStatus?: string[]; billFwdStrategy?: string[]; - rentDueNotification?: string[]; + rentDueNotificationEnabled?: string[]; rentDueDay?: string[]; rentAmount?: string[]; }; @@ -47,7 +47,7 @@ const FormSchema = (t:IntlTemplateFn) => z.object({ 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(), - rentDueNotification: z.boolean().optional().nullable(), + rentDueNotificationEnabled: z.boolean().optional().nullable(), rentDueDay: z.coerce.number().min(1).max(31).optional().nullable(), rentAmount: z.coerce.number().int(t("rent-amount-integer")).positive(t("rent-amount-positive")).optional().nullable(), addToSubsequentMonths: z.boolean().optional().nullable(), @@ -84,7 +84,7 @@ const FormSchema = (t:IntlTemplateFn) => z.object({ path: ["tenantTown"], }) .refine((data) => { - if (data.autoBillFwd || data.rentDueNotification) { + if (data.autoBillFwd || data.rentDueNotificationEnabled) { return !!data.tenantEmail && data.tenantEmail.trim().length > 0; } return true; @@ -93,7 +93,7 @@ const FormSchema = (t:IntlTemplateFn) => z.object({ path: ["tenantEmail"], }) .refine((data) => { - if (data.rentDueNotification) { + if (data.rentDueNotificationEnabled) { return !!data.rentAmount && data.rentAmount > 0; } return true; @@ -126,7 +126,7 @@ export const updateOrAddLocation = withUser(async (user:AuthenticatedUser, locat 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, - rentDueNotification: formData.get('rentDueNotification') === 'on', + rentDueNotificationEnabled: formData.get('rentDueNotificationEnabled') === 'on', rentDueDay: formData.get('rentDueDay') || null, rentAmount: formData.get('rentAmount') || null, addToSubsequentMonths: formData.get('addToSubsequentMonths') === 'on', @@ -152,7 +152,7 @@ export const updateOrAddLocation = withUser(async (user:AuthenticatedUser, locat tenantEmail, tenantEmailStatus, billFwdStrategy, - rentDueNotification, + rentDueNotificationEnabled, rentDueDay, rentAmount, addToSubsequentMonths, @@ -210,7 +210,7 @@ export const updateOrAddLocation = withUser(async (user:AuthenticatedUser, locat tenantEmail: tenantEmail || null, tenantEmailStatus: finalEmailStatus, billFwdStrategy: billFwdStrategy || "when-payed", - rentDueNotification: rentDueNotification || false, + rentDueNotificationEnabled: rentDueNotificationEnabled || false, rentDueDay: rentDueDay || null, rentAmount: rentAmount || null, } @@ -242,7 +242,7 @@ export const updateOrAddLocation = withUser(async (user:AuthenticatedUser, locat tenantEmail: tenantEmail || null, tenantEmailStatus: finalEmailStatus, billFwdStrategy: billFwdStrategy || "when-payed", - rentDueNotification: rentDueNotification || false, + rentDueNotificationEnabled: rentDueNotificationEnabled || false, rentDueDay: rentDueDay || null, rentAmount: rentAmount || null, } @@ -267,7 +267,7 @@ export const updateOrAddLocation = withUser(async (user:AuthenticatedUser, locat tenantEmail: tenantEmail || null, tenantEmailStatus: finalEmailStatus, billFwdStrategy: billFwdStrategy || "when-payed", - rentDueNotification: rentDueNotification || false, + rentDueNotificationEnabled: rentDueNotificationEnabled || false, rentDueDay: rentDueDay || null, rentAmount: rentAmount || null, } @@ -291,7 +291,7 @@ export const updateOrAddLocation = withUser(async (user:AuthenticatedUser, locat tenantEmail: tenantEmail || null, tenantEmailStatus: tenantEmailStatus as EmailStatus || EmailStatus.Unverified, billFwdStrategy: billFwdStrategy || "when-payed", - rentDueNotification: rentDueNotification || false, + rentDueNotificationEnabled: rentDueNotificationEnabled || false, rentDueDay: rentDueDay || null, rentAmount: rentAmount || null, yearMonth: yearMonth, @@ -367,7 +367,7 @@ export const updateOrAddLocation = withUser(async (user:AuthenticatedUser, locat tenantEmail: tenantEmail || null, tenantEmailStatus: tenantEmailStatus as EmailStatus || EmailStatus.Unverified, billFwdStrategy: billFwdStrategy || "when-payed", - rentDueNotification: rentDueNotification || false, + rentDueNotificationEnabled: rentDueNotificationEnabled || false, rentDueDay: rentDueDay || null, rentAmount: rentAmount || null, yearMonth: { year: monthData.year, month: monthData.month }, diff --git a/web-app/app/lib/db-types.ts b/web-app/app/lib/db-types.ts index a21b62e..d220372 100644 --- a/web-app/app/lib/db-types.ts +++ b/web-app/app/lib/db-types.ts @@ -84,9 +84,11 @@ export interface BillingLocation { /** (optional) bill forwarding strategy */ billFwdStrategy?: "when-payed" | "when-attached" | null; /** (optional) whether to automatically send rent notification */ - rentDueNotification?: boolean | null; + 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; /** (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 3b392d3..6a26a9f 100644 --- a/web-app/app/ui/LocationEditForm.tsx +++ b/web-app/app/ui/LocationEditForm.tsx @@ -46,7 +46,7 @@ export const LocationEditForm: FC = ({ location, yearMont proofOfPaymentType: location?.proofOfPaymentType ?? "none", autoBillFwd: location?.autoBillFwd ?? false, billFwdStrategy: location?.billFwdStrategy ?? "when-payed", - rentDueNotification: location?.rentDueNotification ?? false, + rentDueNotificationEnabled: location?.rentDueNotificationEnabled ?? false, rentAmount: location?.rentAmount ?? "", rentDueDay: location?.rentDueDay ?? 1, }); @@ -306,16 +306,16 @@ export const LocationEditForm: FC = ({ location, yearMont - {formValues.rentDueNotification && ( + {formValues.rentDueNotificationEnabled && (
{t("rent-due-day-label")} @@ -355,7 +355,7 @@ export const LocationEditForm: FC = ({ location, yearMont )}
- {(formValues.autoBillFwd || formValues.rentDueNotification) && ( + {(formValues.autoBillFwd || formValues.rentDueNotificationEnabled) && (
{t("tenant-email-legend")}