-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
115 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
apps/admin/app/students/@modal/_components/OutstandingModalFooter.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
"use client"; | ||
|
||
import { useModalRoute } from "@wow-class/ui/hooks"; | ||
import studyAchievementApi from "apis/study/studyAchievementApi"; | ||
import { tags } from "constants/tags"; | ||
import { useAtom, useAtomValue } from "jotai"; | ||
import { revalidateTagByName } from "utils/revalidateTagByName"; | ||
import Button from "wowds-ui/Button"; | ||
|
||
import { | ||
enabledOutstandingStudentsAtom, | ||
outstandingStudentsAtom, | ||
selectedStudentsAtom, | ||
studyAtom, | ||
} from "@/students/_contexts/StudyProvider"; | ||
|
||
const OutstandingModalFooter = () => { | ||
const study = useAtomValue(studyAtom); | ||
const [{ enabled }, setEnabledOutstandingStudents] = useAtom( | ||
enabledOutstandingStudentsAtom | ||
); | ||
const { type, achievement } = useAtomValue(outstandingStudentsAtom); | ||
const [{ students }, setSelectedStudents] = useAtom(selectedStudentsAtom); | ||
|
||
const { onClose } = useModalRoute(); | ||
|
||
const handleClickOutstanding = async () => { | ||
if (!study || !achievement) return; | ||
|
||
const fetch = | ||
type === "처리" | ||
? studyAchievementApi.postStudyAchievement | ||
: studyAchievementApi.deleteStudyAchievement; | ||
const result = await fetch(study.studyId, { | ||
studentIds: students, | ||
achievementType: achievement, | ||
}); | ||
if (result.success) { | ||
revalidateTagByName(tags.students); | ||
setEnabledOutstandingStudents({ | ||
enabled: false, | ||
}); | ||
} | ||
}; | ||
|
||
const handleClickCloseModal = () => { | ||
setSelectedStudents({ | ||
students: [], | ||
firstStudentName: "", | ||
}); | ||
onClose(); | ||
}; | ||
|
||
return enabled ? ( | ||
<Button onClick={handleClickOutstanding}>선택한 우수 회원 {type}</Button> | ||
) : ( | ||
<Button onClick={handleClickCloseModal}>확인하기</Button> | ||
); | ||
}; | ||
export default OutstandingModalFooter; |
38 changes: 38 additions & 0 deletions
38
apps/admin/app/students/@modal/_components/OutstandingModalHeader.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
"use client"; | ||
|
||
import { Text } from "@wow-class/ui"; | ||
import { | ||
outstandingRoundMap, | ||
outstandingTypeMap, | ||
} from "constants/status/outstandigOptions"; | ||
import { useAtomValue } from "jotai"; | ||
|
||
import { | ||
enabledOutstandingStudentsAtom, | ||
outstandingStudentsAtom, | ||
} from "@/students/_contexts/StudyProvider"; | ||
|
||
const OutstandingModalHeader = () => { | ||
const { enabled } = useAtomValue(enabledOutstandingStudentsAtom); | ||
const { type, achievement } = useAtomValue(outstandingStudentsAtom); | ||
|
||
if (!type || !achievement) return null; | ||
return enabled ? ( | ||
<Text | ||
typo="h1" | ||
style={{ | ||
textAlign: "center", | ||
}} | ||
> | ||
선택한 수강생을 <br /> | ||
{outstandingRoundMap[achievement]} {outstandingTypeMap[type]} | ||
하시겠어요? | ||
</Text> | ||
) : ( | ||
<Text typo="h1"> | ||
{outstandingRoundMap[achievement]} {outstandingTypeMap[type]} | ||
되었어요. | ||
</Text> | ||
); | ||
}; | ||
export default OutstandingModalHeader; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters