(refactor) renames autoBillFwd > billFwdEnabled

This commit is contained in:
Knee Cola
2025-12-30 11:09:21 +01:00
parent 4906cc1990
commit e9012ed231
4 changed files with 23 additions and 19 deletions

2
.gitignore vendored
View File

@@ -52,3 +52,5 @@ mongo-backup/
.serena/
*.serena-memory
mongo-backup/
.git/

View File

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

View File

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

View File

@@ -44,7 +44,7 @@ export const LocationEditForm: FC<LocationEditFormProps> = ({ 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<LocationEditFormProps> = ({ location, yearMont
<label className="label cursor-pointer justify-start gap-3">
<input
type="checkbox"
name="autoBillFwd"
name="billFwdEnabled"
className="toggle toggle-primary"
checked={formValues.autoBillFwd}
onChange={(e) => handleInputChange("autoBillFwd", e.target.checked)}
checked={formValues.billFwdEnabled}
onChange={(e) => handleInputChange("billFwdEnabled", e.target.checked)}
/>
<legend className="fieldset-legend">{t("auto-utility-bill-forwarding-toggle-label")}</legend>
</label>
</fieldset>
{formValues.autoBillFwd && (
{formValues.billFwdEnabled && (
<fieldset className="fieldset mt-2 p-2">
<legend className="fieldset-legend">{t("utility-bill-forwarding-strategy-label")}</legend>
<select defaultValue={formValues.billFwdStrategy} className="select input-bordered w-full" name="billFwdStrategy">
@@ -355,7 +355,7 @@ export const LocationEditForm: FC<LocationEditFormProps> = ({ location, yearMont
)}
</fieldset>
{(formValues.autoBillFwd || formValues.rentDueNotificationEnabled) && (
{(formValues.billFwdEnabled || formValues.rentDueNotificationEnabled) && (
<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>
<input