Skip to content

Commit

Permalink
Merge pull request #8 from Team-Ampersand/fix/notice-button-click
Browse files Browse the repository at this point in the history
🔀 공지사항 중복 게시 해결
  • Loading branch information
Ethen1264 authored Sep 14, 2024
2 parents 42731ac + 41328d6 commit b5967bc
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 6 deletions.
3 changes: 3 additions & 0 deletions src/components/Notice/atoms/NoticeOptionBtn/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export interface Props {
borderRadius?: string;
onClick: () => void;
type?: 'button' | 'submit' | 'reset';
isSubmitting?: boolean;
}

const NoticeOptionBtn = ({
Expand All @@ -18,6 +19,7 @@ const NoticeOptionBtn = ({
borderRadius,
onClick,
type = 'button',
isSubmitting,
}: Props) => {
return (
<>
Expand All @@ -28,6 +30,7 @@ const NoticeOptionBtn = ({
border={border}
borderRadius={borderRadius}
onClick={() => onClick()}
disabled={isSubmitting}
>
{children}
</NoticeOptionButton>
Expand Down
7 changes: 6 additions & 1 deletion src/components/Notice/molecules/BottomBtnBox/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ import { isNoticeModify, isNoticeWrite } from 'recoilAtoms/recoilAtomContainer';
import { Palette } from 'styles/globals';
import * as S from './style';

const BottomBtnBox = () => {
interface Props {
isSubmitting: boolean;
}

const BottomBtnBox = ({ isSubmitting }: Props) => {
const setNoticeWrite = useSetRecoilState(isNoticeWrite);
const setNoticeModify = useSetRecoilState(isNoticeModify);

Expand All @@ -31,6 +35,7 @@ const BottomBtnBox = () => {
return;
}}
type="submit"
isSubmitting={isSubmitting}
>
확인
</NoticeOptionBtn>
Expand Down
16 changes: 11 additions & 5 deletions src/components/Notice/organisms/NoticeWrite/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,16 @@ import * as S from './style';

const NoticeWrite = () => {
const router = useRouter();
const { register, watch, handleSubmit, setValue, resetField } =
useForm<noticeFormType>({
defaultValues: { title: '', content: '' },
});
const {
register,
watch,
handleSubmit,
setValue,
resetField,
formState: { isSubmitting },
} = useForm<noticeFormType>({
defaultValues: { title: '', content: '' },
});

const [imgList, setImgList] = useState<string[]>([]);
const [postImgList, setPostImgList] = useState<File[]>([]);
Expand Down Expand Up @@ -88,7 +94,7 @@ const NoticeWrite = () => {
data={imgList}
onDelete={(id: number) => onImgDelete(id)}
/>
<BottomBtnBox />
<BottomBtnBox isSubmitting={isSubmitting} />
</S.Layer>
);
};
Expand Down

0 comments on commit b5967bc

Please sign in to comment.