diff --git a/src/Router.tsx b/src/Router.tsx index 883df1c..2dd00e9 100644 --- a/src/Router.tsx +++ b/src/Router.tsx @@ -4,6 +4,7 @@ import BillsPage from './pages/bills'; import HomePage from './pages/home'; import NewBillPage from './pages/newBill'; import NotFoundPage from './pages/notFound'; +import ReportPage from './pages/ReportPage'; type RouteConfig = { path: string; @@ -13,11 +14,13 @@ type RouteConfig = { export default function Router() { const routes: RouteConfig[] = [ + // Home { path: '/', component: HomePage, exact: true }, + // Bills { path: '/bills/new', component: NewBillPage, @@ -32,6 +35,13 @@ export default function Router() { path: '/bills/:id', component: BillPage }, + // Reports + { + path: '/reports', + component: ReportPage, + exact: true + }, + // … rest { path: '*', component: NotFoundPage diff --git a/src/components/radioInput.tsx b/src/components/radioInput.tsx new file mode 100644 index 0000000..b560251 --- /dev/null +++ b/src/components/radioInput.tsx @@ -0,0 +1,25 @@ +import { Form, Radio } from 'antd'; +import { Controller } from 'react-hook-form'; + +type RadioInputProps = { + control: any; + name: string; + label: string; + options: string[]; +}; + +export const RadioInput = ({ control, name, label, options }: RadioInputProps) => ( + ( + + + {options.map((label, value) => ( + {label} + ))} + + + )} + /> +); diff --git a/src/pages/ReportPage.tsx b/src/pages/ReportPage.tsx new file mode 100644 index 0000000..4b7ad52 --- /dev/null +++ b/src/pages/ReportPage.tsx @@ -0,0 +1,44 @@ +import { Button, Form } from 'antd'; +import { useForm } from 'react-hook-form'; +import { InputSelect } from '../components/inputSelect'; +import { RadioInput } from '../components/radioInput'; +import { withLayout } from '../layouts/main'; +import { monthToList, ReportFormType, ReportType } from '../types/report'; + +function ReportPage() { + // hooks + const { control, handleSubmit, watch } = useForm(); + + // Logic + const onFinish = handleSubmit((data) => console.log(data)); + + const isMonthlyReport = watch('type') === ReportType.monthly; + + return ( + <> +

Reports

+
+ + {isMonthlyReport && ( + + )} + + + + ); +} + +export default withLayout(ReportPage); diff --git a/src/pages/home.tsx b/src/pages/home.tsx index 140f590..695b90c 100644 --- a/src/pages/home.tsx +++ b/src/pages/home.tsx @@ -1,4 +1,4 @@ -import { Button } from 'antd'; +import { Button, Row } from 'antd'; import { useHistory } from 'react-router-dom'; import { withLayout } from '../layouts/main'; @@ -9,9 +9,14 @@ function HomePage() { return ( <>

Rent it Like a Pro

- + + + + ); } diff --git a/src/types/report/index.ts b/src/types/report/index.ts new file mode 100644 index 0000000..1052e3e --- /dev/null +++ b/src/types/report/index.ts @@ -0,0 +1,31 @@ +export type ReportFormType = { + type: ReportType; + month?: Month; +}; + +export enum ReportType { + monthly, + yearly +} + +enum Month { + January, + February, + March, + April, + May, + June, + July, + August, + September, + October, + November, + December +} + +export const monthToList = () => enumToList(Month); + +export const enumToList = (enumerable: any) => + Object.keys(enumerable) + .filter((v) => !parseInt(v)) + .slice(1);