Rename 'town' to 'ownerTown' in UserSettings with 27 character max length
Changes:
- Updated UserSettings interface: town -> ownerTown
- Updated userSettingsActions.ts:
- Changed State type to use ownerTown
- Added max length validation (27 characters) to FormSchema
- Updated validation refinement to check ownerTown
- Updated form data parsing to read ownerTown
- Updated database write operations to use ownerTown
- Updated UserSettingsForm.tsx:
- Changed state tracking to use ownerTown
- Updated validation check to reference ownerTown
- Updated input field: id, name, maxLength={27}
- Updated ViewLocationCard.tsx to use ownerTown instead of town
- Updated English translations:
- town-label -> owner-town-label: "Your Postal Code and Town"
- town-placeholder -> owner-town-placeholder
- town-required -> owner-town-required
- Updated Croatian translations with corresponding ownerTown keys
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -16,7 +16,7 @@ export type State = {
|
||||
errors?: {
|
||||
ownerName?: string[];
|
||||
ownerStreet?: string[];
|
||||
town?: string[];
|
||||
ownerTown?: string[];
|
||||
iban?: string[];
|
||||
currency?: string[];
|
||||
show2dCodeInMonthlyStatement?: string[];
|
||||
@@ -31,7 +31,7 @@ export type State = {
|
||||
const FormSchema = (t: IntlTemplateFn) => z.object({
|
||||
ownerName: z.string().max(25).optional(),
|
||||
ownerStreet: z.string().max(25).optional(),
|
||||
town: z.string().optional(),
|
||||
ownerTown: z.string().max(27).optional(),
|
||||
iban: z.string()
|
||||
.optional()
|
||||
.refine(
|
||||
@@ -66,12 +66,12 @@ const FormSchema = (t: IntlTemplateFn) => z.object({
|
||||
})
|
||||
.refine((data) => {
|
||||
if (data.show2dCodeInMonthlyStatement) {
|
||||
return !!data.town && data.town.trim().length > 0;
|
||||
return !!data.ownerTown && data.ownerTown.trim().length > 0;
|
||||
}
|
||||
return true;
|
||||
}, {
|
||||
message: t("town-required"),
|
||||
path: ["town"],
|
||||
message: t("owner-town-required"),
|
||||
path: ["ownerTown"],
|
||||
})
|
||||
.refine((data) => {
|
||||
if (data.show2dCodeInMonthlyStatement) {
|
||||
@@ -138,7 +138,7 @@ export const updateUserSettings = withUser(async (user: AuthenticatedUser, prevS
|
||||
const validatedFields = FormSchema(t).safeParse({
|
||||
ownerName: formData.get('ownerName') || undefined,
|
||||
ownerStreet: formData.get('ownerStreet') || undefined,
|
||||
town: formData.get('town') || undefined,
|
||||
ownerTown: formData.get('ownerTown') || undefined,
|
||||
iban: formData.get('iban') || undefined,
|
||||
currency: formData.get('currency') || undefined,
|
||||
show2dCodeInMonthlyStatement: formData.get('generateTenantCode') === 'on',
|
||||
@@ -153,7 +153,7 @@ export const updateUserSettings = withUser(async (user: AuthenticatedUser, prevS
|
||||
};
|
||||
}
|
||||
|
||||
const { ownerName, ownerStreet, town, iban, currency, show2dCodeInMonthlyStatement } = validatedFields.data;
|
||||
const { ownerName, ownerStreet, ownerTown, iban, currency, show2dCodeInMonthlyStatement } = validatedFields.data;
|
||||
|
||||
// Normalize IBAN: remove spaces and convert to uppercase
|
||||
const normalizedIban = iban ? iban.replace(/\s/g, '').toUpperCase() : null;
|
||||
@@ -166,7 +166,7 @@ export const updateUserSettings = withUser(async (user: AuthenticatedUser, prevS
|
||||
userId,
|
||||
ownerName: ownerName || null,
|
||||
ownerStreet: ownerStreet || null,
|
||||
town: town || null,
|
||||
ownerTown: ownerTown || null,
|
||||
iban: normalizedIban,
|
||||
currency: currency || null,
|
||||
show2dCodeInMonthlyStatement: show2dCodeInMonthlyStatement ?? false,
|
||||
|
||||
Reference in New Issue
Block a user