Rename 'iban' to 'ownerIBAN' in UserSettings
Changes: - Updated UserSettings interface: iban -> ownerIBAN - Updated userSettingsActions.ts: - Changed State type to use ownerIBAN - Updated FormSchema validation to reference ownerIBAN - Updated validation refinements to check ownerIBAN - Updated form data parsing to read ownerIBAN - Renamed normalizedIban to normalizedOwnerIBAN - Updated database write operations to use ownerIBAN - Updated UserSettingsForm.tsx: - Changed state tracking to use ownerIBAN - Updated validation check to reference ownerIBAN (cleanedOwnerIBAN) - Updated input field: id, name, and event handlers - Updated ViewLocationCard.tsx to use ownerIBAN instead of iban - Updated English translations: - iban-label -> owner-iban-label - iban-placeholder -> owner-iban-placeholder - iban-required -> owner-iban-required - iban-invalid -> owner-iban-invalid - Updated Croatian translations with corresponding ownerIBAN keys 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -17,7 +17,7 @@ export type State = {
|
|||||||
ownerName?: string[];
|
ownerName?: string[];
|
||||||
ownerStreet?: string[];
|
ownerStreet?: string[];
|
||||||
ownerTown?: string[];
|
ownerTown?: string[];
|
||||||
iban?: string[];
|
ownerIBAN?: string[];
|
||||||
currency?: string[];
|
currency?: string[];
|
||||||
show2dCodeInMonthlyStatement?: string[];
|
show2dCodeInMonthlyStatement?: string[];
|
||||||
};
|
};
|
||||||
@@ -32,7 +32,7 @@ const FormSchema = (t: IntlTemplateFn) => z.object({
|
|||||||
ownerName: z.string().max(25).optional(),
|
ownerName: z.string().max(25).optional(),
|
||||||
ownerStreet: z.string().max(25).optional(),
|
ownerStreet: z.string().max(25).optional(),
|
||||||
ownerTown: z.string().max(27).optional(),
|
ownerTown: z.string().max(27).optional(),
|
||||||
iban: z.string()
|
ownerIBAN: z.string()
|
||||||
.optional()
|
.optional()
|
||||||
.refine(
|
.refine(
|
||||||
(val) => {
|
(val) => {
|
||||||
@@ -41,7 +41,7 @@ const FormSchema = (t: IntlTemplateFn) => z.object({
|
|||||||
const cleaned = val.replace(/\s/g, '').toUpperCase();
|
const cleaned = val.replace(/\s/g, '').toUpperCase();
|
||||||
return IBAN.isValid(cleaned);
|
return IBAN.isValid(cleaned);
|
||||||
},
|
},
|
||||||
{ message: t("iban-invalid") }
|
{ message: t("owner-iban-invalid") }
|
||||||
),
|
),
|
||||||
currency: z.string().optional(),
|
currency: z.string().optional(),
|
||||||
show2dCodeInMonthlyStatement: z.boolean().optional().nullable(),
|
show2dCodeInMonthlyStatement: z.boolean().optional().nullable(),
|
||||||
@@ -75,17 +75,17 @@ const FormSchema = (t: IntlTemplateFn) => z.object({
|
|||||||
})
|
})
|
||||||
.refine((data) => {
|
.refine((data) => {
|
||||||
if (data.show2dCodeInMonthlyStatement) {
|
if (data.show2dCodeInMonthlyStatement) {
|
||||||
if (!data.iban || data.iban.trim().length === 0) {
|
if (!data.ownerIBAN || data.ownerIBAN.trim().length === 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// Validate IBAN format when required
|
// Validate IBAN format when required
|
||||||
const cleaned = data.iban.replace(/\s/g, '').toUpperCase();
|
const cleaned = data.ownerIBAN.replace(/\s/g, '').toUpperCase();
|
||||||
return IBAN.isValid(cleaned);
|
return IBAN.isValid(cleaned);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}, {
|
}, {
|
||||||
message: t("iban-required"),
|
message: t("owner-iban-required"),
|
||||||
path: ["iban"],
|
path: ["ownerIBAN"],
|
||||||
})
|
})
|
||||||
.refine((data) => {
|
.refine((data) => {
|
||||||
if (data.show2dCodeInMonthlyStatement) {
|
if (data.show2dCodeInMonthlyStatement) {
|
||||||
@@ -139,7 +139,7 @@ export const updateUserSettings = withUser(async (user: AuthenticatedUser, prevS
|
|||||||
ownerName: formData.get('ownerName') || undefined,
|
ownerName: formData.get('ownerName') || undefined,
|
||||||
ownerStreet: formData.get('ownerStreet') || undefined,
|
ownerStreet: formData.get('ownerStreet') || undefined,
|
||||||
ownerTown: formData.get('ownerTown') || undefined,
|
ownerTown: formData.get('ownerTown') || undefined,
|
||||||
iban: formData.get('iban') || undefined,
|
ownerIBAN: formData.get('ownerIBAN') || undefined,
|
||||||
currency: formData.get('currency') || undefined,
|
currency: formData.get('currency') || undefined,
|
||||||
show2dCodeInMonthlyStatement: formData.get('generateTenantCode') === 'on',
|
show2dCodeInMonthlyStatement: formData.get('generateTenantCode') === 'on',
|
||||||
});
|
});
|
||||||
@@ -153,10 +153,10 @@ export const updateUserSettings = withUser(async (user: AuthenticatedUser, prevS
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
const { ownerName, ownerStreet, ownerTown, iban, currency, show2dCodeInMonthlyStatement } = validatedFields.data;
|
const { ownerName, ownerStreet, ownerTown, ownerIBAN, currency, show2dCodeInMonthlyStatement } = validatedFields.data;
|
||||||
|
|
||||||
// Normalize IBAN: remove spaces and convert to uppercase
|
// Normalize IBAN: remove spaces and convert to uppercase
|
||||||
const normalizedIban = iban ? iban.replace(/\s/g, '').toUpperCase() : null;
|
const normalizedOwnerIBAN = ownerIBAN ? ownerIBAN.replace(/\s/g, '').toUpperCase() : null;
|
||||||
|
|
||||||
// Update the user settings in MongoDB
|
// Update the user settings in MongoDB
|
||||||
const dbClient = await getDbClient();
|
const dbClient = await getDbClient();
|
||||||
@@ -167,7 +167,7 @@ export const updateUserSettings = withUser(async (user: AuthenticatedUser, prevS
|
|||||||
ownerName: ownerName || null,
|
ownerName: ownerName || null,
|
||||||
ownerStreet: ownerStreet || null,
|
ownerStreet: ownerStreet || null,
|
||||||
ownerTown: ownerTown || null,
|
ownerTown: ownerTown || null,
|
||||||
iban: normalizedIban,
|
ownerIBAN: normalizedOwnerIBAN,
|
||||||
currency: currency || null,
|
currency: currency || null,
|
||||||
show2dCodeInMonthlyStatement: show2dCodeInMonthlyStatement ?? false,
|
show2dCodeInMonthlyStatement: show2dCodeInMonthlyStatement ?? false,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -24,8 +24,8 @@ export interface UserSettings {
|
|||||||
ownerStreet?: string | null;
|
ownerStreet?: string | null;
|
||||||
/** owner town */
|
/** owner town */
|
||||||
ownerTown?: string | null;
|
ownerTown?: string | null;
|
||||||
/** IBAN */
|
/** owner IBAN */
|
||||||
iban?: string | null;
|
ownerIBAN?: string | null;
|
||||||
/** currency (ISO 4217) */
|
/** currency (ISO 4217) */
|
||||||
currency?: string | null;
|
currency?: string | null;
|
||||||
/** whether to show 2D code in monthly statement */
|
/** whether to show 2D code in monthly statement */
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ const FormFields: FC<FormFieldsProps> = ({ userSettings, errors, message }) => {
|
|||||||
ownerName: userSettings?.ownerName ?? "",
|
ownerName: userSettings?.ownerName ?? "",
|
||||||
ownerStreet: userSettings?.ownerStreet ?? "",
|
ownerStreet: userSettings?.ownerStreet ?? "",
|
||||||
ownerTown: userSettings?.ownerTown ?? "",
|
ownerTown: userSettings?.ownerTown ?? "",
|
||||||
iban: formatIban(userSettings?.iban) ?? "",
|
ownerIBAN: formatIban(userSettings?.ownerIBAN) ?? "",
|
||||||
currency: userSettings?.currency ?? "EUR",
|
currency: userSettings?.currency ?? "EUR",
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -39,8 +39,8 @@ const FormFields: FC<FormFieldsProps> = ({ userSettings, errors, message }) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Check if any required field is missing (clean IBAN of spaces for validation)
|
// Check if any required field is missing (clean IBAN of spaces for validation)
|
||||||
const cleanedIban = formValues.iban.replace(/\s/g, '');
|
const cleanedOwnerIBAN = formValues.ownerIBAN.replace(/\s/g, '');
|
||||||
const hasMissingData = !formValues.ownerName || !formValues.ownerStreet || !formValues.ownerTown || !cleanedIban || !formValues.currency;
|
const hasMissingData = !formValues.ownerName || !formValues.ownerStreet || !formValues.ownerTown || !cleanedOwnerIBAN || !formValues.currency;
|
||||||
|
|
||||||
// Track whether to generate 2D code for tenant (use persisted value from database)
|
// Track whether to generate 2D code for tenant (use persisted value from database)
|
||||||
const [show2dCodeInMonthlyStatement, setShow2dCodeInMonthlyStatement] = useState(
|
const [show2dCodeInMonthlyStatement, setShow2dCodeInMonthlyStatement] = useState(
|
||||||
@@ -146,21 +146,21 @@ const FormFields: FC<FormFieldsProps> = ({ userSettings, errors, message }) => {
|
|||||||
|
|
||||||
<div className="form-control w-full">
|
<div className="form-control w-full">
|
||||||
<label className="label">
|
<label className="label">
|
||||||
<span className="label-text">{t("iban-label")}</span>
|
<span className="label-text">{t("owner-iban-label")}</span>
|
||||||
</label>
|
</label>
|
||||||
<input
|
<input
|
||||||
id="iban"
|
id="ownerIBAN"
|
||||||
name="iban"
|
name="ownerIBAN"
|
||||||
type="text"
|
type="text"
|
||||||
placeholder={t("iban-placeholder")}
|
placeholder={t("owner-iban-placeholder")}
|
||||||
className="input input-bordered w-full placeholder:text-gray-600"
|
className="input input-bordered w-full placeholder:text-gray-600"
|
||||||
defaultValue={formatIban(userSettings?.iban)}
|
defaultValue={formatIban(userSettings?.ownerIBAN)}
|
||||||
onChange={(e) => handleInputChange("iban", e.target.value)}
|
onChange={(e) => handleInputChange("ownerIBAN", e.target.value)}
|
||||||
disabled={pending}
|
disabled={pending}
|
||||||
/>
|
/>
|
||||||
<div id="iban-error" aria-live="polite" aria-atomic="true">
|
<div id="ownerIBAN-error" aria-live="polite" aria-atomic="true">
|
||||||
{errors?.iban &&
|
{errors?.ownerIBAN &&
|
||||||
errors.iban.map((error: string) => (
|
errors.ownerIBAN.map((error: string) => (
|
||||||
<p className="mt-2 text-sm text-red-500" key={error}>
|
<p className="mt-2 text-sm text-red-500" key={error}>
|
||||||
{error}
|
{error}
|
||||||
</p>
|
</p>
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ export const ViewLocationCard:FC<ViewLocationCardProps> = ({location, userSettin
|
|||||||
Primatelj: userSettings?.ownerName ?? "",
|
Primatelj: userSettings?.ownerName ?? "",
|
||||||
AdresaPrimatelja: userSettings?.ownerStreet ?? "",
|
AdresaPrimatelja: userSettings?.ownerStreet ?? "",
|
||||||
SjedistePrimatelja: userSettings?.ownerTown ?? "",
|
SjedistePrimatelja: userSettings?.ownerTown ?? "",
|
||||||
IBAN: userSettings?.iban ?? "",
|
IBAN: userSettings?.ownerIBAN ?? "",
|
||||||
ModelPlacanja: "HR00",
|
ModelPlacanja: "HR00",
|
||||||
PozivNaBroj: `${yearMonth.year}-${yearMonth.month.toString().padStart(2,"0")}`,
|
PozivNaBroj: `${yearMonth.year}-${yearMonth.month.toString().padStart(2,"0")}`,
|
||||||
SifraNamjene: "",
|
SifraNamjene: "",
|
||||||
|
|||||||
@@ -195,8 +195,8 @@
|
|||||||
"owner-street-placeholder": "enter your street and house number",
|
"owner-street-placeholder": "enter your street and house number",
|
||||||
"owner-town-label": "Your Postal Code and Town",
|
"owner-town-label": "Your Postal Code and Town",
|
||||||
"owner-town-placeholder": "enter your postal code and town",
|
"owner-town-placeholder": "enter your postal code and town",
|
||||||
"iban-label": "IBAN",
|
"owner-iban-label": "IBAN",
|
||||||
"iban-placeholder": "enter your IBAN",
|
"owner-iban-placeholder": "enter your IBAN",
|
||||||
"currency-label": "Currency",
|
"currency-label": "Currency",
|
||||||
"save-button": "Save",
|
"save-button": "Save",
|
||||||
"cancel-button": "Cancel",
|
"cancel-button": "Cancel",
|
||||||
@@ -204,8 +204,8 @@
|
|||||||
"owner-name-required": "Name is mandatory",
|
"owner-name-required": "Name is mandatory",
|
||||||
"owner-street-required": "Street is mandatory",
|
"owner-street-required": "Street is mandatory",
|
||||||
"owner-town-required": "Town is mandatory",
|
"owner-town-required": "Town is mandatory",
|
||||||
"iban-required": "Valid IBAN is mandatory",
|
"owner-iban-required": "Valid IBAN is mandatory",
|
||||||
"iban-invalid": "Invalid IBAN format. Please enter a valid IBAN",
|
"owner-iban-invalid": "Invalid IBAN format. Please enter a valid IBAN",
|
||||||
"currency-required": "Currency is mandatory",
|
"currency-required": "Currency is mandatory",
|
||||||
"validation-failed": "Validation failed. Please check the form and try again."
|
"validation-failed": "Validation failed. Please check the form and try again."
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -194,8 +194,8 @@
|
|||||||
"owner-street-placeholder": "unesite ulicu i kućni broj",
|
"owner-street-placeholder": "unesite ulicu i kućni broj",
|
||||||
"owner-town-label": "Poštanski broj i Grad",
|
"owner-town-label": "Poštanski broj i Grad",
|
||||||
"owner-town-placeholder": "unesite poštanski broj i grad",
|
"owner-town-placeholder": "unesite poštanski broj i grad",
|
||||||
"iban-label": "IBAN",
|
"owner-iban-label": "IBAN",
|
||||||
"iban-placeholder": "unesite svoj IBAN",
|
"owner-iban-placeholder": "unesite svoj IBAN",
|
||||||
"currency-label": "Valuta",
|
"currency-label": "Valuta",
|
||||||
"save-button": "Spremi",
|
"save-button": "Spremi",
|
||||||
"cancel-button": "Odbaci",
|
"cancel-button": "Odbaci",
|
||||||
@@ -203,8 +203,8 @@
|
|||||||
"owner-name-required": "Ime i prezime je obavezno",
|
"owner-name-required": "Ime i prezime je obavezno",
|
||||||
"owner-street-required": "Ulica je obavezna",
|
"owner-street-required": "Ulica je obavezna",
|
||||||
"owner-town-required": "Grad je obavezan",
|
"owner-town-required": "Grad je obavezan",
|
||||||
"iban-required": "Ispravan IBAN je obavezan",
|
"owner-iban-required": "Ispravan IBAN je obavezan",
|
||||||
"iban-invalid": "Neispravan IBAN format. Molimo unesite ispravan IBAN.",
|
"owner-iban-invalid": "Neispravan IBAN format. Molimo unesite ispravan IBAN.",
|
||||||
"currency-required": "Valuta je obavezna",
|
"currency-required": "Valuta je obavezna",
|
||||||
"validation-failed": "Validacija nije uspjela. Molimo provjerite formu i pokušajte ponovno."
|
"validation-failed": "Validacija nije uspjela. Molimo provjerite formu i pokušajte ponovno."
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user