refactor: replace generateTenantCode boolean with tenantPaymentMethod enum

- Replace generateTenantCode boolean field with tenantPaymentMethod enum ("none" | "iban" | "revolut")
- Update LocationEditForm to use dropdown select instead of toggle for payment method selection
- Consolidate multiple useState hooks into single formValues state object
- Change from defaultValue to controlled components with value/onChange pattern
- Add hidden inputs to preserve tenant data when payment method is not selected
- Update validation logic to check tenantPaymentMethod === "iban"
- Update ViewLocationCard to use new tenantPaymentMethod field
- Add Croatian translations for new dropdown options

This provides better scalability for adding future payment methods and improves form state management.

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

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-11-24 15:34:59 +01:00
parent ead7451170
commit 3e581d8878
5 changed files with 108 additions and 74 deletions

View File

@@ -27,7 +27,7 @@ export const ViewLocationCard:FC<ViewLocationCardProps> = ({location, userSettin
tenantName,
tenantStreet,
tenantTown,
generateTenantCode,
tenantPaymentMethod,
// NOTE: only the fileName is projected from the DB to reduce data transfer
utilBillsProofOfPaymentAttachment,
utilBillsProofOfPaymentUploadedAt,
@@ -79,7 +79,7 @@ export const ViewLocationCard:FC<ViewLocationCardProps> = ({location, userSettin
const { hub3aText, paymentParams } = useMemo(() => {
if(!userSettings?.enableIbanPayment || !generateTenantCode) {
if(!userSettings?.enableIbanPayment || tenantPaymentMethod !== "iban") {
return {
hub3aText: "",
paymentParams: {} as PaymentParams
@@ -126,7 +126,7 @@ export const ViewLocationCard:FC<ViewLocationCardProps> = ({location, userSettin
: null
}
{
userSettings?.enableIbanPayment && generateTenantCode ?
userSettings?.enableIbanPayment && tenantPaymentMethod === "iban" ?
<>
<p className="max-w-[25em] ml-1 mt-1 mb-1">{t("payment-info-header")}</p>
<ul className="ml-4 mb-3">