From 6fa952d8db468b48b3c985ad6ae0a233c390f45f Mon Sep 17 00:00:00 2001 From: anyl92 Date: Sun, 20 Aug 2023 07:42:43 +0900 Subject: [PATCH] feat(active): valid check, btn disable, checkd ui --- src/features/setting/Container.tsx | 23 +++++++++--- .../setting/components/PreviewSection.tsx | 10 ++++- .../components/SubmitForm/DailySticker.tsx | 11 +++++- .../components/SubmitForm/DailyWord.tsx | 6 ++- src/features/setting/constants.ts | 3 +- src/features/setting/hooks/useSetting.ts | 3 +- src/features/setting/style/index.scss | 37 +++++++++++++++---- 7 files changed, 74 insertions(+), 19 deletions(-) diff --git a/src/features/setting/Container.tsx b/src/features/setting/Container.tsx index 0a8ccf7..0149d34 100644 --- a/src/features/setting/Container.tsx +++ b/src/features/setting/Container.tsx @@ -12,22 +12,33 @@ const Container = () => { const [, setTitle] = useAtom(titleAtom); const [, setBottomBtn] = useAtom(bottomBtnAtom); - const { handlePreviewClick, handleSubmit, onSubmit, register, control } = - useSetting(); + const { + handlePreviewClick, + handleSubmit, + onSubmit, + register, + control, + formState, + } = useSetting(); useLayoutEffect(() => { setTitle({ title: 'Active', back: true }); - setBottomBtn({ text: 'Save' }); - + setBottomBtn({ + text: 'Save', + disable: !formState.isValid ? true : false, + }); return () => { setTitle({}); setBottomBtn({}); }; - }, []); + }, [formState.isValid]); return (
- + void; + formState: FormState; }; const PreviewSection: FunctionComponent = ({ handlePreviewClick, + formState, }) => { return (
{previewTitleText}
{previewSubText}
-
diff --git a/src/features/setting/components/SubmitForm/DailySticker.tsx b/src/features/setting/components/SubmitForm/DailySticker.tsx index 7c3c5d8..143db1d 100644 --- a/src/features/setting/components/SubmitForm/DailySticker.tsx +++ b/src/features/setting/components/SubmitForm/DailySticker.tsx @@ -3,7 +3,7 @@ import { Controller } from 'react-hook-form'; import { Control } from 'react-hook-form'; import { Inputs } from '../../types'; -import { stickerList, wordStickerText } from '../../constants'; +import { stickerList, stickerText, wordStickerText } from '../../constants'; import moodBad from '/png/mood_BAD.png'; import moodGood from '/png/mood_GOOD.png'; @@ -23,12 +23,19 @@ const DailySticker: FunctionComponent = ({ control }) => { rules={{ required: true }} render={({ field }) => (
- {stickerList.map((sticker) => ( + {stickerList.map((sticker, idx) => (