delete forms were not wrapped in <Main>

This commit is contained in:
2024-02-15 15:52:27 +01:00
parent 4fe918840b
commit cebe5a7239
4 changed files with 26 additions and 18 deletions

View File

@@ -3,6 +3,7 @@ import { fetchLocationById } from '@/app/lib/actions/locationActions';
import { LocationDeleteForm } from '@/app/ui/LocationDeleteForm';
import { BillDeleteForm } from '@/app/ui/BillDeleteForm';
import { fetchBillById } from '@/app/lib/actions/billActions';
import { Main } from '@/app/ui/Main';
export default async function Page({ params:{ id } }: { params: { id:string } }) {
const [locationID, billID] = id.split('-');
@@ -13,5 +14,9 @@ export default async function Page({ params:{ id } }: { params: { id:string } })
return(notFound());
}
return (<BillDeleteForm location={location} bill={bill} />);
return (
<Main>
<BillDeleteForm location={location} bill={bill} />
</Main>
);
}

View File

@@ -1,6 +1,7 @@
import { notFound } from 'next/navigation';
import { fetchLocationById } from '@/app/lib/actions/locationActions';
import { LocationDeleteForm } from '@/app/ui/LocationDeleteForm';
import { Main } from '@/app/ui/Main';
export default async function Page({ params:{ id } }: { params: { id:string } }) {
@@ -10,5 +11,9 @@ export default async function Page({ params:{ id } }: { params: { id:string } })
return(notFound());
}
return (<LocationDeleteForm location={location} />);
return (
<Main>
<LocationDeleteForm location={location} />
</Main>
);
}

View File

@@ -20,20 +20,18 @@ export const BillDeleteForm:FC<BillDeleteFormProps> = ({ bill, location }) => {
return(
<Main>
<div className="card card-compact card-bordered min-w-[20em] max-w-[90em] bg-base-100 shadow-s my-1">
<div className="card-body">
<form action={dispatch}>
<p className="py-6 px-6">
Please confirm deletion of bill <strong>{bill.name}</strong> at <strong>{location.name}</strong>.
</p>
<div className="pt-4 text-center">
<button className="btn btn-primary">Confim</button>
<Link className="btn btn-neutral ml-3" href={`/bill/${location._id}-${bill._id}/edit/`}>Cancel</Link>
</div>
</form>
</div>
<div className="card card-compact card-bordered min-w-[20em] max-w-[90em] bg-base-100 shadow-s my-1">
<div className="card-body">
<form action={dispatch}>
<p className="py-6 px-6">
Please confirm deletion of bill <strong>{bill.name}</strong> at <strong>{location.name}</strong>.
</p>
<div className="pt-4 text-center">
<button className="btn btn-primary">Confim</button>
<Link className="btn btn-neutral ml-3" href={`/bill/${location._id}-${bill._id}/edit/`}>Cancel</Link>
</div>
</form>
</div>
</Main>
</div>
)
}

View File

@@ -37,7 +37,7 @@ export const LocationEditForm:FC<LocationEditFormProps> = ({ location, yearMonth
<TrashIcon className="h-[1em] w-[1em] text-error text-2xl" />
</Link>
}
<input id="locationName" name="locationName" type="text" placeholder="Naziv lokacije" className="input input-bordered w-full" defaultValue={location?.name ?? ""} />
<input id="locationName" name="locationName" type="text" placeholder="Realestate name" className="input input-bordered w-full" defaultValue={location?.name ?? ""} />
<div id="status-error" aria-live="polite" aria-atomic="true">
{state.errors?.locationName &&
state.errors.locationName.map((error: string) => (
@@ -47,7 +47,7 @@ export const LocationEditForm:FC<LocationEditFormProps> = ({ location, yearMonth
))}
</div>
<textarea id="locationNotes" name="locationNotes" className="textarea textarea-bordered my-1 w-full block h-[8em]" placeholder="Opis" defaultValue={location?.notes ?? ""}></textarea>
<textarea id="locationNotes" name="locationNotes" className="textarea textarea-bordered my-1 w-full block h-[8em]" placeholder="Description" defaultValue={location?.notes ?? ""}></textarea>
<div id="status-error" aria-live="polite" aria-atomic="true">
{state.errors?.locationNotes &&
state.errors.locationNotes.map((error: string) => (