"Cancel" buttons replaced with <Link>
This commit is contained in:
@@ -4,22 +4,20 @@ import { FC } from "react";
|
||||
import { Bill, BillingLocation } from "../lib/db-types";
|
||||
import { useFormState } from "react-dom";
|
||||
import { Main } from "./Main";
|
||||
import { gotoHome } from "../lib/actions/navigationActions";
|
||||
import { deleteBillById } from "../lib/actions/billActions";
|
||||
import Link from "next/link";
|
||||
|
||||
export interface BillDeleteFormProps {
|
||||
bill: Bill,
|
||||
location: BillingLocation
|
||||
}
|
||||
|
||||
export const BillDeleteForm:FC<BillDeleteFormProps> = ({ bill, location }) =>
|
||||
{
|
||||
const handleAction = deleteBillById.bind(null, location._id, bill._id, location.yearMonth.year, location.yearMonth.month);
|
||||
export const BillDeleteForm:FC<BillDeleteFormProps> = ({ bill, location }) => {
|
||||
|
||||
const { year, month } = location.yearMonth;
|
||||
const handleAction = deleteBillById.bind(null, location._id, bill._id, year, month);
|
||||
const [ state, dispatch ] = useFormState(handleAction, null);
|
||||
|
||||
const handleCancel = () => {
|
||||
gotoHome(location.yearMonth);
|
||||
};
|
||||
|
||||
return(
|
||||
<Main>
|
||||
@@ -31,7 +29,7 @@ export const BillDeleteForm:FC<BillDeleteFormProps> = ({ bill, location }) =>
|
||||
</p>
|
||||
<div className="pt-4 text-center">
|
||||
<button className="btn btn-primary">Confim</button>
|
||||
<button type="button" className="btn btn-neutral ml-3" onClick={handleCancel}>Cancel</button>
|
||||
<Link className="btn btn-neutral ml-3" href={`/bill/${location._id}-${bill._id}/edit/`}>Cancel</Link>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user