From e6adb10689813241d3e73809015668375ed95466 Mon Sep 17 00:00:00 2001 From: Knee Cola Date: Sat, 22 Nov 2025 22:40:12 +0100 Subject: [PATCH] Rename 'town' to 'ownerTown' in UserSettings with 27 character max length MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- app/lib/actions/userSettingsActions.ts | 16 ++++++++-------- app/lib/db-types.ts | 4 ++-- app/ui/UserSettingsForm.tsx | 23 ++++++++++++----------- app/ui/ViewLocationCard.tsx | 2 +- messages/en.json | 6 +++--- messages/hr.json | 6 +++--- 6 files changed, 29 insertions(+), 28 deletions(-) diff --git a/app/lib/actions/userSettingsActions.ts b/app/lib/actions/userSettingsActions.ts index 43a14a9..08798b0 100644 --- a/app/lib/actions/userSettingsActions.ts +++ b/app/lib/actions/userSettingsActions.ts @@ -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, diff --git a/app/lib/db-types.ts b/app/lib/db-types.ts index 48851f5..b78d0bf 100644 --- a/app/lib/db-types.ts +++ b/app/lib/db-types.ts @@ -22,8 +22,8 @@ export interface UserSettings { ownerName?: string | null; /** owner street */ ownerStreet?: string | null; - /** town */ - town?: string | null; + /** owner town */ + ownerTown?: string | null; /** IBAN */ iban?: string | null; /** currency (ISO 4217) */ diff --git a/app/ui/UserSettingsForm.tsx b/app/ui/UserSettingsForm.tsx index 9fc9ab0..c611d12 100644 --- a/app/ui/UserSettingsForm.tsx +++ b/app/ui/UserSettingsForm.tsx @@ -29,7 +29,7 @@ const FormFields: FC = ({ userSettings, errors, message }) => { const [formValues, setFormValues] = useState({ ownerName: userSettings?.ownerName ?? "", ownerStreet: userSettings?.ownerStreet ?? "", - town: userSettings?.town ?? "", + ownerTown: userSettings?.ownerTown ?? "", iban: formatIban(userSettings?.iban) ?? "", currency: userSettings?.currency ?? "EUR", }); @@ -40,7 +40,7 @@ const FormFields: FC = ({ userSettings, errors, message }) => { // Check if any required field is missing (clean IBAN of spaces for validation) const cleanedIban = formValues.iban.replace(/\s/g, ''); - const hasMissingData = !formValues.ownerName || !formValues.ownerStreet || !formValues.town || !cleanedIban || !formValues.currency; + const hasMissingData = !formValues.ownerName || !formValues.ownerStreet || !formValues.ownerTown || !cleanedIban || !formValues.currency; // Track whether to generate 2D code for tenant (use persisted value from database) const [show2dCodeInMonthlyStatement, setShow2dCodeInMonthlyStatement] = useState( @@ -121,21 +121,22 @@ const FormFields: FC = ({ userSettings, errors, message }) => {
handleInputChange("town", e.target.value)} + defaultValue={userSettings?.ownerTown ?? ""} + onChange={(e) => handleInputChange("ownerTown", e.target.value)} disabled={pending} /> -
- {errors?.town && - errors.town.map((error: string) => ( +
+ {errors?.ownerTown && + errors.ownerTown.map((error: string) => (

{error}

diff --git a/app/ui/ViewLocationCard.tsx b/app/ui/ViewLocationCard.tsx index f15883c..eedc4a2 100644 --- a/app/ui/ViewLocationCard.tsx +++ b/app/ui/ViewLocationCard.tsx @@ -30,7 +30,7 @@ export const ViewLocationCard:FC = ({location, userSettin SjedistePlatitelja: tenantTown ?? "", Primatelj: userSettings?.ownerName ?? "", AdresaPrimatelja: userSettings?.ownerStreet ?? "", - SjedistePrimatelja: userSettings?.town ?? "", + SjedistePrimatelja: userSettings?.ownerTown ?? "", IBAN: userSettings?.iban ?? "", ModelPlacanja: "HR00", PozivNaBroj: `${yearMonth.year}-${yearMonth.month.toString().padStart(2,"0")}`, diff --git a/messages/en.json b/messages/en.json index 222d4ed..efdd5e8 100644 --- a/messages/en.json +++ b/messages/en.json @@ -193,8 +193,8 @@ "owner-name-placeholder": "enter your first and last name", "owner-street-label": "Your Street and House Number", "owner-street-placeholder": "enter your street and house number", - "town-label": "Town", - "town-placeholder": "enter your town", + "owner-town-label": "Your Postal Code and Town", + "owner-town-placeholder": "enter your postal code and town", "iban-label": "IBAN", "iban-placeholder": "enter your IBAN", "currency-label": "Currency", @@ -203,7 +203,7 @@ "validation": { "owner-name-required": "Name is mandatory", "owner-street-required": "Street is mandatory", - "town-required": "Town is mandatory", + "owner-town-required": "Town is mandatory", "iban-required": "Valid IBAN is mandatory", "iban-invalid": "Invalid IBAN format. Please enter a valid IBAN", "currency-required": "Currency is mandatory", diff --git a/messages/hr.json b/messages/hr.json index e140182..0e7fb76 100644 --- a/messages/hr.json +++ b/messages/hr.json @@ -192,8 +192,8 @@ "owner-name-placeholder": "unesite svoje ime i prezime", "owner-street-label": "Ulica i kućni broj", "owner-street-placeholder": "unesite ulicu i kućni broj", - "town-label": "Poštanski broj i Grad", - "town-placeholder": "unesite poštanski broj i grad", + "owner-town-label": "Poštanski broj i Grad", + "owner-town-placeholder": "unesite poštanski broj i grad", "iban-label": "IBAN", "iban-placeholder": "unesite svoj IBAN", "currency-label": "Valuta", @@ -202,7 +202,7 @@ "validation": { "owner-name-required": "Ime i prezime je obavezno", "owner-street-required": "Ulica je obavezna", - "town-required": "Grad je obavezan", + "owner-town-required": "Grad je obavezan", "iban-required": "Ispravan IBAN je obavezan", "iban-invalid": "Neispravan IBAN format. Molimo unesite ispravan IBAN.", "currency-required": "Valuta je obavezna",