From cef4e86c35d632254153f4043316468011a82701 Mon Sep 17 00:00:00 2001 From: Sachi Goto <70562492+SachiGoto@users.noreply.github.com> Date: Tue, 12 Dec 2023 18:13:54 +0900 Subject: [PATCH] updated based on feedback --- app/activity/create/components/form.tsx | 238 ++++++++---------- app/activity/create/components/index.ts | 2 +- app/activity/create/page.tsx | 29 +-- .../create/{components => }/schema.ts | 8 +- app/components/input/index.ts | 2 + app/components/input/input-form.tsx | 29 +++ app/components/input/textarea-form.tsx | 29 +++ 7 files changed, 183 insertions(+), 154 deletions(-) rename app/activity/create/{components => }/schema.ts (69%) create mode 100644 app/components/input/input-form.tsx create mode 100644 app/components/input/textarea-form.tsx diff --git a/app/activity/create/components/form.tsx b/app/activity/create/components/form.tsx index 5e98ad0..e1949b8 100644 --- a/app/activity/create/components/form.tsx +++ b/app/activity/create/components/form.tsx @@ -7,19 +7,17 @@ import { FormControl, FormLabel, FormErrorMessage, - Input, Button, - Textarea, Image, SimpleGrid, Text, Flex } from '@chakra-ui/react' - import { PrimaryButton } from '@/components/button' -import { createActivitySchema, createActivityResolver } from './schema' +import { InputForm, TextareaForm } from '@/components/input' +import { createActivitySchema, createActivityResolver } from '../schema' -export const Form = () => { +export const FormActivity = () => { const [selectedImages, setSelectedImages] = useState([]) const onDrop = useCallback((acceptedFiles: File[]) => { setSelectedImages((prevImages) => [...prevImages, ...acceptedFiles]) @@ -43,141 +41,123 @@ export const Form = () => { const createHandler = handleSubmit(async (data: createActivitySchema) => { // TODO append images to formData and send to backend - console.log('formData', data) }) return ( - - - - Title - - {errors.title && ( - {errors.title.message} - )} - + + + Title + + {errors.title && ( + {errors.title.message} + )} + - - Time From - - {errors.timeFrom && ( - {errors.timeFrom.message} - )} - + + Time From + + {errors.timeFrom && ( + {errors.timeFrom.message} + )} + - - Time To - - {errors.timeTo && ( - {errors.timeTo.message} - )} - + + Time To + + {errors.timeTo && ( + {errors.timeTo.message} + )} + - - Address - - {errors.address && ( - {errors.address.message} - )} - + + Address + + {errors.address && ( + {errors.address.message} + )} + - - URL - - {errors.url && ( - {errors.url.message} - )} - + + URL + + {errors.url && ( + {errors.url.message} + )} + - - Image - - - {selectedImages.map((image, index) => ( - {`Selected removeImage(index)} - /> - ))} - + + Image + + + {selectedImages.map((image, index) => ( + {`Selected removeImage(index)} + /> + ))} + - - - - Add Image - - + + + + Add Image + + - - Memo -