mirror of
https://github.com/rjNemo/melon_frontend
synced 2026-06-06 02:16:45 +00:00
feat: redirect after creation
This commit is contained in:
parent
e953246d06
commit
3343e3595e
2 changed files with 7 additions and 1 deletions
|
|
@ -12,6 +12,7 @@ const BillPage = () => {
|
|||
// Hooks
|
||||
const { id } = useParams<QueryParams>();
|
||||
const [sent, setSent] = useState(false);
|
||||
|
||||
// Local State
|
||||
const [bill, setBill] = useState<Bill>({} as Bill);
|
||||
|
||||
|
|
|
|||
|
|
@ -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<BillForm>();
|
||||
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 (
|
||||
<main>
|
||||
|
|
|
|||
Loading…
Reference in a new issue