-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Feat] CompletePage 사용자 만족도 조사 추가 (#343)
* design: 설문조사 박스 구현 * feat: 클릭 시 효과 * fix: 영역 좁히도록 수정 * feat: 점수 클릭 후 렌더링 상태 변경 * design: 애니메이션 추가 * feat: postSatisfaction API 연결 * fix: 코드리뷰 반영 및 전체width 확장 * fix: interface naming 통일 * feat: onSuccess 추가 * chore: 테스트용 코드 복구
- Loading branch information
Showing
6 changed files
with
200 additions
and
6 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import tokenInstance from '@apis/tokenInstance'; | ||
|
||
export const postSatisfaction = (satisfaction: number) => { | ||
return tokenInstance.post('/recruiting-applicant/satisfaction', { | ||
satisfaction, | ||
}); | ||
}; |
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,50 @@ | ||
import { useState } from 'react'; | ||
|
||
import useMutateSatisfaction from '../hooks/useMutateSatisfaction'; | ||
import { pointBoxVar, pointContainerVar, surveyBox, thanksTextVar } from '../style.css'; | ||
|
||
const Survey = () => { | ||
const [point, setPoint] = useState<number | 'CHANGED'>(-1); | ||
|
||
const handleSatisfaction = () => { | ||
setTimeout(() => { | ||
setPoint('CHANGED'); | ||
}, 200); | ||
setTimeout(() => { | ||
setPoint(-1); | ||
}, 2200); | ||
}; | ||
|
||
const { mutate } = useMutateSatisfaction({ onSuccess: handleSatisfaction }); | ||
|
||
const handleClickPoint = (i: number) => { | ||
if (point === 'CHANGED') return; | ||
mutate({ satisfaction: i }); | ||
setPoint(i); | ||
}; | ||
|
||
return ( | ||
<div className={surveyBox}> | ||
<span | ||
style={{ | ||
textAlign: 'center', | ||
whiteSpace: 'pre-line', | ||
}}>{`지원서 이용 만족도를 0-10점 중에 선택해주세요.\n의견을 주시면 프로덕트 개선에 도움이 됩니다.`}</span> | ||
<div style={{ position: 'relative', width: 348, height: 36 }}> | ||
<span className={thanksTextVar[point === 'CHANGED' ? 'in' : 'out']}>소중한 의견 감사합니다 :)</span> | ||
<ul className={pointContainerVar[point !== 'CHANGED' ? 'in' : 'out']}> | ||
{Array.from({ length: 11 }, (_, i) => i).map((v) => ( | ||
<li | ||
key={v} | ||
className={pointBoxVar[point === 'CHANGED' ? 'changed' : v === point ? 'selected' : 'default']} | ||
onClick={() => handleClickPoint(v)}> | ||
<span style={{ paddingTop: 5 }}>{v}</span> | ||
</li> | ||
))} | ||
</ul> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default Survey; |
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,22 @@ | ||
import { useMutation } from '@tanstack/react-query'; | ||
import { AxiosError, AxiosResponse } from 'axios'; | ||
|
||
import { ErrorResponse } from '@type/errorResponse'; | ||
|
||
import { postSatisfaction } from '../apis'; | ||
import { PostSatisfactionRequest, PostSatisfactionResponse } from '../types'; | ||
|
||
const useMutateSatisfaction = ({ onSuccess }: { onSuccess?: () => void }) => { | ||
const { mutate } = useMutation< | ||
AxiosResponse<PostSatisfactionResponse, PostSatisfactionRequest>, | ||
AxiosError<ErrorResponse, PostSatisfactionRequest>, | ||
PostSatisfactionRequest | ||
>({ | ||
mutationFn: ({ satisfaction }) => postSatisfaction(satisfaction), | ||
onSuccess, | ||
}); | ||
|
||
return { mutate }; | ||
}; | ||
|
||
export default useMutateSatisfaction; |
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
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,8 @@ | ||
export interface PostSatisfactionRequest { | ||
satisfaction: number; | ||
} | ||
|
||
export interface PostSatisfactionResponse { | ||
err: boolean; | ||
userMessage: string; | ||
} |