(refactor) rename: rentDueNotification > rentDueNotificationEnabled

This commit is contained in:
Knee Cola
2025-12-30 10:45:48 +01:00
parent 3e4d8fb95c
commit 4906cc1990
4 changed files with 22 additions and 20 deletions

View File

@@ -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: The text includes the following information:
* what the web app is about - very short into * 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 * 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.rentDueNotification`) or utility bills due (`BillingLocation.billFwdStrategy`) notification or both - 2x a month - depending on the config set by the landloard * 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) * 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`. If the user clicks the button "Verify e-mail" this triggers update of `BillingLocation.tenantEmailStatus`.

View File

@@ -24,7 +24,7 @@ export type State = {
tenantEmail?: string[]; tenantEmail?: string[];
tenantEmailStatus?: string[]; tenantEmailStatus?: string[];
billFwdStrategy?: string[]; billFwdStrategy?: string[];
rentDueNotification?: string[]; rentDueNotificationEnabled?: string[];
rentDueDay?: string[]; rentDueDay?: string[];
rentAmount?: 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(), 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(), tenantEmailStatus: z.enum([EmailStatus.Unverified, EmailStatus.VerificationPending, EmailStatus.Verified, EmailStatus.Unsubscribed]).optional().nullable(),
billFwdStrategy: z.enum(["when-payed", "when-attached"]).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(), 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(), rentAmount: z.coerce.number().int(t("rent-amount-integer")).positive(t("rent-amount-positive")).optional().nullable(),
addToSubsequentMonths: z.boolean().optional().nullable(), addToSubsequentMonths: z.boolean().optional().nullable(),
@@ -84,7 +84,7 @@ const FormSchema = (t:IntlTemplateFn) => z.object({
path: ["tenantTown"], path: ["tenantTown"],
}) })
.refine((data) => { .refine((data) => {
if (data.autoBillFwd || data.rentDueNotification) { if (data.autoBillFwd || data.rentDueNotificationEnabled) {
return !!data.tenantEmail && data.tenantEmail.trim().length > 0; return !!data.tenantEmail && data.tenantEmail.trim().length > 0;
} }
return true; return true;
@@ -93,7 +93,7 @@ const FormSchema = (t:IntlTemplateFn) => z.object({
path: ["tenantEmail"], path: ["tenantEmail"],
}) })
.refine((data) => { .refine((data) => {
if (data.rentDueNotification) { if (data.rentDueNotificationEnabled) {
return !!data.rentAmount && data.rentAmount > 0; return !!data.rentAmount && data.rentAmount > 0;
} }
return true; return true;
@@ -126,7 +126,7 @@ export const updateOrAddLocation = withUser(async (user:AuthenticatedUser, locat
tenantEmail: formData.get('tenantEmail') || null, tenantEmail: formData.get('tenantEmail') || null,
tenantEmailStatus: formData.get('tenantEmailStatus') as "unverified" | "verification-pending" | "verified" | "unsubscribed" | undefined, tenantEmailStatus: formData.get('tenantEmailStatus') as "unverified" | "verification-pending" | "verified" | "unsubscribed" | undefined,
billFwdStrategy: formData.get('billFwdStrategy') as "when-payed" | "when-attached" | 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, rentDueDay: formData.get('rentDueDay') || null,
rentAmount: formData.get('rentAmount') || null, rentAmount: formData.get('rentAmount') || null,
addToSubsequentMonths: formData.get('addToSubsequentMonths') === 'on', addToSubsequentMonths: formData.get('addToSubsequentMonths') === 'on',
@@ -152,7 +152,7 @@ export const updateOrAddLocation = withUser(async (user:AuthenticatedUser, locat
tenantEmail, tenantEmail,
tenantEmailStatus, tenantEmailStatus,
billFwdStrategy, billFwdStrategy,
rentDueNotification, rentDueNotificationEnabled,
rentDueDay, rentDueDay,
rentAmount, rentAmount,
addToSubsequentMonths, addToSubsequentMonths,
@@ -210,7 +210,7 @@ export const updateOrAddLocation = withUser(async (user:AuthenticatedUser, locat
tenantEmail: tenantEmail || null, tenantEmail: tenantEmail || null,
tenantEmailStatus: finalEmailStatus, tenantEmailStatus: finalEmailStatus,
billFwdStrategy: billFwdStrategy || "when-payed", billFwdStrategy: billFwdStrategy || "when-payed",
rentDueNotification: rentDueNotification || false, rentDueNotificationEnabled: rentDueNotificationEnabled || false,
rentDueDay: rentDueDay || null, rentDueDay: rentDueDay || null,
rentAmount: rentAmount || null, rentAmount: rentAmount || null,
} }
@@ -242,7 +242,7 @@ export const updateOrAddLocation = withUser(async (user:AuthenticatedUser, locat
tenantEmail: tenantEmail || null, tenantEmail: tenantEmail || null,
tenantEmailStatus: finalEmailStatus, tenantEmailStatus: finalEmailStatus,
billFwdStrategy: billFwdStrategy || "when-payed", billFwdStrategy: billFwdStrategy || "when-payed",
rentDueNotification: rentDueNotification || false, rentDueNotificationEnabled: rentDueNotificationEnabled || false,
rentDueDay: rentDueDay || null, rentDueDay: rentDueDay || null,
rentAmount: rentAmount || null, rentAmount: rentAmount || null,
} }
@@ -267,7 +267,7 @@ export const updateOrAddLocation = withUser(async (user:AuthenticatedUser, locat
tenantEmail: tenantEmail || null, tenantEmail: tenantEmail || null,
tenantEmailStatus: finalEmailStatus, tenantEmailStatus: finalEmailStatus,
billFwdStrategy: billFwdStrategy || "when-payed", billFwdStrategy: billFwdStrategy || "when-payed",
rentDueNotification: rentDueNotification || false, rentDueNotificationEnabled: rentDueNotificationEnabled || false,
rentDueDay: rentDueDay || null, rentDueDay: rentDueDay || null,
rentAmount: rentAmount || null, rentAmount: rentAmount || null,
} }
@@ -291,7 +291,7 @@ export const updateOrAddLocation = withUser(async (user:AuthenticatedUser, locat
tenantEmail: tenantEmail || null, tenantEmail: tenantEmail || null,
tenantEmailStatus: tenantEmailStatus as EmailStatus || EmailStatus.Unverified, tenantEmailStatus: tenantEmailStatus as EmailStatus || EmailStatus.Unverified,
billFwdStrategy: billFwdStrategy || "when-payed", billFwdStrategy: billFwdStrategy || "when-payed",
rentDueNotification: rentDueNotification || false, rentDueNotificationEnabled: rentDueNotificationEnabled || false,
rentDueDay: rentDueDay || null, rentDueDay: rentDueDay || null,
rentAmount: rentAmount || null, rentAmount: rentAmount || null,
yearMonth: yearMonth, yearMonth: yearMonth,
@@ -367,7 +367,7 @@ export const updateOrAddLocation = withUser(async (user:AuthenticatedUser, locat
tenantEmail: tenantEmail || null, tenantEmail: tenantEmail || null,
tenantEmailStatus: tenantEmailStatus as EmailStatus || EmailStatus.Unverified, tenantEmailStatus: tenantEmailStatus as EmailStatus || EmailStatus.Unverified,
billFwdStrategy: billFwdStrategy || "when-payed", billFwdStrategy: billFwdStrategy || "when-payed",
rentDueNotification: rentDueNotification || false, rentDueNotificationEnabled: rentDueNotificationEnabled || false,
rentDueDay: rentDueDay || null, rentDueDay: rentDueDay || null,
rentAmount: rentAmount || null, rentAmount: rentAmount || null,
yearMonth: { year: monthData.year, month: monthData.month }, yearMonth: { year: monthData.year, month: monthData.month },

View File

@@ -84,9 +84,11 @@ export interface BillingLocation {
/** (optional) bill forwarding strategy */ /** (optional) bill forwarding strategy */
billFwdStrategy?: "when-payed" | "when-attached" | null; billFwdStrategy?: "when-payed" | "when-attached" | null;
/** (optional) whether to automatically send rent notification */ /** (optional) whether to automatically send rent notification */
rentDueNotification?: boolean | null; rentDueNotificationEnabled?: boolean | null;
/** (optional) day of month when rent is due (1-31) */ /** (optional) day of month when rent is due (1-31) */
rentDueDay?: number | null; rentDueDay?: number | null;
/** (optional) when was the rent due notification sent */
rentDueNotificationEnabledSentAt?: number | null;
/** (optional) monthly rent amount in cents */ /** (optional) monthly rent amount in cents */
rentAmount?: number | null; rentAmount?: number | null;
/** (optional) whether the location has been seen by tenant */ /** (optional) whether the location has been seen by tenant */

View File

@@ -46,7 +46,7 @@ export const LocationEditForm: FC<LocationEditFormProps> = ({ location, yearMont
proofOfPaymentType: location?.proofOfPaymentType ?? "none", proofOfPaymentType: location?.proofOfPaymentType ?? "none",
autoBillFwd: location?.autoBillFwd ?? false, autoBillFwd: location?.autoBillFwd ?? false,
billFwdStrategy: location?.billFwdStrategy ?? "when-payed", billFwdStrategy: location?.billFwdStrategy ?? "when-payed",
rentDueNotification: location?.rentDueNotification ?? false, rentDueNotificationEnabled: location?.rentDueNotificationEnabled ?? false,
rentAmount: location?.rentAmount ?? "", rentAmount: location?.rentAmount ?? "",
rentDueDay: location?.rentDueDay ?? 1, rentDueDay: location?.rentDueDay ?? 1,
}); });
@@ -306,16 +306,16 @@ export const LocationEditForm: FC<LocationEditFormProps> = ({ location, yearMont
<label className="label cursor-pointer justify-start gap-3"> <label className="label cursor-pointer justify-start gap-3">
<input <input
type="checkbox" type="checkbox"
name="rentDueNotification" name="rentDueNotificationEnabled"
className="toggle toggle-primary" className="toggle toggle-primary"
checked={formValues.rentDueNotification} checked={formValues.rentDueNotificationEnabled}
onChange={(e) => handleInputChange("rentDueNotification", e.target.checked)} onChange={(e) => handleInputChange("rentDueNotificationEnabled", e.target.checked)}
/> />
<legend className="fieldset-legend">{t("auto-rent-notification-toggle-label")}</legend> <legend className="fieldset-legend">{t("auto-rent-notification-toggle-label")}</legend>
</label> </label>
</fieldset> </fieldset>
{formValues.rentDueNotification && ( {formValues.rentDueNotificationEnabled && (
<div className="animate-expand-fade-in origin-top"> <div className="animate-expand-fade-in origin-top">
<fieldset className="fieldset mt-2 p-2"> <fieldset className="fieldset mt-2 p-2">
<legend className="fieldset-legend">{t("rent-due-day-label")}</legend> <legend className="fieldset-legend">{t("rent-due-day-label")}</legend>
@@ -355,7 +355,7 @@ export const LocationEditForm: FC<LocationEditFormProps> = ({ location, yearMont
)} )}
</fieldset> </fieldset>
{(formValues.autoBillFwd || formValues.rentDueNotification) && ( {(formValues.autoBillFwd || formValues.rentDueNotificationEnabled) && (
<fieldset className="fieldset bg-base-200 border-base-300 rounded-box w-xs border p-4 pb-2 mt-4"> <fieldset className="fieldset bg-base-200 border-base-300 rounded-box w-xs border p-4 pb-2 mt-4">
<legend className="fieldset-legend font-semibold uppercase">{t("tenant-email-legend")}</legend> <legend className="fieldset-legend font-semibold uppercase">{t("tenant-email-legend")}</legend>
<input <input