Skip to content

Commit

Permalink
feat: 필터 미선택 시 저장 버튼 비활성화
Browse files Browse the repository at this point in the history
  • Loading branch information
mlnwns committed Jul 22, 2024
1 parent 550af7a commit 831ad41
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions FE/error/src/components/scheduleCreate/CreateModal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ const CreateModal = ({
}
}, [isOpen, selectedDate]);

const isFilterSelected = () => {
return selectedFilter && selectedFilter.category && selectedFilter.filter;
};

const handleTitleChange = (event) => {
setEventName(event.target.value);
};
Expand Down Expand Up @@ -141,18 +145,21 @@ const CreateModal = ({
}

const saveData = () => {
if (!eventName || !isFilterSelected()) {
return; // 추가적인 안전장치
}

const data = {
eventName: eventName,
eventStartDate: eventStartDate,
eventEndDate: eventEndDate,
eventPlace: eventPlace,
eventInfo: eventMemo,
eventCategory: {
econo: selectedFilter.econo,
group: selectedFilter.group,
personal: selectedFilter.personal,
[selectedFilter.category]: selectedFilter.filter,
},
};

axios.post("/api/calendar", data).then((res) => {
createDate(
eventName,
Expand Down Expand Up @@ -295,7 +302,10 @@ const CreateModal = ({
<ReactQuill placeholder={"설명 추가"} onChange={handleMemoChange} />
</EditorBox>
<div style={{ display: "flex", justifyContent: "flex-end" }}>
<SaveButton onClick={saveData} disabled={!eventName}>
<SaveButton
onClick={saveData}
disabled={!eventName || !isFilterSelected()}
>
저장
</SaveButton>
</div>
Expand Down

0 comments on commit 831ad41

Please sign in to comment.