refactor: improve notification naming and introduce type-safe enums

- Rename billFwd* to billsNotification* for clarity
- Rename rentDueNotification* to rentNotification* for consistency
- Rename utilBillsProofOfPayment to billsProofOfPayment
- Introduce enums for type safety:
  - BillsNotificationStrategy (WhenPayed, WhenAttached)
  - BillsNotificationStatus (Scheduled, Sent, Failed)
  - RentNotificationStatus (Sent, Failed)
- Replace "pending" status with "scheduled" for better semantics
- Fix function names to proper camelCase
- Fix incorrect import path in web-app/app/lib/format.ts

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
Knee Cola
2026-01-06 13:05:22 +01:00
parent 0556ad2533
commit fb35e0278e
13 changed files with 160 additions and 137 deletions

View File

@@ -2,7 +2,7 @@
import { TrashIcon, ExclamationTriangleIcon, ClockIcon, EnvelopeIcon, CheckCircleIcon, PencilSquareIcon, XCircleIcon } from "@heroicons/react/24/outline";
import { FC, useState } from "react";
import { BillingLocation, UserSettings, YearMonth, EmailStatus } from '@evidencija-rezija/shared-code';
import { BillingLocation, UserSettings, YearMonth, EmailStatus, BillsNotificationStrategy } from '@evidencija-rezija/shared-code';
import { updateOrAddLocation } from "../lib/actions/locationActions";
import { useFormState } from "react-dom";
import Link from "next/link";
@@ -45,9 +45,9 @@ export const LocationEditForm: FC<LocationEditFormProps> = ({ location, yearMont
tenantEmailLanguage: location?.tenantEmailLanguage ?? (locale as "hr" | "en"),
tenantPaymentMethod: location?.tenantPaymentMethod ?? "none",
proofOfPaymentType: location?.proofOfPaymentType ?? "none",
billFwdEnabled: location?.billFwdEnabled ?? false,
billFwdStrategy: location?.billFwdStrategy ?? "when-payed",
rentDueNotificationEnabled: location?.rentDueNotificationEnabled ?? false,
billsNotificationEnabled: location?.billsNotificationEnabled ?? false,
billsNotificationStrategy: location?.billsNotificationStrategy ?? BillsNotificationStrategy.WhenPayed,
rentNotificationEnabled: location?.rentNotificationEnabled ?? false,
rentAmount: location?.rentAmount ?? "",
rentDueDay: location?.rentDueDay ?? 1,
});
@@ -279,21 +279,21 @@ export const LocationEditForm: FC<LocationEditFormProps> = ({ location, yearMont
<label className="label cursor-pointer justify-start gap-3">
<input
type="checkbox"
name="billFwdEnabled"
name="billsNotificationEnabled"
className="toggle toggle-primary"
checked={formValues.billFwdEnabled}
onChange={(e) => handleInputChange("billFwdEnabled", e.target.checked)}
checked={formValues.billsNotificationEnabled}
onChange={(e) => handleInputChange("billsNotificationEnabled", e.target.checked)}
/>
<legend className="fieldset-legend">{t("auto-utility-bill-forwarding-toggle-label")}</legend>
</label>
</fieldset>
{formValues.billFwdEnabled && (
{formValues.billsNotificationEnabled && (
<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">
<option value="when-payed">{t("utility-bill-forwarding-when-payed")}</option>
<option value="when-attached">{t("utility-bill-forwarding-when-attached")}</option>
<select defaultValue={formValues.billsNotificationStrategy} className="select input-bordered w-full" name="billsNotificationStrategy">
<option value={BillsNotificationStrategy.WhenPayed}>{t("utility-bill-forwarding-when-payed")}</option>
<option value={BillsNotificationStrategy.WhenAttached}>{t("utility-bill-forwarding-when-attached")}</option>
</select>
</fieldset>
)}
@@ -307,16 +307,16 @@ export const LocationEditForm: FC<LocationEditFormProps> = ({ location, yearMont
<label className="label cursor-pointer justify-start gap-3">
<input
type="checkbox"
name="rentDueNotificationEnabled"
name="rentNotificationEnabled"
className="toggle toggle-primary"
checked={formValues.rentDueNotificationEnabled}
onChange={(e) => handleInputChange("rentDueNotificationEnabled", e.target.checked)}
checked={formValues.rentNotificationEnabled}
onChange={(e) => handleInputChange("rentNotificationEnabled", e.target.checked)}
/>
<legend className="fieldset-legend">{t("auto-rent-notification-toggle-label")}</legend>
</label>
</fieldset>
{formValues.rentDueNotificationEnabled && (
{formValues.rentNotificationEnabled && (
<div className="animate-expand-fade-in origin-top">
<fieldset className="fieldset mt-2 p-2">
<legend className="fieldset-legend">{t("rent-due-day-label")}</legend>
@@ -356,7 +356,7 @@ export const LocationEditForm: FC<LocationEditFormProps> = ({ location, yearMont
)}
</fieldset>
{(formValues.billFwdEnabled || formValues.rentDueNotificationEnabled) && (
{(formValues.billsNotificationEnabled || formValues.rentNotificationEnabled) && (
<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>
<label className="label">