From 0e38b9b833ccf60af41eb78618d0f580ad8de4cc Mon Sep 17 00:00:00 2001 From: Damian Date: Mon, 26 Jun 2023 14:45:34 +0200 Subject: [PATCH 01/92] feat: add form --- package.json | 1 + src/components/Form/Form.tsx | 47 ++++++++++++++++++++++++++++++++++++ src/components/Form/index.ts | 1 + yarn.lock | 5 ++++ 4 files changed, 54 insertions(+) create mode 100644 src/components/Form/Form.tsx create mode 100644 src/components/Form/index.ts diff --git a/package.json b/package.json index 3aac8a9..e6cf894 100644 --- a/package.json +++ b/package.json @@ -20,6 +20,7 @@ "next-seo": "6.0.0", "react": "18.2.0", "react-dom": "18.2.0", + "react-hook-form": "^7.45.0", "react-markdown": "^8.0.7", "tailwind-merge": "1.12.0" }, diff --git a/src/components/Form/Form.tsx b/src/components/Form/Form.tsx new file mode 100644 index 0000000..3004223 --- /dev/null +++ b/src/components/Form/Form.tsx @@ -0,0 +1,47 @@ +import { SubmitHandler,useForm } from 'react-hook-form'; + +type Inputs = { + name: string; + email: string; + department: string; + message: string; +}; + +export function Form() { + const { + register, + handleSubmit, + watch, + formState: { errors } + } = useForm(); + + const onSubmit: SubmitHandler = data => console.log(data); + console.log(watch('name')); + + return ( + <> +

Cześć!

+

Cieszymy się, że chcesz zostać członkiem CodersCrew!

+
+ + {errors.name && To pole jest wymagane} + + {errors.email && ( + Błędny format e-mail (brak znaków specjalnych np. @, .) + )} + + + {errors.message && To pole jest wymagane} + + + +
+ + ); +} diff --git a/src/components/Form/index.ts b/src/components/Form/index.ts new file mode 100644 index 0000000..d39070f --- /dev/null +++ b/src/components/Form/index.ts @@ -0,0 +1 @@ +export { Form } from './Form'; diff --git a/yarn.lock b/yarn.lock index 5f10164..f98449f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -9696,6 +9696,11 @@ react-element-to-jsx-string@^15.0.0: is-plain-object "5.0.0" react-is "18.1.0" +react-hook-form@^7.45.0: + version "7.45.0" + resolved "https://registry.yarnpkg.com/react-hook-form/-/react-hook-form-7.45.0.tgz#df2bbc8cee598855a63ba446e0bb06f7c8120ccf" + integrity sha512-AbHeZ4ad+0dEIknSW9dBgIwcvRDfZ1O97sgj75WaMdOX0eg8TBiUf9wxzVkIjZbk76BBIE9lmFOzyD4PN80ZQg== + react-inspector@^6.0.0: version "6.0.1" resolved "https://registry.yarnpkg.com/react-inspector/-/react-inspector-6.0.1.tgz#1a37f0165d9df81ee804d63259eaaeabe841287d" From 4687b99e8d1170baeaf38b97f88b78ec4e9c5578 Mon Sep 17 00:00:00 2001 From: Damian Date: Mon, 26 Jun 2023 14:46:34 +0200 Subject: [PATCH 02/92] feat: add checkbox --- src/components/Form/Form.tsx | 36 ++++++++++++++++++++++++++++++++---- 1 file changed, 32 insertions(+), 4 deletions(-) diff --git a/src/components/Form/Form.tsx b/src/components/Form/Form.tsx index 3004223..f1fb32f 100644 --- a/src/components/Form/Form.tsx +++ b/src/components/Form/Form.tsx @@ -1,4 +1,4 @@ -import { SubmitHandler,useForm } from 'react-hook-form'; +import { SubmitHandler, useForm } from 'react-hook-form'; type Inputs = { name: string; @@ -36,10 +36,38 @@ export function Form() { - +