diff --git a/src/pages/bill.tsx b/src/pages/bill.tsx index eb6329c..df32221 100644 --- a/src/pages/bill.tsx +++ b/src/pages/bill.tsx @@ -12,6 +12,7 @@ const BillPage = () => { // Hooks const { id } = useParams(); const [sent, setSent] = useState(false); + // Local State const [bill, setBill] = useState({} as Bill); diff --git a/src/pages/home.tsx b/src/pages/home.tsx index e32d2b6..9377e5d 100644 --- a/src/pages/home.tsx +++ b/src/pages/home.tsx @@ -1,5 +1,6 @@ import { Button, Form, Input, Switch } from 'antd'; import { Controller, useForm } from 'react-hook-form'; +import { useHistory } from 'react-router-dom'; import { createBill } from '../api'; import { InputSelect } from '../components/inputSelect'; import { withLayout } from '../layouts/main'; @@ -8,9 +9,13 @@ import { BillForm } from '../types/bill'; const HomePage = () => { // Hooks const { register, handleSubmit, control } = useForm(); + const history = useHistory(); // Logic - const onSubmit = handleSubmit((data) => createBill(data)); + const onSubmit = handleSubmit(async (data) => { + const newId = await createBill(data); + history.push(`/bills/${newId}`); + }); return (