Rename 'street' to 'ownerStreet' in UserSettings with 25 character max length
Changes:
- Updated UserSettings interface: street -> ownerStreet
- Updated userSettingsActions.ts:
- Changed State type to use ownerStreet
- Added max length validation (25 characters) to FormSchema
- Updated validation refinement to check ownerStreet
- Updated form data parsing to read ownerStreet
- Updated database write operations to use ownerStreet
- Updated UserSettingsForm.tsx:
- Changed state tracking to use ownerStreet
- Updated validation check to reference ownerStreet
- Updated input field: id, name, maxLength={25}
- Updated ViewLocationCard.tsx to use ownerStreet instead of street
- Updated English translations:
- street-label -> owner-street-label: "Your Street and House Number"
- street-placeholder -> owner-street-placeholder
- street-required -> owner-street-required
- Updated Croatian translations with corresponding ownerStreet keys
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -15,7 +15,7 @@ import * as IBAN from 'iban';
|
||||
export type State = {
|
||||
errors?: {
|
||||
ownerName?: string[];
|
||||
street?: string[];
|
||||
ownerStreet?: string[];
|
||||
town?: string[];
|
||||
iban?: string[];
|
||||
currency?: string[];
|
||||
@@ -30,7 +30,7 @@ export type State = {
|
||||
*/
|
||||
const FormSchema = (t: IntlTemplateFn) => z.object({
|
||||
ownerName: z.string().max(25).optional(),
|
||||
street: z.string().optional(),
|
||||
ownerStreet: z.string().max(25).optional(),
|
||||
town: z.string().optional(),
|
||||
iban: z.string()
|
||||
.optional()
|
||||
@@ -57,12 +57,12 @@ const FormSchema = (t: IntlTemplateFn) => z.object({
|
||||
})
|
||||
.refine((data) => {
|
||||
if (data.show2dCodeInMonthlyStatement) {
|
||||
return !!data.street && data.street.trim().length > 0;
|
||||
return !!data.ownerStreet && data.ownerStreet.trim().length > 0;
|
||||
}
|
||||
return true;
|
||||
}, {
|
||||
message: t("street-required"),
|
||||
path: ["street"],
|
||||
message: t("owner-street-required"),
|
||||
path: ["ownerStreet"],
|
||||
})
|
||||
.refine((data) => {
|
||||
if (data.show2dCodeInMonthlyStatement) {
|
||||
@@ -137,7 +137,7 @@ export const updateUserSettings = withUser(async (user: AuthenticatedUser, prevS
|
||||
|
||||
const validatedFields = FormSchema(t).safeParse({
|
||||
ownerName: formData.get('ownerName') || undefined,
|
||||
street: formData.get('street') || undefined,
|
||||
ownerStreet: formData.get('ownerStreet') || undefined,
|
||||
town: formData.get('town') || undefined,
|
||||
iban: formData.get('iban') || undefined,
|
||||
currency: formData.get('currency') || undefined,
|
||||
@@ -153,7 +153,7 @@ export const updateUserSettings = withUser(async (user: AuthenticatedUser, prevS
|
||||
};
|
||||
}
|
||||
|
||||
const { ownerName, street, town, iban, currency, show2dCodeInMonthlyStatement } = validatedFields.data;
|
||||
const { ownerName, ownerStreet, town, iban, currency, show2dCodeInMonthlyStatement } = validatedFields.data;
|
||||
|
||||
// Normalize IBAN: remove spaces and convert to uppercase
|
||||
const normalizedIban = iban ? iban.replace(/\s/g, '').toUpperCase() : null;
|
||||
@@ -165,7 +165,7 @@ export const updateUserSettings = withUser(async (user: AuthenticatedUser, prevS
|
||||
const userSettings: UserSettings = {
|
||||
userId,
|
||||
ownerName: ownerName || null,
|
||||
street: street || null,
|
||||
ownerStreet: ownerStreet || null,
|
||||
town: town || null,
|
||||
iban: normalizedIban,
|
||||
currency: currency || null,
|
||||
|
||||
@@ -20,8 +20,8 @@ export interface UserSettings {
|
||||
userId: string;
|
||||
/** owner name */
|
||||
ownerName?: string | null;
|
||||
/** street */
|
||||
street?: string | null;
|
||||
/** owner street */
|
||||
ownerStreet?: string | null;
|
||||
/** town */
|
||||
town?: string | null;
|
||||
/** IBAN */
|
||||
|
||||
@@ -28,7 +28,7 @@ const FormFields: FC<FormFieldsProps> = ({ userSettings, errors, message }) => {
|
||||
// Track current form values for real-time validation
|
||||
const [formValues, setFormValues] = useState({
|
||||
ownerName: userSettings?.ownerName ?? "",
|
||||
street: userSettings?.street ?? "",
|
||||
ownerStreet: userSettings?.ownerStreet ?? "",
|
||||
town: userSettings?.town ?? "",
|
||||
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.street || !formValues.town || !cleanedIban || !formValues.currency;
|
||||
const hasMissingData = !formValues.ownerName || !formValues.ownerStreet || !formValues.town || !cleanedIban || !formValues.currency;
|
||||
|
||||
// Track whether to generate 2D code for tenant (use persisted value from database)
|
||||
const [show2dCodeInMonthlyStatement, setShow2dCodeInMonthlyStatement] = useState(
|
||||
@@ -96,21 +96,22 @@ const FormFields: FC<FormFieldsProps> = ({ userSettings, errors, message }) => {
|
||||
|
||||
<div className="form-control w-full">
|
||||
<label className="label">
|
||||
<span className="label-text">{t("street-label")} </span>
|
||||
<span className="label-text">{t("owner-street-label")} </span>
|
||||
</label>
|
||||
<input
|
||||
id="street"
|
||||
name="street"
|
||||
id="ownerStreet"
|
||||
name="ownerStreet"
|
||||
type="text"
|
||||
placeholder={t("street-placeholder")}
|
||||
maxLength={25}
|
||||
placeholder={t("owner-street-placeholder")}
|
||||
className="input input-bordered w-full placeholder:text-gray-600"
|
||||
defaultValue={userSettings?.street ?? ""}
|
||||
onChange={(e) => handleInputChange("street", e.target.value)}
|
||||
defaultValue={userSettings?.ownerStreet ?? ""}
|
||||
onChange={(e) => handleInputChange("ownerStreet", e.target.value)}
|
||||
disabled={pending}
|
||||
/>
|
||||
<div id="street-error" aria-live="polite" aria-atomic="true">
|
||||
{errors?.street &&
|
||||
errors.street.map((error: string) => (
|
||||
<div id="ownerStreet-error" aria-live="polite" aria-atomic="true">
|
||||
{errors?.ownerStreet &&
|
||||
errors.ownerStreet.map((error: string) => (
|
||||
<p className="mt-2 text-sm text-red-500" key={error}>
|
||||
{error}
|
||||
</p>
|
||||
|
||||
@@ -29,7 +29,7 @@ export const ViewLocationCard:FC<ViewLocationCardProps> = ({location, userSettin
|
||||
AdresaPlatitelja: tenantStreet ?? "",
|
||||
SjedistePlatitelja: tenantTown ?? "",
|
||||
Primatelj: userSettings?.ownerName ?? "",
|
||||
AdresaPrimatelja: userSettings?.street ?? "",
|
||||
AdresaPrimatelja: userSettings?.ownerStreet ?? "",
|
||||
SjedistePrimatelja: userSettings?.town ?? "",
|
||||
IBAN: userSettings?.iban ?? "",
|
||||
ModelPlacanja: "HR00",
|
||||
|
||||
Reference in New Issue
Block a user