Skip to content

Commit

Permalink
feat: 현재 질문 로딩 기능 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
JaeHongDev committed Jul 4, 2024
1 parent 3d7b67e commit 5ba30d7
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 23 deletions.
29 changes: 15 additions & 14 deletions frontend/src/components/InterviewForm/InterviewForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const border = "1px solid rgb(54, 54, 54)";
const InterviewForm = ({interviewId}: InterviewFormProps) => {
const {
interview,
interviewLoading,
handleSubmit,
handlePass,
chatList,
Expand Down Expand Up @@ -51,25 +52,25 @@ const InterviewForm = ({interviewId}: InterviewFormProps) => {
borderLeft: border
}}>
<div className='p-3'>
<InterviewQuestionBoard question={interview.question}
chatList={chatList}
remainTailQuestionCount={remainTailQuestionCount}/>
<InterviewQuestionBoard
isLoading={interviewLoading}
question={interview.question}
chatList={chatList}
remainTailQuestionCount={remainTailQuestionCount}/>
</div>

<div className="gap-1 h-full flex flex-col max-h-[310px] p-4" style={{
borderTop:border
}}>
<div>
<Textarea
placeholder="여기에 답을 적어주세요"
value={answer}
onChange={(e) => handleAnswerChange(e.target.value)}
minRows={10}
rows={10}
maxRows={10}
disabled={feedbackWaiting}
/>
</div>
<Textarea
placeholder="여기에 답을 적어주세요"
value={answer}
onChange={(e) => handleAnswerChange(e.target.value)}
minRows={10}
rows={10}
maxRows={10}
disabled={feedbackWaiting}
/>
<div className="row-span-1 flex flex-col-reverse" >
<InterviewController
onQuit={quit}
Expand Down
5 changes: 3 additions & 2 deletions frontend/src/components/InterviewForm/useInterviewForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ interface InterviewForm {
export const useInterviewForm = (interviewId: number) => {

const navigate = useNavigate();
const {interview, refetch, error} = useInterviewQuestionLoadQuery(interviewId);
const {interview, refetch, error, isLoading: interviewLoading} = useInterviewQuestionLoadQuery(interviewId);
const interviewSubmitMutation = useInterviewSubmitMutation();

const answerFeedbackMutation = useAnswerFeedbackMutation();
Expand Down Expand Up @@ -228,9 +228,10 @@ export const useInterviewForm = (interviewId: number) => {

return {
interview,
interviewLoading,
handleSubmit,
handlePass,
feedbackWaiting: answerFeedbackMutation.isPending,
feedbackWaiting: answerFeedbackMutation.isPending || (interviewSubmitMutation.isPending || tailQuestionSubmitMutation.isPending),
remainTailQuestionCount: interviewForm.remainTailQuestionCount,
chatList: interviewForm.chatList,
answer: interviewForm.answer,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,14 @@ import UserChat from "@/components/Chat/UserChat";
import {Chat} from "@/types/question";
import {useCallback, useEffect, useRef} from "react";


interface InterviewQuestionBoardProps {
question: string;
remainTailQuestionCount: number;
chatList: Chat[]
chatList: Chat[],
isLoading: boolean;
}

const InterviewQuestionBoard = ({question, remainTailQuestionCount, chatList}: InterviewQuestionBoardProps) => {

const InterviewQuestionBoard = ({question, remainTailQuestionCount, chatList, isLoading}: InterviewQuestionBoardProps) => {
const scrollRef = useRef<HTMLDivElement>(null);

useEffect(() => {
Expand All @@ -38,7 +37,7 @@ const InterviewQuestionBoard = ({question, remainTailQuestionCount, chatList}: I
return (
<div className="max-w-full min-w-full ">
<div className='row-span-4 col-auto'>
<p className='text-3xl'>{question}</p>
<p className='text-3xl'>{isLoading ? "질문을 가져옵니다....": question}</p>
<TailQuestionMessage/>


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ import {loadByCurrentInterviewQuestion} from "@/api/interview/LoadByCurrentInter

export const useInterviewQuestionLoadQuery = (interviewId: number) => {
// TODO: 변수명 바꾸기
const {data: interview, refetch, error} = useSuspenseQuery({
const {data: interview, refetch, error, isFetching} = useSuspenseQuery({
queryKey: ['loadInterviewQuestion', interviewId],
queryFn: () => loadByCurrentInterviewQuestion(interviewId),
gcTime: 60 * 60 * 10,
staleTime: 60* 60 * 10
});

return {interview, refetch, error}
return {interview, refetch, error, isLoading: isFetching}
}


Expand Down

0 comments on commit 5ba30d7

Please sign in to comment.