(refactor): locationNotes removed

This commit is contained in:
Knee Cola
2025-11-18 11:55:42 +01:00
parent 6a4c869fa3
commit 92b2b74b66
2 changed files with 7 additions and 19 deletions

View File

@@ -14,7 +14,6 @@ import { getTranslations, getLocale } from "next-intl/server";
export type State = { export type State = {
errors?: { errors?: {
locationName?: string[]; locationName?: string[];
locationNotes?: string[];
generateTenantCode?: string[]; generateTenantCode?: string[];
tenantFirstName?: string[]; tenantFirstName?: string[];
tenantLastName?: string[]; tenantLastName?: string[];
@@ -34,7 +33,6 @@ export type State = {
const FormSchema = (t:IntlTemplateFn) => z.object({ const FormSchema = (t:IntlTemplateFn) => z.object({
_id: z.string(), _id: z.string(),
locationName: z.coerce.string().min(1, t("location-name-required")), locationName: z.coerce.string().min(1, t("location-name-required")),
locationNotes: z.string(),
generateTenantCode: z.boolean().optional().nullable(), generateTenantCode: z.boolean().optional().nullable(),
tenantFirstName: z.string().optional().nullable(), tenantFirstName: z.string().optional().nullable(),
tenantLastName: z.string().optional().nullable(), tenantLastName: z.string().optional().nullable(),
@@ -92,7 +90,6 @@ export const updateOrAddLocation = withUser(async (user:AuthenticatedUser, locat
const validatedFields = FormSchema(t).safeParse({ const validatedFields = FormSchema(t).safeParse({
locationName: formData.get('locationName'), locationName: formData.get('locationName'),
locationNotes: formData.get('locationNotes'),
generateTenantCode: formData.get('generateTenantCode') === 'on', generateTenantCode: formData.get('generateTenantCode') === 'on',
tenantFirstName: formData.get('tenantFirstName') || null, tenantFirstName: formData.get('tenantFirstName') || null,
tenantLastName: formData.get('tenantLastName') || null, tenantLastName: formData.get('tenantLastName') || null,
@@ -115,7 +112,6 @@ export const updateOrAddLocation = withUser(async (user:AuthenticatedUser, locat
const { const {
locationName, locationName,
locationNotes,
generateTenantCode, generateTenantCode,
tenantFirstName, tenantFirstName,
tenantLastName, tenantLastName,
@@ -156,7 +152,6 @@ export const updateOrAddLocation = withUser(async (user:AuthenticatedUser, locat
{ {
$set: { $set: {
name: locationName, name: locationName,
notes: locationNotes,
generateTenantCode: generateTenantCode || false, generateTenantCode: generateTenantCode || false,
tenantFirstName: tenantFirstName || null, tenantFirstName: tenantFirstName || null,
tenantLastName: tenantLastName || null, tenantLastName: tenantLastName || null,
@@ -185,7 +180,6 @@ export const updateOrAddLocation = withUser(async (user:AuthenticatedUser, locat
{ {
$set: { $set: {
name: locationName, name: locationName,
notes: locationNotes,
generateTenantCode: generateTenantCode || false, generateTenantCode: generateTenantCode || false,
tenantFirstName: tenantFirstName || null, tenantFirstName: tenantFirstName || null,
tenantLastName: tenantLastName || null, tenantLastName: tenantLastName || null,
@@ -207,7 +201,6 @@ export const updateOrAddLocation = withUser(async (user:AuthenticatedUser, locat
{ {
$set: { $set: {
name: locationName, name: locationName,
notes: locationNotes,
generateTenantCode: generateTenantCode || false, generateTenantCode: generateTenantCode || false,
tenantFirstName: tenantFirstName || null, tenantFirstName: tenantFirstName || null,
tenantLastName: tenantLastName || null, tenantLastName: tenantLastName || null,
@@ -227,7 +220,6 @@ export const updateOrAddLocation = withUser(async (user:AuthenticatedUser, locat
userId, userId,
userEmail, userEmail,
name: locationName, name: locationName,
notes: locationNotes,
generateTenantCode: generateTenantCode || false, generateTenantCode: generateTenantCode || false,
tenantFirstName: tenantFirstName || null, tenantFirstName: tenantFirstName || null,
tenantLastName: tenantLastName || null, tenantLastName: tenantLastName || null,
@@ -299,7 +291,6 @@ export const updateOrAddLocation = withUser(async (user:AuthenticatedUser, locat
userId, userId,
userEmail, userEmail,
name: locationName, name: locationName,
notes: locationNotes,
generateTenantCode: generateTenantCode || false, generateTenantCode: generateTenantCode || false,
tenantFirstName: tenantFirstName || null, tenantFirstName: tenantFirstName || null,
tenantLastName: tenantLastName || null, tenantLastName: tenantLastName || null,

View File

@@ -78,14 +78,6 @@ export const LocationEditForm: FC<LocationEditFormProps> = ({ location, yearMont
))} ))}
</div> </div>
</fieldset> </fieldset>
<div id="status-error" aria-live="polite" aria-atomic="true">
{state.errors?.locationNotes &&
state.errors.locationNotes.map((error: string) => (
<p className="mt-2 text-sm text-red-500" key={error}>
{error}
</p>
))}
</div>
<fieldset className="fieldset bg-base-200 border-base-300 rounded-box w-xs border p-4 pb-2 mt-4"> <fieldset className="fieldset bg-base-200 border-base-300 rounded-box w-xs border p-4 pb-2 mt-4">
<legend className="fieldset-legend font-semibold uppercase">{t("tenant-2d-code-legend")}</legend> <legend className="fieldset-legend font-semibold uppercase">{t("tenant-2d-code-legend")}</legend>
@@ -284,11 +276,16 @@ export const LocationEditForm: FC<LocationEditFormProps> = ({ location, yearMont
} }
export const LocationEditFormSkeleton: FC = () => { export const LocationEditFormSkeleton: FC = () => {
const t = useTranslations("location-edit-form");
return ( return (
<div className="card card-compact card-bordered min-w-[20em] max-w-[90em] bg-base-100 shadow-s my-1"> <div className="card card-compact card-bordered min-w-[20em] max-w-[90em] bg-base-100 shadow-s my-1">
<div className="card-body"> <div className="card-body">
<div id="locationName" className="input w-full skeleton"></div> <fieldset className="fieldset mt-2 p-2">
<div id="locationNotes" className="textarea my-1 w-full block h-[8em] skeleton"></div> <legend className="fieldset-legend font-semibold uppercase">{t("location-name-legend")}</legend>
<div id="locationName" className="input w-full skeleton"></div>
</fieldset>
<div className="pt-4"> <div className="pt-4">
<div className="btn w-[5.5em] skeleton"></div> <div className="btn w-[5.5em] skeleton"></div>
<div className="btn w-[5.5em] ml-3 skeleton"></div> <div className="btn w-[5.5em] ml-3 skeleton"></div>