Remove lastName field from UserSettings and database
- 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 <noreply@anthropic.com>
This commit is contained in:
@@ -15,7 +15,6 @@ import * as IBAN from 'iban';
|
|||||||
export type State = {
|
export type State = {
|
||||||
errors?: {
|
errors?: {
|
||||||
firstName?: string[];
|
firstName?: string[];
|
||||||
lastName?: string[];
|
|
||||||
street?: string[];
|
street?: string[];
|
||||||
town?: string[];
|
town?: string[];
|
||||||
iban?: string[];
|
iban?: string[];
|
||||||
@@ -31,7 +30,6 @@ export type State = {
|
|||||||
*/
|
*/
|
||||||
const FormSchema = (t: IntlTemplateFn) => z.object({
|
const FormSchema = (t: IntlTemplateFn) => z.object({
|
||||||
firstName: z.string().optional(),
|
firstName: z.string().optional(),
|
||||||
lastName: z.string().optional(),
|
|
||||||
street: z.string().optional(),
|
street: z.string().optional(),
|
||||||
town: z.string().optional(),
|
town: z.string().optional(),
|
||||||
iban: z.string()
|
iban: z.string()
|
||||||
@@ -57,15 +55,6 @@ const FormSchema = (t: IntlTemplateFn) => z.object({
|
|||||||
message: t("first-name-required"),
|
message: t("first-name-required"),
|
||||||
path: ["firstName"],
|
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) => {
|
.refine((data) => {
|
||||||
if (data.show2dCodeInMonthlyStatement) {
|
if (data.show2dCodeInMonthlyStatement) {
|
||||||
return !!data.street && data.street.trim().length > 0;
|
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({
|
const validatedFields = FormSchema(t).safeParse({
|
||||||
firstName: formData.get('firstName') || undefined,
|
firstName: formData.get('firstName') || undefined,
|
||||||
lastName: formData.get('lastName') || undefined,
|
|
||||||
street: formData.get('street') || undefined,
|
street: formData.get('street') || undefined,
|
||||||
town: formData.get('town') || undefined,
|
town: formData.get('town') || undefined,
|
||||||
iban: formData.get('iban') || 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
|
// 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;
|
||||||
@@ -177,7 +165,6 @@ export const updateUserSettings = withUser(async (user: AuthenticatedUser, prevS
|
|||||||
const userSettings: UserSettings = {
|
const userSettings: UserSettings = {
|
||||||
userId,
|
userId,
|
||||||
firstName: firstName || null,
|
firstName: firstName || null,
|
||||||
lastName: lastName || null,
|
|
||||||
street: street || null,
|
street: street || null,
|
||||||
town: town || null,
|
town: town || null,
|
||||||
iban: normalizedIban,
|
iban: normalizedIban,
|
||||||
|
|||||||
@@ -20,8 +20,6 @@ export interface UserSettings {
|
|||||||
userId: string;
|
userId: string;
|
||||||
/** first name */
|
/** first name */
|
||||||
firstName?: string | null;
|
firstName?: string | null;
|
||||||
/** last name */
|
|
||||||
lastName?: string | null;
|
|
||||||
/** street */
|
/** street */
|
||||||
street?: string | null;
|
street?: string | null;
|
||||||
/** town */
|
/** town */
|
||||||
|
|||||||
@@ -28,7 +28,6 @@ const FormFields: FC<FormFieldsProps> = ({ userSettings, errors, message }) => {
|
|||||||
// Track current form values for real-time validation
|
// Track current form values for real-time validation
|
||||||
const [formValues, setFormValues] = useState({
|
const [formValues, setFormValues] = useState({
|
||||||
firstName: userSettings?.firstName ?? "",
|
firstName: userSettings?.firstName ?? "",
|
||||||
lastName: userSettings?.lastName ?? "",
|
|
||||||
street: userSettings?.street ?? "",
|
street: userSettings?.street ?? "",
|
||||||
town: userSettings?.town ?? "",
|
town: userSettings?.town ?? "",
|
||||||
iban: formatIban(userSettings?.iban) ?? "",
|
iban: formatIban(userSettings?.iban) ?? "",
|
||||||
@@ -41,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.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)
|
// Track whether to generate 2D code for tenant (use persisted value from database)
|
||||||
const [show2dCodeInMonthlyStatement, setShow2dCodeInMonthlyStatement] = useState(
|
const [show2dCodeInMonthlyStatement, setShow2dCodeInMonthlyStatement] = useState(
|
||||||
@@ -94,30 +93,6 @@ const FormFields: FC<FormFieldsProps> = ({ userSettings, errors, message }) => {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="form-control w-full">
|
|
||||||
<label className="label">
|
|
||||||
<span className="label-text">{t("last-name-label")}</span>
|
|
||||||
</label>
|
|
||||||
<input
|
|
||||||
id="lastName"
|
|
||||||
name="lastName"
|
|
||||||
type="text"
|
|
||||||
placeholder={t("last-name-placeholder")}
|
|
||||||
className="input input-bordered w-full placeholder:text-gray-600"
|
|
||||||
defaultValue={userSettings?.lastName ?? ""}
|
|
||||||
onChange={(e) => handleInputChange("lastName", e.target.value)}
|
|
||||||
disabled={pending}
|
|
||||||
/>
|
|
||||||
<div id="lastName-error" aria-live="polite" aria-atomic="true">
|
|
||||||
{errors?.lastName &&
|
|
||||||
errors.lastName.map((error: string) => (
|
|
||||||
<p className="mt-2 text-sm text-red-500" key={error}>
|
|
||||||
{error}
|
|
||||||
</p>
|
|
||||||
))}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="form-control w-full">
|
<div className="form-control w-full">
|
||||||
<label className="label">
|
<label className="label">
|
||||||
<span className="label-text">{t("street-label")} </span>
|
<span className="label-text">{t("street-label")} </span>
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ export const ViewLocationCard:FC<ViewLocationCardProps> = ({location, userSettin
|
|||||||
ImePlatitelja: tenantName ?? "",
|
ImePlatitelja: tenantName ?? "",
|
||||||
AdresaPlatitelja: tenantStreet ?? "",
|
AdresaPlatitelja: tenantStreet ?? "",
|
||||||
SjedistePlatitelja: tenantTown ?? "",
|
SjedistePlatitelja: tenantTown ?? "",
|
||||||
Primatelj: (userSettings?.firstName && userSettings?.lastName) ? `${userSettings.firstName} ${userSettings.lastName}` : "",
|
Primatelj: userSettings?.firstName ?? "",
|
||||||
AdresaPrimatelja: userSettings?.street ?? "",
|
AdresaPrimatelja: userSettings?.street ?? "",
|
||||||
SjedistePrimatelja: userSettings?.town ?? "",
|
SjedistePrimatelja: userSettings?.town ?? "",
|
||||||
IBAN: userSettings?.iban ?? "",
|
IBAN: userSettings?.iban ?? "",
|
||||||
|
|||||||
@@ -101,13 +101,13 @@
|
|||||||
"warning-message": "Ova operacija je nepovratna i obrisat će račun u svim mjesecima koji slijede!"
|
"warning-message": "Ova operacija je nepovratna i obrisat će račun u svim mjesecima koji slijede!"
|
||||||
},
|
},
|
||||||
"bill-edit-form": {
|
"bill-edit-form": {
|
||||||
"bill-name-placeholder": "Ime računa",
|
"bill-name-placeholder": "ime računa",
|
||||||
"paid-checkbox": "Plaćeno",
|
"paid-checkbox": "Plaćeno",
|
||||||
"scanning-pdf": "🕵️♂️ Tražim 2D barkodove unutar dokumenta...",
|
"scanning-pdf": "🕵️♂️ Tražim 2D barkodove unutar dokumenta...",
|
||||||
"multiple-barcode-results-notification": "✅ Pronađeno je više 2D barkodova. Molimo odaberi onaj koji se odnosi na zadani mjesec:",
|
"multiple-barcode-results-notification": "✅ Pronađeno je više 2D barkodova. Molimo odaberi onaj koji se odnosi na zadani mjesec:",
|
||||||
"payed-amount": "Iznos",
|
"payed-amount": "Iznos",
|
||||||
"barcode-disclaimer": "Nakon skeniranja bar koda obavezni provjeri jesu li svi podaci ispravni.<br></br>Ne snosimo odgovornost za slučaj pogrešno provedene uplate.",
|
"barcode-disclaimer": "Nakon skeniranja bar koda obavezni provjeri jesu li svi podaci ispravni.<br></br>Ne snosimo odgovornost za slučaj pogrešno provedene uplate.",
|
||||||
"notes-placeholder": "Bilješke",
|
"notes-placeholder": "bilješke",
|
||||||
"save-button": "Spremi",
|
"save-button": "Spremi",
|
||||||
"cancel-button": "Odbaci",
|
"cancel-button": "Odbaci",
|
||||||
"delete-tooltip": "Obriši račun",
|
"delete-tooltip": "Obriši račun",
|
||||||
@@ -135,7 +135,7 @@
|
|||||||
"location-edit-form": {
|
"location-edit-form": {
|
||||||
"location-name-legend": "Realestate name",
|
"location-name-legend": "Realestate name",
|
||||||
"location-name-placeholder": "unesite naziv nekretnine",
|
"location-name-placeholder": "unesite naziv nekretnine",
|
||||||
"notes-placeholder": "Bilješke",
|
"notes-placeholder": "bilješke",
|
||||||
"tenant-2d-code-legend": "2D BARKOD ZA PODSTANARA",
|
"tenant-2d-code-legend": "2D BARKOD ZA PODSTANARA",
|
||||||
"tenant-2d-code-info": "2D barkod omogućuje podstanaru da brzo i jednostavno na vaš IBAN uplati iznos koji vam duguje za plaćene režije. Barkod će biti prikazan kada podstanar otvori poveznicu na obračun za zadani mjesec.",
|
"tenant-2d-code-info": "2D barkod omogućuje podstanaru da brzo i jednostavno na vaš IBAN uplati iznos koji vam duguje za plaćene režije. Barkod će biti prikazan kada podstanar otvori poveznicu na obračun za zadani mjesec.",
|
||||||
"tenant-2d-code-toggle-label": "generiraj 2D barkod",
|
"tenant-2d-code-toggle-label": "generiraj 2D barkod",
|
||||||
@@ -143,8 +143,8 @@
|
|||||||
"tenant-name-placeholder": "unesite ime i prezime podstanara",
|
"tenant-name-placeholder": "unesite ime i prezime podstanara",
|
||||||
"tenant-street-label": "Ulica podstanara i kućni broj",
|
"tenant-street-label": "Ulica podstanara i kućni broj",
|
||||||
"tenant-street-placeholder": "unesite ulicu podstanara",
|
"tenant-street-placeholder": "unesite ulicu podstanara",
|
||||||
"tenant-town-label": "Grad podstanara",
|
"tenant-town-label": "Poštanski broj i Grad podstanara",
|
||||||
"tenant-town-placeholder": "unesite grad podstanara",
|
"tenant-town-placeholder": "unesite poštanski broj i grad podstanara",
|
||||||
"auto-utility-bill-forwarding-legend": "AUTOMATSKO PROSLJEĐIVANJE REŽIJA",
|
"auto-utility-bill-forwarding-legend": "AUTOMATSKO PROSLJEĐIVANJE REŽIJA",
|
||||||
"auto-utility-bill-forwarding-info": "Ova opcija omogućuje automatsko prosljeđivanje režija podstanaru putem emaila u skladu s odabranom strategijom.",
|
"auto-utility-bill-forwarding-info": "Ova opcija omogućuje automatsko prosljeđivanje režija podstanaru putem emaila u skladu s odabranom strategijom.",
|
||||||
"auto-utility-bill-forwarding-toggle-label": "proslijedi režije automatski",
|
"auto-utility-bill-forwarding-toggle-label": "proslijedi režije automatski",
|
||||||
@@ -189,15 +189,15 @@
|
|||||||
"tenant-2d-code-legend": "2D BARKOD ZA PODSTANARA",
|
"tenant-2d-code-legend": "2D BARKOD ZA PODSTANARA",
|
||||||
"tenant-2d-code-toggle-label": "prikazuj 2D barkod u mjesečnom obračunu",
|
"tenant-2d-code-toggle-label": "prikazuj 2D barkod u mjesečnom obračunu",
|
||||||
"first-name-label": "Ime",
|
"first-name-label": "Ime",
|
||||||
"first-name-placeholder": "Unesite svoje ime",
|
"first-name-placeholder": "unesite svoje ime",
|
||||||
"last-name-label": "Prezime",
|
"last-name-label": "Prezime",
|
||||||
"last-name-placeholder": "Unesite svoje prezime",
|
"last-name-placeholder": "unesite svoje prezime",
|
||||||
"street-label": "Ulica",
|
"street-label": "Ulica i kućni broj",
|
||||||
"street-placeholder": "Unesite ulicu",
|
"street-placeholder": "unesite ulicu i kućni broj",
|
||||||
"town-label": "Grad",
|
"town-label": "Poštanski broj i Grad",
|
||||||
"town-placeholder": "Unesite grad",
|
"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",
|
||||||
"save-button": "Spremi",
|
"save-button": "Spremi",
|
||||||
"cancel-button": "Odbaci",
|
"cancel-button": "Odbaci",
|
||||||
|
|||||||
Reference in New Issue
Block a user