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?: {
|
errors?: {
|
||||||
ownerName?: string[];
|
ownerName?: string[];
|
||||||
ownerStreet?: string[];
|
ownerStreet?: string[];
|
||||||
town?: string[];
|
ownerTown?: string[];
|
||||||
iban?: string[];
|
iban?: string[];
|
||||||
currency?: string[];
|
currency?: string[];
|
||||||
show2dCodeInMonthlyStatement?: string[];
|
show2dCodeInMonthlyStatement?: string[];
|
||||||
@@ -31,7 +31,7 @@ export type State = {
|
|||||||
const FormSchema = (t: IntlTemplateFn) => z.object({
|
const FormSchema = (t: IntlTemplateFn) => z.object({
|
||||||
ownerName: z.string().max(25).optional(),
|
ownerName: z.string().max(25).optional(),
|
||||||
ownerStreet: z.string().max(25).optional(),
|
ownerStreet: z.string().max(25).optional(),
|
||||||
town: z.string().optional(),
|
ownerTown: z.string().max(27).optional(),
|
||||||
iban: z.string()
|
iban: z.string()
|
||||||
.optional()
|
.optional()
|
||||||
.refine(
|
.refine(
|
||||||
@@ -66,12 +66,12 @@ const FormSchema = (t: IntlTemplateFn) => z.object({
|
|||||||
})
|
})
|
||||||
.refine((data) => {
|
.refine((data) => {
|
||||||
if (data.show2dCodeInMonthlyStatement) {
|
if (data.show2dCodeInMonthlyStatement) {
|
||||||
return !!data.town && data.town.trim().length > 0;
|
return !!data.ownerTown && data.ownerTown.trim().length > 0;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}, {
|
}, {
|
||||||
message: t("town-required"),
|
message: t("owner-town-required"),
|
||||||
path: ["town"],
|
path: ["ownerTown"],
|
||||||
})
|
})
|
||||||
.refine((data) => {
|
.refine((data) => {
|
||||||
if (data.show2dCodeInMonthlyStatement) {
|
if (data.show2dCodeInMonthlyStatement) {
|
||||||
@@ -138,7 +138,7 @@ export const updateUserSettings = withUser(async (user: AuthenticatedUser, prevS
|
|||||||
const validatedFields = FormSchema(t).safeParse({
|
const validatedFields = FormSchema(t).safeParse({
|
||||||
ownerName: formData.get('ownerName') || undefined,
|
ownerName: formData.get('ownerName') || undefined,
|
||||||
ownerStreet: formData.get('ownerStreet') || undefined,
|
ownerStreet: formData.get('ownerStreet') || undefined,
|
||||||
town: formData.get('town') || undefined,
|
ownerTown: formData.get('ownerTown') || undefined,
|
||||||
iban: formData.get('iban') || undefined,
|
iban: formData.get('iban') || undefined,
|
||||||
currency: formData.get('currency') || undefined,
|
currency: formData.get('currency') || undefined,
|
||||||
show2dCodeInMonthlyStatement: formData.get('generateTenantCode') === 'on',
|
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
|
// Normalize IBAN: remove spaces and convert to uppercase
|
||||||
const normalizedIban = iban ? iban.replace(/\s/g, '').toUpperCase() : null;
|
const normalizedIban = iban ? iban.replace(/\s/g, '').toUpperCase() : null;
|
||||||
@@ -166,7 +166,7 @@ export const updateUserSettings = withUser(async (user: AuthenticatedUser, prevS
|
|||||||
userId,
|
userId,
|
||||||
ownerName: ownerName || null,
|
ownerName: ownerName || null,
|
||||||
ownerStreet: ownerStreet || null,
|
ownerStreet: ownerStreet || null,
|
||||||
town: town || null,
|
ownerTown: ownerTown || null,
|
||||||
iban: normalizedIban,
|
iban: normalizedIban,
|
||||||
currency: currency || null,
|
currency: currency || null,
|
||||||
show2dCodeInMonthlyStatement: show2dCodeInMonthlyStatement ?? false,
|
show2dCodeInMonthlyStatement: show2dCodeInMonthlyStatement ?? false,
|
||||||
|
|||||||
@@ -22,8 +22,8 @@ export interface UserSettings {
|
|||||||
ownerName?: string | null;
|
ownerName?: string | null;
|
||||||
/** owner street */
|
/** owner street */
|
||||||
ownerStreet?: string | null;
|
ownerStreet?: string | null;
|
||||||
/** town */
|
/** owner town */
|
||||||
town?: string | null;
|
ownerTown?: string | null;
|
||||||
/** IBAN */
|
/** IBAN */
|
||||||
iban?: string | null;
|
iban?: string | null;
|
||||||
/** currency (ISO 4217) */
|
/** currency (ISO 4217) */
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ const FormFields: FC<FormFieldsProps> = ({ userSettings, errors, message }) => {
|
|||||||
const [formValues, setFormValues] = useState({
|
const [formValues, setFormValues] = useState({
|
||||||
ownerName: userSettings?.ownerName ?? "",
|
ownerName: userSettings?.ownerName ?? "",
|
||||||
ownerStreet: userSettings?.ownerStreet ?? "",
|
ownerStreet: userSettings?.ownerStreet ?? "",
|
||||||
town: userSettings?.town ?? "",
|
ownerTown: userSettings?.ownerTown ?? "",
|
||||||
iban: formatIban(userSettings?.iban) ?? "",
|
iban: formatIban(userSettings?.iban) ?? "",
|
||||||
currency: userSettings?.currency ?? "EUR",
|
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)
|
// Check if any required field is missing (clean IBAN of spaces for validation)
|
||||||
const cleanedIban = formValues.iban.replace(/\s/g, '');
|
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)
|
// Track whether to generate 2D code for tenant (use persisted value from database)
|
||||||
const [show2dCodeInMonthlyStatement, setShow2dCodeInMonthlyStatement] = useState(
|
const [show2dCodeInMonthlyStatement, setShow2dCodeInMonthlyStatement] = useState(
|
||||||
@@ -121,21 +121,22 @@ const FormFields: FC<FormFieldsProps> = ({ userSettings, errors, message }) => {
|
|||||||
|
|
||||||
<div className="form-control w-full">
|
<div className="form-control w-full">
|
||||||
<label className="label">
|
<label className="label">
|
||||||
<span className="label-text">{t("town-label")}</span>
|
<span className="label-text">{t("owner-town-label")}</span>
|
||||||
</label>
|
</label>
|
||||||
<input
|
<input
|
||||||
id="town"
|
id="ownerTown"
|
||||||
name="town"
|
name="ownerTown"
|
||||||
type="text"
|
type="text"
|
||||||
placeholder={t("town-placeholder")}
|
maxLength={27}
|
||||||
|
placeholder={t("owner-town-placeholder")}
|
||||||
className="input input-bordered w-full placeholder:text-gray-600"
|
className="input input-bordered w-full placeholder:text-gray-600"
|
||||||
defaultValue={userSettings?.town ?? ""}
|
defaultValue={userSettings?.ownerTown ?? ""}
|
||||||
onChange={(e) => handleInputChange("town", e.target.value)}
|
onChange={(e) => handleInputChange("ownerTown", e.target.value)}
|
||||||
disabled={pending}
|
disabled={pending}
|
||||||
/>
|
/>
|
||||||
<div id="town-error" aria-live="polite" aria-atomic="true">
|
<div id="ownerTown-error" aria-live="polite" aria-atomic="true">
|
||||||
{errors?.town &&
|
{errors?.ownerTown &&
|
||||||
errors.town.map((error: string) => (
|
errors.ownerTown.map((error: string) => (
|
||||||
<p className="mt-2 text-sm text-red-500" key={error}>
|
<p className="mt-2 text-sm text-red-500" key={error}>
|
||||||
{error}
|
{error}
|
||||||
</p>
|
</p>
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ export const ViewLocationCard:FC<ViewLocationCardProps> = ({location, userSettin
|
|||||||
SjedistePlatitelja: tenantTown ?? "",
|
SjedistePlatitelja: tenantTown ?? "",
|
||||||
Primatelj: userSettings?.ownerName ?? "",
|
Primatelj: userSettings?.ownerName ?? "",
|
||||||
AdresaPrimatelja: userSettings?.ownerStreet ?? "",
|
AdresaPrimatelja: userSettings?.ownerStreet ?? "",
|
||||||
SjedistePrimatelja: userSettings?.town ?? "",
|
SjedistePrimatelja: userSettings?.ownerTown ?? "",
|
||||||
IBAN: userSettings?.iban ?? "",
|
IBAN: userSettings?.iban ?? "",
|
||||||
ModelPlacanja: "HR00",
|
ModelPlacanja: "HR00",
|
||||||
PozivNaBroj: `${yearMonth.year}-${yearMonth.month.toString().padStart(2,"0")}`,
|
PozivNaBroj: `${yearMonth.year}-${yearMonth.month.toString().padStart(2,"0")}`,
|
||||||
|
|||||||
@@ -193,8 +193,8 @@
|
|||||||
"owner-name-placeholder": "enter your first and last name",
|
"owner-name-placeholder": "enter your first and last name",
|
||||||
"owner-street-label": "Your Street and House Number",
|
"owner-street-label": "Your Street and House Number",
|
||||||
"owner-street-placeholder": "enter your street and house number",
|
"owner-street-placeholder": "enter your street and house number",
|
||||||
"town-label": "Town",
|
"owner-town-label": "Your Postal Code and Town",
|
||||||
"town-placeholder": "enter your town",
|
"owner-town-placeholder": "enter your postal code and town",
|
||||||
"iban-label": "IBAN",
|
"iban-label": "IBAN",
|
||||||
"iban-placeholder": "enter your IBAN",
|
"iban-placeholder": "enter your IBAN",
|
||||||
"currency-label": "Currency",
|
"currency-label": "Currency",
|
||||||
@@ -203,7 +203,7 @@
|
|||||||
"validation": {
|
"validation": {
|
||||||
"owner-name-required": "Name is mandatory",
|
"owner-name-required": "Name is mandatory",
|
||||||
"owner-street-required": "Street 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-required": "Valid IBAN is mandatory",
|
||||||
"iban-invalid": "Invalid IBAN format. Please enter a valid IBAN",
|
"iban-invalid": "Invalid IBAN format. Please enter a valid IBAN",
|
||||||
"currency-required": "Currency is mandatory",
|
"currency-required": "Currency is mandatory",
|
||||||
|
|||||||
@@ -192,8 +192,8 @@
|
|||||||
"owner-name-placeholder": "unesite svoje ime i prezime",
|
"owner-name-placeholder": "unesite svoje ime i prezime",
|
||||||
"owner-street-label": "Ulica i kućni broj",
|
"owner-street-label": "Ulica i kućni broj",
|
||||||
"owner-street-placeholder": "unesite ulicu i kućni broj",
|
"owner-street-placeholder": "unesite ulicu i kućni broj",
|
||||||
"town-label": "Poštanski broj i Grad",
|
"owner-town-label": "Poštanski broj i Grad",
|
||||||
"town-placeholder": "unesite poštanski broj i grad",
|
"owner-town-placeholder": "unesite poštanski broj i grad",
|
||||||
"iban-label": "IBAN",
|
"iban-label": "IBAN",
|
||||||
"iban-placeholder": "unesite svoj IBAN",
|
"iban-placeholder": "unesite svoj IBAN",
|
||||||
"currency-label": "Valuta",
|
"currency-label": "Valuta",
|
||||||
@@ -202,7 +202,7 @@
|
|||||||
"validation": {
|
"validation": {
|
||||||
"owner-name-required": "Ime i prezime je obavezno",
|
"owner-name-required": "Ime i prezime je obavezno",
|
||||||
"owner-street-required": "Ulica je obavezna",
|
"owner-street-required": "Ulica je obavezna",
|
||||||
"town-required": "Grad je obavezan",
|
"owner-town-required": "Grad je obavezan",
|
||||||
"iban-required": "Ispravan IBAN je obavezan",
|
"iban-required": "Ispravan IBAN je obavezan",
|
||||||
"iban-invalid": "Neispravan IBAN format. Molimo unesite ispravan IBAN.",
|
"iban-invalid": "Neispravan IBAN format. Molimo unesite ispravan IBAN.",
|
||||||
"currency-required": "Valuta je obavezna",
|
"currency-required": "Valuta je obavezna",
|
||||||
|
|||||||
Reference in New Issue
Block a user