(refactor) renames autoBillFwd > billFwdEnabled
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -52,3 +52,5 @@ mongo-backup/
|
|||||||
.serena/
|
.serena/
|
||||||
*.serena-memory
|
*.serena-memory
|
||||||
mongo-backup/
|
mongo-backup/
|
||||||
|
|
||||||
|
.git/
|
||||||
@@ -20,7 +20,7 @@ export type State = {
|
|||||||
tenantName?: string[];
|
tenantName?: string[];
|
||||||
tenantStreet?: string[];
|
tenantStreet?: string[];
|
||||||
tenantTown?: string[];
|
tenantTown?: string[];
|
||||||
autoBillFwd?: string[];
|
billFwdEnabled?: string[];
|
||||||
tenantEmail?: string[];
|
tenantEmail?: string[];
|
||||||
tenantEmailStatus?: string[];
|
tenantEmailStatus?: string[];
|
||||||
billFwdStrategy?: string[];
|
billFwdStrategy?: string[];
|
||||||
@@ -43,7 +43,7 @@ const FormSchema = (t:IntlTemplateFn) => z.object({
|
|||||||
tenantName: z.string().max(30).optional().nullable(),
|
tenantName: z.string().max(30).optional().nullable(),
|
||||||
tenantStreet: z.string().max(27).optional().nullable(),
|
tenantStreet: z.string().max(27).optional().nullable(),
|
||||||
tenantTown: 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(),
|
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(),
|
||||||
@@ -84,7 +84,7 @@ const FormSchema = (t:IntlTemplateFn) => z.object({
|
|||||||
path: ["tenantTown"],
|
path: ["tenantTown"],
|
||||||
})
|
})
|
||||||
.refine((data) => {
|
.refine((data) => {
|
||||||
if (data.autoBillFwd || data.rentDueNotificationEnabled) {
|
if (data.billFwdEnabled || data.rentDueNotificationEnabled) {
|
||||||
return !!data.tenantEmail && data.tenantEmail.trim().length > 0;
|
return !!data.tenantEmail && data.tenantEmail.trim().length > 0;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@@ -122,7 +122,7 @@ export const updateOrAddLocation = withUser(async (user:AuthenticatedUser, locat
|
|||||||
tenantName: formData.get('tenantName') || null,
|
tenantName: formData.get('tenantName') || null,
|
||||||
tenantStreet: formData.get('tenantStreet') || null,
|
tenantStreet: formData.get('tenantStreet') || null,
|
||||||
tenantTown: formData.get('tenantTown') || null,
|
tenantTown: formData.get('tenantTown') || null,
|
||||||
autoBillFwd: formData.get('autoBillFwd') === 'on',
|
billFwdEnabled: formData.get('billFwdEnabled') === 'on',
|
||||||
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,
|
||||||
@@ -148,7 +148,7 @@ export const updateOrAddLocation = withUser(async (user:AuthenticatedUser, locat
|
|||||||
tenantName,
|
tenantName,
|
||||||
tenantStreet,
|
tenantStreet,
|
||||||
tenantTown,
|
tenantTown,
|
||||||
autoBillFwd,
|
billFwdEnabled,
|
||||||
tenantEmail,
|
tenantEmail,
|
||||||
tenantEmailStatus,
|
tenantEmailStatus,
|
||||||
billFwdStrategy,
|
billFwdStrategy,
|
||||||
@@ -206,7 +206,7 @@ export const updateOrAddLocation = withUser(async (user:AuthenticatedUser, locat
|
|||||||
tenantName: tenantName || null,
|
tenantName: tenantName || null,
|
||||||
tenantStreet: tenantStreet || null,
|
tenantStreet: tenantStreet || null,
|
||||||
tenantTown: tenantTown || null,
|
tenantTown: tenantTown || null,
|
||||||
autoBillFwd: autoBillFwd || false,
|
billFwdEnabled: billFwdEnabled || false,
|
||||||
tenantEmail: tenantEmail || null,
|
tenantEmail: tenantEmail || null,
|
||||||
tenantEmailStatus: finalEmailStatus,
|
tenantEmailStatus: finalEmailStatus,
|
||||||
billFwdStrategy: billFwdStrategy || "when-payed",
|
billFwdStrategy: billFwdStrategy || "when-payed",
|
||||||
@@ -238,7 +238,7 @@ export const updateOrAddLocation = withUser(async (user:AuthenticatedUser, locat
|
|||||||
tenantName: tenantName || null,
|
tenantName: tenantName || null,
|
||||||
tenantStreet: tenantStreet || null,
|
tenantStreet: tenantStreet || null,
|
||||||
tenantTown: tenantTown || null,
|
tenantTown: tenantTown || null,
|
||||||
autoBillFwd: autoBillFwd || false,
|
billFwdEnabled: billFwdEnabled || false,
|
||||||
tenantEmail: tenantEmail || null,
|
tenantEmail: tenantEmail || null,
|
||||||
tenantEmailStatus: finalEmailStatus,
|
tenantEmailStatus: finalEmailStatus,
|
||||||
billFwdStrategy: billFwdStrategy || "when-payed",
|
billFwdStrategy: billFwdStrategy || "when-payed",
|
||||||
@@ -263,7 +263,7 @@ export const updateOrAddLocation = withUser(async (user:AuthenticatedUser, locat
|
|||||||
tenantName: tenantName || null,
|
tenantName: tenantName || null,
|
||||||
tenantStreet: tenantStreet || null,
|
tenantStreet: tenantStreet || null,
|
||||||
tenantTown: tenantTown || null,
|
tenantTown: tenantTown || null,
|
||||||
autoBillFwd: autoBillFwd || false,
|
billFwdEnabled: billFwdEnabled || false,
|
||||||
tenantEmail: tenantEmail || null,
|
tenantEmail: tenantEmail || null,
|
||||||
tenantEmailStatus: finalEmailStatus,
|
tenantEmailStatus: finalEmailStatus,
|
||||||
billFwdStrategy: billFwdStrategy || "when-payed",
|
billFwdStrategy: billFwdStrategy || "when-payed",
|
||||||
@@ -287,7 +287,7 @@ export const updateOrAddLocation = withUser(async (user:AuthenticatedUser, locat
|
|||||||
tenantName: tenantName || null,
|
tenantName: tenantName || null,
|
||||||
tenantStreet: tenantStreet || null,
|
tenantStreet: tenantStreet || null,
|
||||||
tenantTown: tenantTown || null,
|
tenantTown: tenantTown || null,
|
||||||
autoBillFwd: autoBillFwd || false,
|
billFwdEnabled: billFwdEnabled || false,
|
||||||
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",
|
||||||
@@ -363,7 +363,7 @@ export const updateOrAddLocation = withUser(async (user:AuthenticatedUser, locat
|
|||||||
tenantName: tenantName || null,
|
tenantName: tenantName || null,
|
||||||
tenantStreet: tenantStreet || null,
|
tenantStreet: tenantStreet || null,
|
||||||
tenantTown: tenantTown || null,
|
tenantTown: tenantTown || null,
|
||||||
autoBillFwd: autoBillFwd || false,
|
billFwdEnabled: billFwdEnabled || false,
|
||||||
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",
|
||||||
|
|||||||
@@ -75,20 +75,22 @@ export interface BillingLocation {
|
|||||||
tenantStreet?: string | null;
|
tenantStreet?: string | null;
|
||||||
/** (optional) tenant town */
|
/** (optional) tenant town */
|
||||||
tenantTown?: string | null;
|
tenantTown?: string | null;
|
||||||
/** (optional) whether to automatically notify tenant */
|
|
||||||
autoBillFwd?: boolean | null;
|
|
||||||
/** (optional) tenant email */
|
/** (optional) tenant email */
|
||||||
tenantEmail?: string | null;
|
tenantEmail?: string | null;
|
||||||
/** (optional) tenant email status */
|
/** (optional) tenant email status */
|
||||||
tenantEmailStatus?: EmailStatus | null;
|
tenantEmailStatus?: EmailStatus | null;
|
||||||
|
/** (optional) whether to automatically notify tenant */
|
||||||
|
billFwdEnabled?: boolean | null;
|
||||||
/** (optional) bill forwarding strategy */
|
/** (optional) bill forwarding strategy */
|
||||||
billFwdStrategy?: "when-payed" | "when-attached" | null;
|
billFwdStrategy?: "when-payed" | "when-attached" | null;
|
||||||
|
/** (optional) bill forwarding status */
|
||||||
|
billFwdStatus?: "pending" | "sent" | "failed" | null;
|
||||||
/** (optional) whether to automatically send rent notification */
|
/** (optional) whether to automatically send rent notification */
|
||||||
rentDueNotificationEnabled?: 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 */
|
/** (optional) when was the rent due notification sent */
|
||||||
rentDueNotificationEnabledSentAt?: number | null;
|
rentDueNotificationStatus?: "sent" | "failed" | 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 */
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ export const LocationEditForm: FC<LocationEditFormProps> = ({ location, yearMont
|
|||||||
tenantEmailStatus: location?.tenantEmailStatus ?? EmailStatus.Unverified,
|
tenantEmailStatus: location?.tenantEmailStatus ?? EmailStatus.Unverified,
|
||||||
tenantPaymentMethod: location?.tenantPaymentMethod ?? "none",
|
tenantPaymentMethod: location?.tenantPaymentMethod ?? "none",
|
||||||
proofOfPaymentType: location?.proofOfPaymentType ?? "none",
|
proofOfPaymentType: location?.proofOfPaymentType ?? "none",
|
||||||
autoBillFwd: location?.autoBillFwd ?? false,
|
billFwdEnabled: location?.billFwdEnabled ?? false,
|
||||||
billFwdStrategy: location?.billFwdStrategy ?? "when-payed",
|
billFwdStrategy: location?.billFwdStrategy ?? "when-payed",
|
||||||
rentDueNotificationEnabled: location?.rentDueNotificationEnabled ?? false,
|
rentDueNotificationEnabled: location?.rentDueNotificationEnabled ?? false,
|
||||||
rentAmount: location?.rentAmount ?? "",
|
rentAmount: location?.rentAmount ?? "",
|
||||||
@@ -278,16 +278,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="autoBillFwd"
|
name="billFwdEnabled"
|
||||||
className="toggle toggle-primary"
|
className="toggle toggle-primary"
|
||||||
checked={formValues.autoBillFwd}
|
checked={formValues.billFwdEnabled}
|
||||||
onChange={(e) => handleInputChange("autoBillFwd", e.target.checked)}
|
onChange={(e) => handleInputChange("billFwdEnabled", e.target.checked)}
|
||||||
/>
|
/>
|
||||||
<legend className="fieldset-legend">{t("auto-utility-bill-forwarding-toggle-label")}</legend>
|
<legend className="fieldset-legend">{t("auto-utility-bill-forwarding-toggle-label")}</legend>
|
||||||
</label>
|
</label>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
|
||||||
{formValues.autoBillFwd && (
|
{formValues.billFwdEnabled && (
|
||||||
<fieldset className="fieldset mt-2 p-2">
|
<fieldset className="fieldset mt-2 p-2">
|
||||||
<legend className="fieldset-legend">{t("utility-bill-forwarding-strategy-label")}</legend>
|
<legend className="fieldset-legend">{t("utility-bill-forwarding-strategy-label")}</legend>
|
||||||
<select defaultValue={formValues.billFwdStrategy} className="select input-bordered w-full" name="billFwdStrategy">
|
<select defaultValue={formValues.billFwdStrategy} className="select input-bordered w-full" name="billFwdStrategy">
|
||||||
@@ -355,7 +355,7 @@ export const LocationEditForm: FC<LocationEditFormProps> = ({ location, yearMont
|
|||||||
)}
|
)}
|
||||||
</fieldset>
|
</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">
|
<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
|
||||||
|
|||||||
Reference in New Issue
Block a user