Skip to content

Commit 4125e30

Browse files
authored
Merge pull request #89 from Team-INSERT/feat/meister
마이스터 역량 인증제 페이지 완성
2 parents 84d78c2 + 90e32b8 commit 4125e30

23 files changed

+954
-345
lines changed

src/apis/httpClient/httpClient.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,13 @@ export class HttpClient {
3333
return this.api.get("", { ...HttpClient.clientConfig, ...requestConfig });
3434
}
3535

36+
getDetail(data: unknown, requestConfig?: AxiosRequestConfig) {
37+
return this.api.post("/detail", data, {
38+
...HttpClient.clientConfig,
39+
...requestConfig,
40+
});
41+
}
42+
3643
getById(requestConfig?: AxiosRequestConfig) {
3744
return this.api.get("/:id", {
3845
...HttpClient.clientConfig,
@@ -171,4 +178,6 @@ export default {
171178
meal: new HttpClient("api/meal", axiosConfig),
172179
calender: new HttpClient("api/calender", axiosConfig),
173180
reserve: new HttpClient("api/ber", axiosConfig),
181+
meister: new HttpClient("api/meister", axiosConfig),
182+
ranking: new HttpClient("api/meister/ranking", axiosConfig),
174183
};

src/assets/data/emptyMeister.ts

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import IMeister from "@/interfaces/meister.interface";
2+
3+
const emptyMeister: IMeister = {
4+
meister: {
5+
score: 0,
6+
positivePoint: 0,
7+
negativePoint: 0,
8+
lastUpdate: "2000-03-01T00:00:00.000000",
9+
loginError: false,
10+
basicJobSkills: 0,
11+
professionalTech: 0,
12+
workEthic: 0,
13+
humanities: 0,
14+
foreignScore: 0,
15+
},
16+
avg: {
17+
score: 0,
18+
basicJobSkills: 0,
19+
professionalTech: 0,
20+
workEthic: 0,
21+
humanities: 0,
22+
foreignScore: 0,
23+
positivePoint: 0,
24+
negativePoint: 0,
25+
},
26+
max: {
27+
score: 0,
28+
basicJobSkills: 0,
29+
professionalTech: 0,
30+
workEthic: 0,
31+
humanities: 0,
32+
foreignScore: 0,
33+
positivePoint: 0,
34+
negativePoint: 0,
35+
},
36+
};
37+
38+
export default emptyMeister;

src/constants/key.constant.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ const KEY = {
99
MEAL: "useMeal",
1010
CALENDER: "useCalender",
1111
RESERVE: "useReserve",
12+
MEISTER: "useMeister",
13+
MEISTER_DETAIL: "useMeisterDetail",
14+
RANKING: "useRanking",
1215
} as const;
1316

1417
export default KEY;
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
const getMeisterChapter = (chapter: string) => {
2+
switch (chapter) {
3+
case "professionalTech":
4+
return "전문 기술 역량";
5+
case "workEthic":
6+
return "인성 직업 의식";
7+
case "humanities":
8+
return "인문학적 소양";
9+
case "foreignScore":
10+
return "외국어 능력";
11+
default:
12+
return chapter;
13+
}
14+
};
15+
16+
export default getMeisterChapter;

src/helpers/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@ export { default as getMealName } from "./getMealName.helper";
1212
export { default as getTimetableType } from "./getTimetableType.helper";
1313
export { default as getDay } from "./getDay.helper";
1414
export { default as getClassName } from "./getClassName.helper";
15+
export { default as getMeisterChapter } from "./getMeisterChapter.helper";

src/hooks/useDidMountEffect.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { useRef, useEffect } from "react";
2+
3+
export const useDidMountEffect = (
4+
func: () => void,
5+
deps: React.DependencyList,
6+
) => {
7+
const didMount = useRef(false);
8+
9+
useEffect(() => {
10+
if (didMount.current) func();
11+
else didMount.current = true;
12+
}, deps);
13+
};

src/hooks/useMeisterHTML.ts

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
import { color } from "@/styles";
2+
3+
// 심신미약자나 노약자, 임산부, 유아는 코드를 읽는 것을 삼가하기바람
4+
5+
export const useMeisterHTML = () => {
6+
const getBasicJobSkills = (html: string) => {
7+
return [
8+
{
9+
title: "의사소통 국어",
10+
value: +html.substring(
11+
html.lastIndexOf("의사소통(국어) : ") + 11,
12+
html.lastIndexOf("의사소통(국어) : ") + 12,
13+
),
14+
status: color.primary_blue,
15+
},
16+
{
17+
title: "의사소통 영어",
18+
value: +html.substring(
19+
html.lastIndexOf("의사소통(영어) : ") + 11,
20+
html.lastIndexOf("의사소통(영어) : ") + 12,
21+
),
22+
status: color.primary_mint,
23+
},
24+
{
25+
title: "수리 활용",
26+
value: +html.substring(
27+
html.lastIndexOf("수리활용 : ") + 7,
28+
html.lastIndexOf("수리활용 : ") + 8,
29+
),
30+
status: color.primary_red,
31+
},
32+
{
33+
title: "문제 해결",
34+
value: +html.substring(
35+
html.lastIndexOf("문제해결 : ") + 7,
36+
html.lastIndexOf("문제해결 : ") + 8,
37+
),
38+
status: color.primary_yellow,
39+
},
40+
];
41+
};
42+
43+
const scoreParser = (html: string) => {
44+
const parsedHTML = html;
45+
return (
46+
parsedHTML
47+
.replaceAll(
48+
'<div>[ <span style="font-weight:bold; color:blue;">',
49+
(match) => {
50+
return `<section class="list-item">${match}`;
51+
},
52+
)
53+
.replace(/\[ (\d{4}-\d{2}-\d{2}) \]/g, (match) => {
54+
return `<br>
55+
<hgroup class="section-date">
56+
${match
57+
.replaceAll("[ ", "")
58+
.replaceAll(" ]", "")
59+
.replace("-", "년 ")
60+
.replace("-", "월 ")}일</hgroup></section>`;
61+
})
62+
.replaceAll("- 시도와 전국은 중복부여 안함", "")
63+
.replace(/[-].*?: -<br>/gi, "")
64+
.replace(/[-].*?: -/gi, "")
65+
.replace(/\([^)]*\)/gi, "")
66+
.replace(/\s+([\d.]+)\s*/gi, (match) => {
67+
return `<span class="total-score-item">${match}</span>`;
68+
})
69+
.replace(/ \d+ /gi, (match) => {
70+
return `<span class="item-score" >${match.replaceAll(
71+
" ",
72+
"",
73+
)}</span>`;
74+
})
75+
.replaceAll(
76+
'[ <span style="font-weight:bold; color:red;">종합</span> ]',
77+
"",
78+
)
79+
.replaceAll(",", "")
80+
.replaceAll("font-weight:bold; color:blue;", "")
81+
.replaceAll(
82+
'⑥ 헌혈 : <span style="font-weight:bold;">0 점</span> ( 총 : 시간 )<br>',
83+
"",
84+
)
85+
.replaceAll(
86+
'⑧ 스포츠관련 행사 : <span style="font-weight:bold;"> 점</span> ( 총 : 0 건 )<br>',
87+
"",
88+
)
89+
.replaceAll(
90+
'⑬ 직업관련 교육 : <span style="font-weight:bold;"> 점</span> ( 총 : 0 건 )<br>',
91+
"",
92+
)
93+
.replaceAll(
94+
'⑪ 체육/음악 관련 대회 : <span style="font-weight:bold;">0 점</span> - 시도와 전국은 중복부여 안함 (최고 득점 1개만 적용)<br>',
95+
"",
96+
)
97+
.replaceAll("font-weight:bold;", "")
98+
.replaceAll(
99+
'⑪ 체육/음악 관련 대회 : <span style="font-weight:bold;"> 점</span> - 시도와 전국은 중복부여 안함 (최고 득점 1개만 적용)<br>',
100+
"",
101+
)
102+
.replace(/[-]/gi, "")
103+
// .replaceAll(":", "·")
104+
.replaceAll(
105+
'[ <span style="font-weight:bold; color:red;">종합</span> ]',
106+
"",
107+
)
108+
.replaceAll(": 점", ": 0점")
109+
.replaceAll(": 점", ": 0점")
110+
.replaceAll("\n", "")
111+
.replaceAll("\t", "")
112+
.replaceAll(" ", "")
113+
);
114+
};
115+
116+
const pointParser = (html: string) => {
117+
return html.replaceAll(
118+
'style="border:1px solid #ccc;margin-bottom:10px;border-radius:3px;padding:10px;box-shadow: 2px 2px 1px 2px #ddd;"',
119+
"",
120+
);
121+
};
122+
123+
return { getBasicJobSkills, scoreParser, pointParser };
124+
};

src/interfaces/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,4 @@ export type { default as IPlan } from "./plan.interface";
2121
export type { default as IReserve } from "./reserve.interface";
2222
export type { default as IReserveList } from "./reserveList.interface";
2323
export type { default as ICreateReserve } from "./createReserve.interface";
24+
export type { default as IMeister } from "./meister.interface";

src/interfaces/meister.interface.ts

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
export default interface IMeister {
2+
meister: {
3+
score: number;
4+
positivePoint: number;
5+
negativePoint: number;
6+
lastUpdate: string;
7+
loginError: boolean;
8+
basicJobSkills: number;
9+
professionalTech: number;
10+
workEthic: number;
11+
humanities: number;
12+
foreignScore: number;
13+
};
14+
avg: {
15+
score: number;
16+
basicJobSkills: number;
17+
professionalTech: number;
18+
workEthic: number;
19+
humanities: number;
20+
foreignScore: number;
21+
positivePoint: number;
22+
negativePoint: number;
23+
};
24+
max: {
25+
score: number;
26+
basicJobSkills: number;
27+
professionalTech: number;
28+
workEthic: number;
29+
humanities: number;
30+
foreignScore: number;
31+
positivePoint: number;
32+
negativePoint: number;
33+
};
34+
}

0 commit comments

Comments
 (0)