diff --git a/src/bindings.ts b/src/bindings.ts index 50260a0..6b9a741 100644 --- a/src/bindings.ts +++ b/src/bindings.ts @@ -132,3 +132,17 @@ export type Template = { html: string; companyId: number; }; + +export interface Client { + id: number; + name: string; + cin?: string; + vatId?: string; + streetAddress: string; + city: string; + postalCode: string; + email?: string; + phoneNumber?: string; + invoices?: Invoice[]; + companyId: number; +} diff --git a/src/screens/Dashboard/components/Form/Dropdown.tsx b/src/screens/Dashboard/components/Form/Dropdown.tsx index 165eb97..df0fea3 100644 --- a/src/screens/Dashboard/components/Form/Dropdown.tsx +++ b/src/screens/Dashboard/components/Form/Dropdown.tsx @@ -24,71 +24,67 @@ const Dropdown: Component = (props) => { }; return ( -
- -
- - {selected().name} - - - - - {({ isOpen }): JSX.Element => ( - - - - {(item): JSX.Element => ( - - {({ isActive, isSelected }): JSX.Element => ( -
+ + {selected().name} + + + + + {({ isOpen }): JSX.Element => ( + + + + {(item): JSX.Element => ( + + {({ isActive, isSelected }): JSX.Element => ( +
+ + {item.name} + + {isSelected() ? ( + - - {item.name} - - {isSelected() ? ( - - - - ) : null} -
- )} -
+ + + ) : null} +
)} -
-
-
- )} -
-
-
-
+ + )} + + + + )} + + ); }; diff --git a/src/screens/Dashboard/components/Form/Input.tsx b/src/screens/Dashboard/components/Form/Input.tsx index f4c9fd8..fe413b3 100644 --- a/src/screens/Dashboard/components/Form/Input.tsx +++ b/src/screens/Dashboard/components/Form/Input.tsx @@ -1,7 +1,7 @@ import type { Component } from "solid-js"; type TextInputProps = { - type: "text" | "date"; + type: "text" | "date" | "email" | "tel"; onChange: (value: string) => void; label: string; defaultValue?: string; @@ -29,7 +29,7 @@ const Input: Component = (props) => { return ( }> = (props) => { +const Form: ParentComponent<{ form: FormApi; class?: string }> = (props) => { return (
{ e.preventDefault(); e.stopPropagation(); diff --git a/src/screens/Dashboard/pages/Sales/Clients/ManageClient.tsx b/src/screens/Dashboard/pages/Sales/Clients/ManageClient.tsx index 05d1a3b..0cef099 100644 --- a/src/screens/Dashboard/pages/Sales/Clients/ManageClient.tsx +++ b/src/screens/Dashboard/pages/Sales/Clients/ManageClient.tsx @@ -4,10 +4,30 @@ import PageHeader from "@/screens/Dashboard/components/PageHeader"; import HeaderButton from "@/screens/Dashboard/components/PageHeader/HeaderButton"; import { useParams } from "@solidjs/router"; import type { Component } from "solid-js"; +import { createForm } from "@tanstack/solid-form"; +import Input from "@/screens/Dashboard/components/Form/Input"; +import Dropdown from "@/screens/Dashboard/components/Form/Dropdown"; +import type { Client } from "@/bindings"; +import Form from "@/screens/Dashboard/components/Form"; const ManageClient: Component = () => { const params = useParams<{ readonly id?: string }>(); const [t] = useI18n(); + const form = createForm(() => ({ + defaultValues: { + id: 0, + name: "", + cin: "", + vatId: "", + streetAddress: "", + city: "", + postalCode: "", + email: "", + phoneNumber: "", + companyId: 0, + }, + onSubmit: (client) => alert(JSON.stringify(client)), + })); return ( @@ -19,6 +39,127 @@ const ManageClient: Component = () => { , ]} /> + +
+
+
+
+ + {(field) => ( + field().handleChange(data)} + /> + )} + + + {(field) => ( + field().handleChange(data)} + /> + )} + + + {(field) => ( + field().handleChange(data)} + /> + )} + +
+
+
+
+ + {(field) => ( + field().handleChange(data)} + /> + )} + + + {(field) => ( + field().handleChange(data)} + /> + )} + + + {(field) => ( + field().handleChange(data)} + /> + )} + +
+
+
+
+
+
+ + {(field) => ( + field().handleChange(data)} + /> + )} + + + {(field) => ( + field().handleChange(data)} + /> + )} + +
+
+
+
+ + {(field) => ( + field().handleChange(data.id)} + /> + )} + +
+
+
+
+ +
+
+
); };