Skip to content

Commit

Permalink
refactor: 중복 로직 삼항연산자로 개선
Browse files Browse the repository at this point in the history
  • Loading branch information
hamo-o committed Aug 29, 2024
1 parent a2195bc commit 2f0aede
Showing 1 changed file with 10 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,26 +29,22 @@ const AssignmentHeader = ({ assignment, disabled }: AssignmentHeaderProps) => {
const onOpen = methods.getValues("onOpen");

const handleClickSubmit = async () => {
if (assignmentStatus === "CANCELLED") return;

const data = {
title: methods.getValues("title"),
descriptionNotionLink: methods.getValues("descriptionNotionLink"),
deadLine: methods.getValues("deadLine"),
};

if (assignmentStatus === "NONE") {
const { success } = await studyApi.createAssignment(studyDetailId, data);
if (success) {
revalidateTagByName(`${tags.assignments} ${studyDetailId.toString()}`);
revalidateTagByName(tags.assignments);
onOpen();
}
} else if (assignmentStatus === "OPEN") {
const { success } = await studyApi.patchAssignment(studyDetailId, data);
if (success) {
revalidateTagByName(`${tags.assignments} ${studyDetailId.toString()}`);
revalidateTagByName(tags.assignments);
onOpen();
}
const { success } =
assignmentStatus === "NONE"
? await studyApi.createAssignment(studyDetailId, data)
: await studyApi.patchAssignment(studyDetailId, data);
if (success) {
revalidateTagByName(`${tags.assignments} ${studyDetailId.toString()}`);
revalidateTagByName(tags.assignments);
onOpen();
}
};

Expand Down

0 comments on commit 2f0aede

Please sign in to comment.