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:
Knee Cola
2025-11-22 22:43:30 +01:00
parent e6adb10689
commit 4db56f8383
6 changed files with 34 additions and 34 deletions

View File

@@ -17,7 +17,7 @@ export type State = {
ownerName?: string[];
ownerStreet?: string[];
ownerTown?: string[];
iban?: string[];
ownerIBAN?: string[];
currency?: string[];
show2dCodeInMonthlyStatement?: string[];
};
@@ -32,7 +32,7 @@ const FormSchema = (t: IntlTemplateFn) => z.object({
ownerName: z.string().max(25).optional(),
ownerStreet: z.string().max(25).optional(),
ownerTown: z.string().max(27).optional(),
iban: z.string()
ownerIBAN: z.string()
.optional()
.refine(
(val) => {
@@ -41,7 +41,7 @@ const FormSchema = (t: IntlTemplateFn) => z.object({
const cleaned = val.replace(/\s/g, '').toUpperCase();
return IBAN.isValid(cleaned);
},
{ message: t("iban-invalid") }
{ message: t("owner-iban-invalid") }
),
currency: z.string().optional(),
show2dCodeInMonthlyStatement: z.boolean().optional().nullable(),
@@ -75,17 +75,17 @@ const FormSchema = (t: IntlTemplateFn) => z.object({
})
.refine((data) => {
if (data.show2dCodeInMonthlyStatement) {
if (!data.iban || data.iban.trim().length === 0) {
if (!data.ownerIBAN || data.ownerIBAN.trim().length === 0) {
return false;
}
// 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 true;
}, {
message: t("iban-required"),
path: ["iban"],
message: t("owner-iban-required"),
path: ["ownerIBAN"],
})
.refine((data) => {
if (data.show2dCodeInMonthlyStatement) {
@@ -139,7 +139,7 @@ export const updateUserSettings = withUser(async (user: AuthenticatedUser, prevS
ownerName: formData.get('ownerName') || undefined,
ownerStreet: formData.get('ownerStreet') || undefined,
ownerTown: formData.get('ownerTown') || undefined,
iban: formData.get('iban') || undefined,
ownerIBAN: formData.get('ownerIBAN') || undefined,
currency: formData.get('currency') || undefined,
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
const normalizedIban = iban ? iban.replace(/\s/g, '').toUpperCase() : null;
const normalizedOwnerIBAN = ownerIBAN ? ownerIBAN.replace(/\s/g, '').toUpperCase() : null;
// Update the user settings in MongoDB
const dbClient = await getDbClient();
@@ -167,7 +167,7 @@ export const updateUserSettings = withUser(async (user: AuthenticatedUser, prevS
ownerName: ownerName || null,
ownerStreet: ownerStreet || null,
ownerTown: ownerTown || null,
iban: normalizedIban,
ownerIBAN: normalizedOwnerIBAN,
currency: currency || null,
show2dCodeInMonthlyStatement: show2dCodeInMonthlyStatement ?? false,
};

View File

@@ -24,8 +24,8 @@ export interface UserSettings {
ownerStreet?: string | null;
/** owner town */
ownerTown?: string | null;
/** IBAN */
iban?: string | null;
/** owner IBAN */
ownerIBAN?: string | null;
/** currency (ISO 4217) */
currency?: string | null;
/** whether to show 2D code in monthly statement */