Rename firstName to ownerName with updated validation
- Renamed firstName to ownerName in UserSettings interface - Updated UserSettingsForm field to accept full name (first and last) - Set maximum length to 25 characters for owner name field - Updated all database operations to use ownerName - Changed English label from "First Name" to "Your First and Last Name" - Updated Croatian translations to match (Vaše ime i prezime) - Updated form validation schema and error messages - Removed old lastName-related translations - Updated ViewLocationCard to use ownerName for recipient 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -14,7 +14,7 @@ import * as IBAN from 'iban';
|
||||
|
||||
export type State = {
|
||||
errors?: {
|
||||
firstName?: string[];
|
||||
ownerName?: string[];
|
||||
street?: string[];
|
||||
town?: string[];
|
||||
iban?: string[];
|
||||
@@ -29,7 +29,7 @@ export type State = {
|
||||
* Schema for validating user settings form fields
|
||||
*/
|
||||
const FormSchema = (t: IntlTemplateFn) => z.object({
|
||||
firstName: z.string().optional(),
|
||||
ownerName: z.string().max(25).optional(),
|
||||
street: z.string().optional(),
|
||||
town: z.string().optional(),
|
||||
iban: z.string()
|
||||
@@ -48,12 +48,12 @@ const FormSchema = (t: IntlTemplateFn) => z.object({
|
||||
})
|
||||
.refine((data) => {
|
||||
if (data.show2dCodeInMonthlyStatement) {
|
||||
return !!data.firstName && data.firstName.trim().length > 0;
|
||||
return !!data.ownerName && data.ownerName.trim().length > 0;
|
||||
}
|
||||
return true;
|
||||
}, {
|
||||
message: t("first-name-required"),
|
||||
path: ["firstName"],
|
||||
message: t("owner-name-required"),
|
||||
path: ["ownerName"],
|
||||
})
|
||||
.refine((data) => {
|
||||
if (data.show2dCodeInMonthlyStatement) {
|
||||
@@ -136,7 +136,7 @@ export const updateUserSettings = withUser(async (user: AuthenticatedUser, prevS
|
||||
const t = await getTranslations("user-settings-form.validation");
|
||||
|
||||
const validatedFields = FormSchema(t).safeParse({
|
||||
firstName: formData.get('firstName') || undefined,
|
||||
ownerName: formData.get('ownerName') || undefined,
|
||||
street: formData.get('street') || undefined,
|
||||
town: formData.get('town') || undefined,
|
||||
iban: formData.get('iban') || undefined,
|
||||
@@ -153,7 +153,7 @@ export const updateUserSettings = withUser(async (user: AuthenticatedUser, prevS
|
||||
};
|
||||
}
|
||||
|
||||
const { firstName, street, town, iban, currency, show2dCodeInMonthlyStatement } = validatedFields.data;
|
||||
const { ownerName, street, town, iban, currency, show2dCodeInMonthlyStatement } = validatedFields.data;
|
||||
|
||||
// Normalize IBAN: remove spaces and convert to uppercase
|
||||
const normalizedIban = iban ? iban.replace(/\s/g, '').toUpperCase() : null;
|
||||
@@ -164,7 +164,7 @@ export const updateUserSettings = withUser(async (user: AuthenticatedUser, prevS
|
||||
|
||||
const userSettings: UserSettings = {
|
||||
userId,
|
||||
firstName: firstName || null,
|
||||
ownerName: ownerName || null,
|
||||
street: street || null,
|
||||
town: town || null,
|
||||
iban: normalizedIban,
|
||||
|
||||
@@ -18,8 +18,8 @@ export interface YearMonth {
|
||||
export interface UserSettings {
|
||||
/** user's ID */
|
||||
userId: string;
|
||||
/** first name */
|
||||
firstName?: string | null;
|
||||
/** owner name */
|
||||
ownerName?: string | null;
|
||||
/** street */
|
||||
street?: string | null;
|
||||
/** town */
|
||||
|
||||
Reference in New Issue
Block a user