Skip to content

Commit

Permalink
refactor: 인터뷰 로딩 기능 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
JaeHongDev committed Jul 4, 2024
1 parent a8f42e9 commit 672a61f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import {Button, ModalBody, ModalContent, ModalHeader, Slider} from "@nextui-org/
import {problemCount, tailQuestionCount} from "@/components/InterviewCreatorForm/InterviewCreateForm.constant";
import {InterviewSettings} from "@/types/interview";
import {useInterviewCreateMutation} from "@/hooks/api/interview/useInterviewCreateMutation";
import {useCallback} from "react";
import {useInterviewCreateForm} from "@/components/InterviewCreatorForm/useInterviewCreateForm";


Expand Down Expand Up @@ -46,13 +45,9 @@ interface InterviewCreateFormProps {
}

const InterviewCreateForm = ({ interviewSettings: {questionSetId, count, tailQuestionDepth}}: InterviewCreateFormProps) => {
const {mutate} = useInterviewCreateMutation();
const {mutate, isPending,isSuccess} = useInterviewCreateMutation();
const {interviewCreateForm, handleOnChange} = useInterviewCreateForm({tailQuestionDepth, totalProblemCount:count})

const handleInterviewCreate = useCallback(() => {
mutate({questionSetId, ...interviewCreateForm});
}, [interviewCreateForm]);

return (
<ModalContent>
{() => (
Expand All @@ -78,7 +73,9 @@ const InterviewCreateForm = ({ interviewSettings: {questionSetId, count, tailQue
<p>*아직 지원하지 않습니다.</p>
<InterviewSettingsSlider label={"문항 별 대기 시간"} disabled={true}/>
<InterviewSettingsSlider label={"문항 별 제한 시간"} disabled={true}/>
<Button onClick={handleInterviewCreate}>면접 시작</Button>
<Button onClick={() => {
mutate({questionSetId, ...interviewCreateForm});
}} isLoading={isPending || isSuccess}>면접 시작</Button>
</ModalBody>
</>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {PATH} from "@/constants/path";
import {toast} from "sonner";



export const useInterviewCreateMutation = () => {
const navigate = useNavigate();
return useMutation({
Expand All @@ -14,9 +15,7 @@ export const useInterviewCreateMutation = () => {
navigate(PATH.INTERVIEW(interviewId));
},
onError:(error) => {
console.log(error.message);
toast.error(error.message)
}

})
}
4 changes: 2 additions & 2 deletions frontend/src/pages/MainPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ export default function(){
{isLoading ? <QuestionSetItemListSkeleton/> : <></>}
<div ref={ref}/>
</div>
<Modal backdrop="blur" isDismissable={false} isKeyboardDismissDisabled={true} isOpen={isOpen} placement={"top"} className={`text-foreground bg-background dark`} onClose={onClose}>
<InterviewCreateForm interviewSettings={settings} />
<Modal backdrop="opaque" isDismissable={false} isKeyboardDismissDisabled={true} isOpen={isOpen} placement={"top"} onClose={onClose}>
<InterviewCreateForm interviewSettings={settings}/>
</Modal>
</div>
)
Expand Down

0 comments on commit 672a61f

Please sign in to comment.