Skip to content

Commit 7f7ebb0

Browse files
authored
Merge pull request #207 from EntryDSM/fix/206-성적-산출-수정
fix : 성적산출 종합세트
2 parents c784243 + 10210ac commit 7f7ebb0

15 files changed

Lines changed: 473 additions & 197 deletions

File tree

apps/Admission-LTS/src/pages/score/ScoreSecond.tsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,17 @@
1-
import { useState, useEffect } from 'react';
1+
import { useState } from 'react';
22
import { Flex } from '@entry/design-token';
33
import { GradeManager, usePageData } from '@entry/ui';
44

55
export const ScoreSecond = () => {
6-
const subjects = ['국어', '사회', '역사', '수학', '과학', '기술 · 가정', '영어'];
6+
const subjects = [
7+
'국어',
8+
'사회',
9+
'역사',
10+
'수학',
11+
'과학',
12+
'기술 · 가정',
13+
'영어',
14+
];
715
const [globalGrade, setGlobalGrade] = useState<string | null>(null);
816
const [subjectGrades, setSubjectGrades] = usePageData('secondGraduate');
917

apps/Admission-LTS/src/pages/score/ScoreThird.tsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,17 @@
1-
import { useState, useEffect } from 'react';
1+
import { useState } from 'react';
22
import { Flex } from '@entry/design-token';
33
import { GradeManager, usePageData } from '@entry/ui';
44

55
export const ScoreThird = () => {
6-
const subjects = ['국어', '사회', '역사', '수학', '과학', '기술 · 가정', '영어'];
6+
const subjects = [
7+
'국어',
8+
'사회',
9+
'역사',
10+
'수학',
11+
'과학',
12+
'기술 · 가정',
13+
'영어',
14+
];
715
const [globalGrade, setGlobalGrade] = useState<string | null>(null);
816

917
const [subjectGrades, setSubjectGrades] = usePageData('thirdGraduate');

apps/entry-user/src/Router.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,15 +90,15 @@ export const Router = createBrowserRouter([
9090
},
9191
{
9292
path: 'graduated/third1',
93-
element: <ScoreThird />,
93+
element: <ScoreSecond />,
9494
},
9595
{
9696
path: 'graduated/second2',
97-
element: <ScoreSecond />,
97+
element: <ScoreFirst />,
9898
},
9999
{
100100
path: 'graduated/second1',
101-
element: <ScoreSecond />,
101+
element: <ScoreThird />,
102102
},
103103
{
104104
path: 'graduated/activity',

apps/entry-user/src/components/ScoreResultModal.tsx

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,11 @@ import { useCalculationData } from '../contexts/CalculationDataContext';
55
import { calculateScore } from '../apis/calculator';
66
import { transformCalculationDataToAPI } from '../utils/apiDataTransformer';
77
import { useState, useEffect } from 'react';
8-
import { ADMISSION_TYPE_LABEL, ADMISSION_TYPE_MAX_SCORE, ADMISSION_TYPE_MAX_SCORE_GED } from '../constants/admissionType';
8+
import {
9+
ADMISSION_TYPE_LABEL,
10+
ADMISSION_TYPE_MAX_SCORE,
11+
ADMISSION_TYPE_MAX_SCORE_GED,
12+
} from '../constants/admissionType';
913

1014
interface ScoreResultModalProps {
1115
isOpen: boolean;
@@ -18,7 +22,10 @@ interface ScoreResult {
1822
total: string;
1923
}
2024

21-
export const ScoreResultModal = ({ isOpen, onClose }: ScoreResultModalProps) => {
25+
export const ScoreResultModal = ({
26+
isOpen,
27+
onClose,
28+
}: ScoreResultModalProps) => {
2229
const { state } = useCalculationData();
2330
const [results, setResults] = useState<ScoreResult[]>([]);
2431
const [loading, setLoading] = useState(false);
@@ -37,13 +44,14 @@ export const ScoreResultModal = ({ isOpen, onClose }: ScoreResultModalProps) =>
3744
const socialRequest = transformCalculationDataToAPI(state, 'SOCIAL');
3845
const meisterRequest = transformCalculationDataToAPI(state, 'MEISTER');
3946

40-
const educationalStatus = commonRequest.educationalStatus;
47+
const educationalStatus = commonRequest.educanalStatus;
4148

42-
const [commonResponse, socialResponse, meisterResponse] = await Promise.all([
43-
calculateScore(commonRequest),
44-
calculateScore(socialRequest),
45-
calculateScore(meisterRequest),
46-
]);
49+
const [commonResponse, socialResponse, meisterResponse] =
50+
await Promise.all([
51+
calculateScore(commonRequest),
52+
calculateScore(socialRequest),
53+
calculateScore(meisterRequest),
54+
]);
4755

4856
const maxScore =
4957
educationalStatus === 'QUALIFICATION_EXAM'
@@ -54,18 +62,18 @@ export const ScoreResultModal = ({ isOpen, onClose }: ScoreResultModalProps) =>
5462
{
5563
name: ADMISSION_TYPE_LABEL.COMMON,
5664
score: commonResponse.data.totalScore.toFixed(3),
57-
total: maxScore.COMMON.toString()
65+
total: maxScore.COMMON.toString(),
5866
},
5967
{
6068
name: ADMISSION_TYPE_LABEL.SOCIAL,
6169
score: socialResponse.data.totalScore.toFixed(3),
62-
total: maxScore.SOCIAL.toString()
70+
total: maxScore.SOCIAL.toString(),
6371
},
6472
{
6573
name: ADMISSION_TYPE_LABEL.MEISTER,
6674
score: meisterResponse.data.totalScore.toFixed(3),
67-
total: maxScore.MEISTER.toString()
68-
}
75+
total: maxScore.MEISTER.toString(),
76+
},
6977
];
7078

7179
setResults(newResults);
@@ -81,7 +89,7 @@ export const ScoreResultModal = ({ isOpen, onClose }: ScoreResultModalProps) =>
8189
}, [isOpen, state]);
8290

8391
if (!isOpen) return null;
84-
92+
8593
return (
8694
<ModalOverlay onClick={onClose}>
8795
<ModalContainer onClick={(e) => e.stopPropagation()}>
@@ -131,9 +139,7 @@ export const ScoreResultModal = ({ isOpen, onClose }: ScoreResultModalProps) =>
131139

132140
{/* 닫기 버튼 */}
133141
<ButtonWrapper>
134-
<Button onClick={onClose}>
135-
닫기
136-
</Button>
142+
<Button onClick={onClose}>닫기</Button>
137143
</ButtonWrapper>
138144
</ModalContainer>
139145
</ModalOverlay>

apps/entry-user/src/contexts/CalculationDataContext.tsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,13 @@ interface CalculationState {
4141
primarySecond: IScoreType;
4242
primaryFirst: IScoreType;
4343
primaryActivity: IActivityType;
44-
44+
4545
graduatedThird2: IScoreType;
4646
graduatedThird1: IScoreType;
4747
graduatedSecond2: IScoreType;
4848
graduatedSecond1: IScoreType;
4949
graduatedActivity: IActivityType;
50-
50+
5151
qeScore: IQEScoreType;
5252
qeActivity: IActivityType;
5353
}
@@ -97,7 +97,7 @@ const initialState: CalculationState = {
9797
dsmAlgorithm: null,
9898
infoProcessing: null,
9999
},
100-
100+
101101
graduatedThird2: {
102102
kor: null,
103103
soc: null,
@@ -143,7 +143,7 @@ const initialState: CalculationState = {
143143
dsmAlgorithm: null,
144144
infoProcessing: null,
145145
},
146-
146+
147147
qeScore: {
148148
korean: '',
149149
social: '',
@@ -307,7 +307,9 @@ export const useCalculationData = () => {
307307
return context;
308308
};
309309

310-
export const useCalculationPageData = <T extends keyof CalculationState>(page: T) => {
310+
export const useCalculationPageData = <T extends keyof CalculationState>(
311+
page: T
312+
) => {
311313
const { state, updatePageData } = useCalculationData();
312314

313315
const pageData = state[page];

apps/entry-user/src/pages/calculate/Activity.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { useState } from 'react';
21
import { useLocation } from 'react-router-dom';
32
import styled from '@emotion/styled';
43
import { Text } from '@entry/design-token';
@@ -30,7 +29,10 @@ const GridContainer = styled.div`
3029
export const Activity = () => {
3130
const location = useLocation();
3231

33-
const getDataKey = (): 'primaryActivity' | 'graduatedActivity' | 'qeActivity' => {
32+
const getDataKey = ():
33+
| 'primaryActivity'
34+
| 'graduatedActivity'
35+
| 'qeActivity' => {
3436
if (location.pathname.includes('primary')) return 'primaryActivity';
3537
if (location.pathname.includes('graduated')) return 'graduatedActivity';
3638
if (location.pathname.includes('qe')) return 'qeActivity';
@@ -156,4 +158,4 @@ export const Activity = () => {
156158
</Section>
157159
</Container>
158160
);
159-
};
161+
};

apps/entry-user/src/pages/calculate/GraduatedCalculationPage.tsx

Lines changed: 58 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,35 @@
11
import { useState } from 'react';
22
import { Flex, Text } from '@entry/design-token';
33
import { Button } from '@entry/ui';
4-
import { ScoreThird, ScoreSecond, ScoreFirst, Activity } from './';
4+
import { ScoreThird, ScoreSecond, Activity } from './';
55
import { useCalculationData } from '../../contexts/CalculationDataContext';
66
import { calculateScore } from '../../apis/calculator';
77
import { transformCalculationDataToAPI } from '../../utils/apiDataTransformer';
88
import { CalculatorScoreResponse } from '../../apis/calculator/types';
9-
import { ADMISSION_TYPE_LABEL, ADMISSION_TYPE_MAX_SCORE, AdmissionType } from '../../constants/admissionType';
9+
import {
10+
ADMISSION_TYPE_LABEL,
11+
ADMISSION_TYPE_MAX_SCORE,
12+
AdmissionType,
13+
} from '../../constants/admissionType';
1014

1115
const STEPS = [
1216
{ key: 'third2', label: '3학년 2학기' },
1317
{ key: 'third1', label: '3학년 1학기' },
1418
{ key: 'second2', label: '2학년 2학기' },
1519
{ key: 'second1', label: '2학년 1학기' },
16-
{ key: 'activity', label: '출석 및 봉사' }
20+
{ key: 'activity', label: '출석 및 봉사' },
1721
];
1822

1923
export const GraduatedCalculationPage = () => {
2024
const [currentStep, setCurrentStep] = useState(0);
2125
const [showResultModal, setShowResultModal] = useState(false);
22-
const [results, setResults] = useState<{ name: string; type: AdmissionType; data: CalculatorScoreResponse['data'] }[]>([]);
26+
const [results, setResults] = useState<
27+
{
28+
name: string;
29+
type: AdmissionType;
30+
data: CalculatorScoreResponse['data'];
31+
}[]
32+
>([]);
2333
const [isLoading, setIsLoading] = useState(false);
2434
const [error, setError] = useState<string | null>(null);
2535
const { state } = useCalculationData();
@@ -45,16 +55,29 @@ export const GraduatedCalculationPage = () => {
4555
const socialRequest = transformCalculationDataToAPI(state, 'SOCIAL');
4656
const meisterRequest = transformCalculationDataToAPI(state, 'MEISTER');
4757

48-
const [commonResponse, socialResponse, meisterResponse] = await Promise.all([
49-
calculateScore(commonRequest),
50-
calculateScore(socialRequest),
51-
calculateScore(meisterRequest),
52-
]);
58+
const [commonResponse, socialResponse, meisterResponse] =
59+
await Promise.all([
60+
calculateScore(commonRequest),
61+
calculateScore(socialRequest),
62+
calculateScore(meisterRequest),
63+
]);
5364

5465
setResults([
55-
{ name: ADMISSION_TYPE_LABEL.COMMON, type: 'COMMON', data: commonResponse.data },
56-
{ name: ADMISSION_TYPE_LABEL.SOCIAL, type: 'SOCIAL', data: socialResponse.data },
57-
{ name: ADMISSION_TYPE_LABEL.MEISTER, type: 'MEISTER', data: meisterResponse.data },
66+
{
67+
name: ADMISSION_TYPE_LABEL.COMMON,
68+
type: 'COMMON',
69+
data: commonResponse.data,
70+
},
71+
{
72+
name: ADMISSION_TYPE_LABEL.SOCIAL,
73+
type: 'SOCIAL',
74+
data: socialResponse.data,
75+
},
76+
{
77+
name: ADMISSION_TYPE_LABEL.MEISTER,
78+
type: 'MEISTER',
79+
data: meisterResponse.data,
80+
},
5881
]);
5982
setShowResultModal(true);
6083
} catch (err: any) {
@@ -98,15 +121,28 @@ export const GraduatedCalculationPage = () => {
98121
width="32px"
99122
height="32px"
100123
borderRadius="50%"
101-
backgroundColor={index === currentStep ? "#FF6B35" : index < currentStep ? "#FF6B35" : "#E5E5E5"}
124+
backgroundColor={
125+
index === currentStep
126+
? '#FF6B35'
127+
: index < currentStep
128+
? '#FF6B35'
129+
: '#E5E5E5'
130+
}
102131
justifyContent="center"
103132
alignItems="center"
104133
>
105-
<Text fontSize={14} fontWeight={600} color={index <= currentStep ? "#FFFFFF" : "#999"}>
134+
<Text
135+
fontSize={14}
136+
fontWeight={600}
137+
color={index <= currentStep ? '#FFFFFF' : '#999'}
138+
>
106139
{index + 1}
107140
</Text>
108141
</Flex>
109-
<Text fontSize={14} fontWeight={index === currentStep ? 600 : 400}>
142+
<Text
143+
fontSize={14}
144+
fontWeight={index === currentStep ? 600 : 400}
145+
>
110146
{step.label}
111147
</Text>
112148
{index < STEPS.length - 1 && (
@@ -117,7 +153,7 @@ export const GraduatedCalculationPage = () => {
117153
</Flex>
118154
</Flex>
119155

120-
<Flex flex={1} paddingY="40px" width="100%">
156+
<Flex flex={'1'} paddingTop="40px" width="100%">
121157
{renderStepContent()}
122158
</Flex>
123159

@@ -131,15 +167,13 @@ export const GraduatedCalculationPage = () => {
131167
>
132168
이전
133169
</Button>
134-
170+
135171
{currentStep === STEPS.length - 1 ? (
136172
<Button onClick={handleComplete} isBlocked={isLoading}>
137173
{isLoading ? '계산 중...' : '완료'}
138174
</Button>
139175
) : (
140-
<Button onClick={handleNext}>
141-
다음
142-
</Button>
176+
<Button onClick={handleNext}>다음</Button>
143177
)}
144178
</Flex>
145179

@@ -178,18 +212,17 @@ export const GraduatedCalculationPage = () => {
178212
<Flex key={index} justifyContent="space-between">
179213
<Text>{result.name}</Text>
180214
<Text color="#FF6B35" fontWeight={600}>
181-
{result.data.totalScore.toFixed(3)} / {ADMISSION_TYPE_MAX_SCORE[result.type]}
215+
{result.data.totalScore.toFixed(3)} /{' '}
216+
{ADMISSION_TYPE_MAX_SCORE[result.type]}
182217
</Text>
183218
</Flex>
184219
))}
185220
</Flex>
186221

187-
<Button onClick={() => setShowResultModal(false)}>
188-
닫기
189-
</Button>
222+
<Button onClick={() => setShowResultModal(false)}>닫기</Button>
190223
</Flex>
191224
</Flex>
192225
)}
193226
</Flex>
194227
);
195-
};
228+
};

0 commit comments

Comments
 (0)