Skip to content

Commit

Permalink
✨ feat: default 언어 레벨 수정(7.11~13) #73
Browse files Browse the repository at this point in the history
  • Loading branch information
hyeona01 committed Oct 31, 2024
1 parent de5bc1c commit ff17612
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 18 deletions.
5 changes: 4 additions & 1 deletion src/api/resumes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
EducationRequest,
IntroDuctionRequest,
LanguagesLevelType,
LanguagesSummariesResponse,
UserResumeDetailResponse,
WorkExperienctRequest,
} from '@/types/api/resumes';
Expand Down Expand Up @@ -32,7 +33,9 @@ export const getEducation = async (id: number) => {
};

// 7.4 언어 요약 조회하기
export const getLanguagesSummaries = async () => {
export const getLanguagesSummaries = async (): Promise<
RESTYPE<LanguagesSummariesResponse>
> => {
const response = await api.get('/users/resumes/languages/summaries');
return response.data;
};
Expand Down
3 changes: 2 additions & 1 deletion src/components/Language/LanguageCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const LanguageCard = ({

const goToWebSite = [
{
language: 'TOPIC',
language: 'TOPIK',
site: 'https://www.topik.go.kr/TWMAIN/TWMAIN0010.do',
},
{
Expand All @@ -54,6 +54,7 @@ const LanguageCard = ({

// 현재 title과 일치하는 사이트 URL 찾기
const siteInfo = goToWebSite.find((item) => item.language === title);
console.log(level);

return (
<>
Expand Down
35 changes: 21 additions & 14 deletions src/components/Language/LanguageSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,16 @@ import { useGetLanguagesSummaries } from '@/hooks/api/useResume';
const LanguageSection = () => {
const { data } = useGetLanguagesSummaries();
const navigage = useNavigate();

// 언어 레벨 리스트 상태 관리
const [languageData, SetLanguageData] =
useState<LanguagesSummariesResponse>();

// 7.4 (유학생) 언어 요약 조회하기
useEffect(() => {
SetLanguageData(data);
if (data) {
SetLanguageData(data.data);
}
}, [data]);

return (
Expand All @@ -22,15 +27,16 @@ const LanguageSection = () => {
<h1 className="head-2 text-[#1e1926 py-6">Language</h1>
<div className="w-full flex justify-end gap-3 items-center pb-6 pr-2">
<div className="body-2 text-[#1e1926">Add</div>
{/* 언어 추가 화면 이동 */}
<AddIcon
onClick={() => navigage('/resume/language/add')}
className="cursor-pointer"
/>
</div>
<div className="flex flex-col gap-4 mb-14">
{/* TOPIC */}
{/* TOPIK */}
<LanguageCard
title="TOPIC"
title="TOPIK"
description="default"
level={languageData.topik_level}
isAdditionalLanguage={false}
Expand All @@ -53,17 +59,18 @@ const LanguageSection = () => {
maxLevel={6}
/>
{/* 별도의 언어 추가 카드 */}
{languageData.additional_language.map((language) => (
<div key={language.id}>
<LanguageCard
title={language.language_name}
description="add"
level={language.level}
isAdditionalLanguage={true}
maxLevel={10}
/>
</div>
))}
{languageData.additional_language?.length > 0 &&
languageData.additional_language.map((language) => (
<div key={language.id}>
<LanguageCard
title={language.language_name}
description="add"
level={language.level}
isAdditionalLanguage={true}
maxLevel={10}
/>
</div>
))}
</div>
</div>
) : (
Expand Down
3 changes: 3 additions & 0 deletions src/hooks/api/useResume.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ export const usePatchLanguagesLevel = ({
}) => {
return useMutation({
mutationFn: () => patchLanguagesLevel({ type, level }),
onSuccess: () => {
window.location.reload();
},
onError: (error) => {
console.error('언어 레벨 수정 실패', error);
},
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/api/useSetting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export const usePatchNotificationAllowed = () => {
return useMutation({
mutationFn: patchNotificationAllowed,
onSuccess: () => {
window.location.reload;
window.location.reload();
},
onError: (error) => {
console.error('알람 설정 변경 실패', error);
Expand Down
2 changes: 1 addition & 1 deletion src/types/api/resumes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export type EducationRequest = {

// 언어 레벨 수정 API 통합시 type property로 사용
export type LanguagesLevelType =
| 'topic'
| 'topik'
| 'social-integration-program'
| 'sejong-institute';

Expand Down

0 comments on commit ff17612

Please sign in to comment.