(refactor): locationNotes removed
This commit is contained in:
@@ -14,7 +14,6 @@ import { getTranslations, getLocale } from "next-intl/server";
|
||||
export type State = {
|
||||
errors?: {
|
||||
locationName?: string[];
|
||||
locationNotes?: string[];
|
||||
generateTenantCode?: string[];
|
||||
tenantFirstName?: string[];
|
||||
tenantLastName?: string[];
|
||||
@@ -34,7 +33,6 @@ export type State = {
|
||||
const FormSchema = (t:IntlTemplateFn) => z.object({
|
||||
_id: z.string(),
|
||||
locationName: z.coerce.string().min(1, t("location-name-required")),
|
||||
locationNotes: z.string(),
|
||||
generateTenantCode: z.boolean().optional().nullable(),
|
||||
tenantFirstName: 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({
|
||||
locationName: formData.get('locationName'),
|
||||
locationNotes: formData.get('locationNotes'),
|
||||
generateTenantCode: formData.get('generateTenantCode') === 'on',
|
||||
tenantFirstName: formData.get('tenantFirstName') || null,
|
||||
tenantLastName: formData.get('tenantLastName') || null,
|
||||
@@ -115,7 +112,6 @@ export const updateOrAddLocation = withUser(async (user:AuthenticatedUser, locat
|
||||
|
||||
const {
|
||||
locationName,
|
||||
locationNotes,
|
||||
generateTenantCode,
|
||||
tenantFirstName,
|
||||
tenantLastName,
|
||||
@@ -156,7 +152,6 @@ export const updateOrAddLocation = withUser(async (user:AuthenticatedUser, locat
|
||||
{
|
||||
$set: {
|
||||
name: locationName,
|
||||
notes: locationNotes,
|
||||
generateTenantCode: generateTenantCode || false,
|
||||
tenantFirstName: tenantFirstName || null,
|
||||
tenantLastName: tenantLastName || null,
|
||||
@@ -185,7 +180,6 @@ export const updateOrAddLocation = withUser(async (user:AuthenticatedUser, locat
|
||||
{
|
||||
$set: {
|
||||
name: locationName,
|
||||
notes: locationNotes,
|
||||
generateTenantCode: generateTenantCode || false,
|
||||
tenantFirstName: tenantFirstName || null,
|
||||
tenantLastName: tenantLastName || null,
|
||||
@@ -207,7 +201,6 @@ export const updateOrAddLocation = withUser(async (user:AuthenticatedUser, locat
|
||||
{
|
||||
$set: {
|
||||
name: locationName,
|
||||
notes: locationNotes,
|
||||
generateTenantCode: generateTenantCode || false,
|
||||
tenantFirstName: tenantFirstName || null,
|
||||
tenantLastName: tenantLastName || null,
|
||||
@@ -227,7 +220,6 @@ export const updateOrAddLocation = withUser(async (user:AuthenticatedUser, locat
|
||||
userId,
|
||||
userEmail,
|
||||
name: locationName,
|
||||
notes: locationNotes,
|
||||
generateTenantCode: generateTenantCode || false,
|
||||
tenantFirstName: tenantFirstName || null,
|
||||
tenantLastName: tenantLastName || null,
|
||||
@@ -299,7 +291,6 @@ export const updateOrAddLocation = withUser(async (user:AuthenticatedUser, locat
|
||||
userId,
|
||||
userEmail,
|
||||
name: locationName,
|
||||
notes: locationNotes,
|
||||
generateTenantCode: generateTenantCode || false,
|
||||
tenantFirstName: tenantFirstName || null,
|
||||
tenantLastName: tenantLastName || null,
|
||||
|
||||
@@ -78,14 +78,6 @@ export const LocationEditForm: FC<LocationEditFormProps> = ({ location, yearMont
|
||||
))}
|
||||
</div>
|
||||
</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">
|
||||
<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 = () => {
|
||||
const t = useTranslations("location-edit-form");
|
||||
|
||||
return (
|
||||
<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 id="locationName" className="input w-full skeleton"></div>
|
||||
<div id="locationNotes" className="textarea my-1 w-full block h-[8em] skeleton"></div>
|
||||
<fieldset className="fieldset mt-2 p-2">
|
||||
<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="btn w-[5.5em] skeleton"></div>
|
||||
<div className="btn w-[5.5em] ml-3 skeleton"></div>
|
||||
|
||||
Reference in New Issue
Block a user