-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug] 나의 스터디 페이지 QA 반영 #87
Changes from 13 commits
4ec25ac
b22cb51
1b78c6f
95b097a
3135e57
3d6a0fa
47d0418
bf1aee8
97bd9f5
4d50c26
e3847d4
73fbe3b
96f7053
008dabb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
import { css } from "@styled-system/css"; | ||
import { Flex } from "@styled-system/jsx"; | ||
import { Modal, Text } from "@wow-class/ui"; | ||
import { useModalRoute } from "@wow-class/ui/hooks"; | ||
import { myStudyApi } from "apis/myStudyApi"; | ||
import useFetchAttendanceCheckModalInfoData from "hooks/useFetchAttendanceCheckModalInfoData"; | ||
import Image from "next/image"; | ||
|
@@ -16,35 +17,52 @@ const AttendanceCheckModal = () => { | |
const [error, setError] = useState(false); | ||
const [attendanceNumber, setAttendanceNumber] = useState(""); | ||
|
||
const { onClose } = useModalRoute(); | ||
|
||
const { studyInfo } = useFetchAttendanceCheckModalInfoData(); | ||
|
||
const handleChangeAttendanceNumber = (value: string) => { | ||
setAttendanceNumber(value); | ||
}; | ||
|
||
const handleClickAttendanceCheckButton = async () => { | ||
const fetchOngoingStudyInfo = async () => { | ||
const myOngoingStudyInfoData = await myStudyApi.getMyOngoingStudyInfo(); | ||
return myOngoingStudyInfoData?.studyId || null; | ||
}; | ||
|
||
if (!myOngoingStudyInfoData?.studyId) { | ||
return; | ||
} | ||
|
||
const isValidAttendanceNumber = validateAttendanceNumber(attendanceNumber); | ||
|
||
if (!isValidAttendanceNumber) { | ||
return setError(true); | ||
} | ||
const isAttendanceNumberValid = (attendanceNumber: string) => { | ||
return validateAttendanceNumber(attendanceNumber); | ||
}; | ||
Comment on lines
+33
to
+35
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. just ask; There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. handleClickAttendanceCheckButton 자체가 여러 역할들을 하다보니 함수가 한 가지 일을 할 수 있도록 여러 함수로 분리했어요! |
||
|
||
const checkAttendance = async (studyId: number, attendanceNumber: string) => { | ||
const { success } = await myStudyApi.checkAttendance( | ||
myOngoingStudyInfoData?.studyId, | ||
studyId, | ||
attendanceNumber | ||
); | ||
return success; | ||
}; | ||
|
||
const handleClickAttendanceCheckButton = async () => { | ||
const studyId = await fetchOngoingStudyInfo(); | ||
if (!studyId) return; | ||
|
||
if (!isAttendanceNumberValid(attendanceNumber)) { | ||
return setError(true); | ||
} | ||
|
||
const success = await checkAttendance(studyId, attendanceNumber); | ||
if (!success) { | ||
return setError(true); | ||
} | ||
|
||
handleAttendanceSuccess(); | ||
}; | ||
|
||
const handleAttendanceSuccess = () => { | ||
setAttended(true); | ||
setTimeout(() => { | ||
onClose(); | ||
}, 500); | ||
}; | ||
|
||
return ( | ||
|
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just ask;
그냥 반환해도
undefined
가 반환되어 동일하게 처리될 것 같은데null
로 가드해주신 이유가 궁금해요.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
음 큰 이유는 없긴 한데 undefined보다는 null이 좀 더 studyId가 없다는 걸 명시적으로 표현할 수 있지 않나 싶어서 적긴 했습니다!