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,
|
||||
|
||||
@@ -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) */
|
||||
|
||||
@@ -29,7 +29,7 @@ const FormFields: FC<FormFieldsProps> = ({ 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<FormFieldsProps> = ({ 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<FormFieldsProps> = ({ userSettings, errors, message }) => {
|
||||
|
||||
<div className="form-control w-full">
|
||||
<label className="label">
|
||||
<span className="label-text">{t("town-label")}</span>
|
||||
<span className="label-text">{t("owner-town-label")}</span>
|
||||
</label>
|
||||
<input
|
||||
id="town"
|
||||
name="town"
|
||||
id="ownerTown"
|
||||
name="ownerTown"
|
||||
type="text"
|
||||
placeholder={t("town-placeholder")}
|
||||
maxLength={27}
|
||||
placeholder={t("owner-town-placeholder")}
|
||||
className="input input-bordered w-full placeholder:text-gray-600"
|
||||
defaultValue={userSettings?.town ?? ""}
|
||||
onChange={(e) => handleInputChange("town", e.target.value)}
|
||||
defaultValue={userSettings?.ownerTown ?? ""}
|
||||
onChange={(e) => handleInputChange("ownerTown", e.target.value)}
|
||||
disabled={pending}
|
||||
/>
|
||||
<div id="town-error" aria-live="polite" aria-atomic="true">
|
||||
{errors?.town &&
|
||||
errors.town.map((error: string) => (
|
||||
<div id="ownerTown-error" aria-live="polite" aria-atomic="true">
|
||||
{errors?.ownerTown &&
|
||||
errors.ownerTown.map((error: string) => (
|
||||
<p className="mt-2 text-sm text-red-500" key={error}>
|
||||
{error}
|
||||
</p>
|
||||
|
||||
@@ -30,7 +30,7 @@ export const ViewLocationCard:FC<ViewLocationCardProps> = ({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")}`,
|
||||
|
||||
Reference in New Issue
Block a user