From c1762f7157cae97f428ab498305da04ddf391fa8 Mon Sep 17 00:00:00 2001 From: Knee Cola Date: Sat, 22 Nov 2025 22:26:41 +0100 Subject: [PATCH] Remove lastName field from UserSettings and database MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Removed lastName from UserSettings interface - Updated UserSettingsForm to remove lastName input field - Removed lastName from all database operations - Updated form validation schema to remove lastName validation - Updated ViewLocationCard to use only firstName for recipient name - Removed lastName from user settings form state tracking - Updated Croatian translations to reflect changes 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- app/lib/actions/userSettingsActions.ts | 15 +------------- app/lib/db-types.ts | 2 -- app/ui/UserSettingsForm.tsx | 27 +------------------------- app/ui/ViewLocationCard.tsx | 2 +- messages/hr.json | 24 +++++++++++------------ 5 files changed, 15 insertions(+), 55 deletions(-) diff --git a/app/lib/actions/userSettingsActions.ts b/app/lib/actions/userSettingsActions.ts index 8571712..e721eeb 100644 --- a/app/lib/actions/userSettingsActions.ts +++ b/app/lib/actions/userSettingsActions.ts @@ -15,7 +15,6 @@ import * as IBAN from 'iban'; export type State = { errors?: { firstName?: string[]; - lastName?: string[]; street?: string[]; town?: string[]; iban?: string[]; @@ -31,7 +30,6 @@ export type State = { */ const FormSchema = (t: IntlTemplateFn) => z.object({ firstName: z.string().optional(), - lastName: z.string().optional(), street: z.string().optional(), town: z.string().optional(), iban: z.string() @@ -57,15 +55,6 @@ const FormSchema = (t: IntlTemplateFn) => z.object({ message: t("first-name-required"), path: ["firstName"], }) -.refine((data) => { - if (data.show2dCodeInMonthlyStatement) { - return !!data.lastName && data.lastName.trim().length > 0; - } - return true; -}, { - message: t("last-name-required"), - path: ["lastName"], -}) .refine((data) => { if (data.show2dCodeInMonthlyStatement) { return !!data.street && data.street.trim().length > 0; @@ -148,7 +137,6 @@ export const updateUserSettings = withUser(async (user: AuthenticatedUser, prevS const validatedFields = FormSchema(t).safeParse({ firstName: formData.get('firstName') || undefined, - lastName: formData.get('lastName') || undefined, street: formData.get('street') || undefined, town: formData.get('town') || undefined, iban: formData.get('iban') || undefined, @@ -165,7 +153,7 @@ export const updateUserSettings = withUser(async (user: AuthenticatedUser, prevS }; } - const { firstName, lastName, street, town, iban, currency, show2dCodeInMonthlyStatement } = validatedFields.data; + const { firstName, street, town, iban, currency, show2dCodeInMonthlyStatement } = validatedFields.data; // Normalize IBAN: remove spaces and convert to uppercase const normalizedIban = iban ? iban.replace(/\s/g, '').toUpperCase() : null; @@ -177,7 +165,6 @@ export const updateUserSettings = withUser(async (user: AuthenticatedUser, prevS const userSettings: UserSettings = { userId, firstName: firstName || null, - lastName: lastName || null, street: street || null, town: town || null, iban: normalizedIban, diff --git a/app/lib/db-types.ts b/app/lib/db-types.ts index 4e081e1..b023176 100644 --- a/app/lib/db-types.ts +++ b/app/lib/db-types.ts @@ -20,8 +20,6 @@ export interface UserSettings { userId: string; /** first name */ firstName?: string | null; - /** last name */ - lastName?: string | null; /** street */ street?: string | null; /** town */ diff --git a/app/ui/UserSettingsForm.tsx b/app/ui/UserSettingsForm.tsx index 0f6953d..cba8a84 100644 --- a/app/ui/UserSettingsForm.tsx +++ b/app/ui/UserSettingsForm.tsx @@ -28,7 +28,6 @@ const FormFields: FC = ({ userSettings, errors, message }) => { // Track current form values for real-time validation const [formValues, setFormValues] = useState({ firstName: userSettings?.firstName ?? "", - lastName: userSettings?.lastName ?? "", street: userSettings?.street ?? "", town: userSettings?.town ?? "", iban: formatIban(userSettings?.iban) ?? "", @@ -41,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.firstName || !formValues.lastName || !formValues.street || !formValues.town || !cleanedIban || !formValues.currency; + const hasMissingData = !formValues.firstName || !formValues.street || !formValues.town || !cleanedIban || !formValues.currency; // Track whether to generate 2D code for tenant (use persisted value from database) const [show2dCodeInMonthlyStatement, setShow2dCodeInMonthlyStatement] = useState( @@ -94,30 +93,6 @@ const FormFields: FC = ({ userSettings, errors, message }) => { -
- - handleInputChange("lastName", e.target.value)} - disabled={pending} - /> -
- {errors?.lastName && - errors.lastName.map((error: string) => ( -

- {error} -

- ))} -
-
-