(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

@@ -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 },

View File

@@ -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 */