diff --git a/server/app.js b/server/app.js index 1547830..6d4628a 100644 --- a/server/app.js +++ b/server/app.js @@ -6,7 +6,6 @@ import cookieParser from 'cookie-parser'; import apiRouter from './router/api'; import ssrRouter from './router/ssr'; - const __dirname = path.resolve(); const app = express(); @@ -38,7 +37,6 @@ app.use(express.static('public')); app.use('/api', apiRouter); app.use('/', ssrRouter); - app.listen(3000, () => { console.log('listen to http://localhost:3000'); }); diff --git a/server/router/api.js b/server/router/api.js index 6ddd6b2..ba5e660 100644 --- a/server/router/api.js +++ b/server/router/api.js @@ -8,21 +8,21 @@ const router = express.Router(); const upload = multer({ dest: '../uploads/' }); -const DEFAULT_HOST = 'http://ec2-15-165-61-122.ap-northeast-2.compute.amazonaws.com'; +const DEFAULT_HOST = 'http://52.79.66.109:8080'; const PREFIX = '/api/v1'; const ROOT_URL = DEFAULT_HOST + PREFIX; export function getAuthorizationCookie(req) { const accessToken = req.cookies.authorization; if (accessToken === undefined) return 'null'; - return accessToken; + return `Bearer ${accessToken}`; } export async function validateAccessToken(req) { const accessToken = getAuthorizationCookie(req); if (accessToken === undefined) return false; try { - await axios.get(`${ROOT_URL}/auth/check-atk`, { + await axios.get(`${ROOT_URL}/auth/token`, { headers: { Authorization: accessToken, }, @@ -46,22 +46,24 @@ export async function parsePDF(formData) { return response.data; } -export async function validateStudentNumber(formData) { - const response = await axios.post(`${ROOT_URL}/users/studentNumber-validity-checks`, formData); - return !response.data.isNotDuplicated; +export async function validateStudentNumber({ studentNumber }) { + const response = await axios.get( + `${ROOT_URL}/users/sign-up/check-duplicate-student-number?student-number=${studentNumber}` + ); + return !response.data.notDuplicated; } -export async function validateUserId(formData) { - const response = await axios.post(`${ROOT_URL}/users/userid-validity-checks`, formData); - return !response.data.isNotDuplicated; +export async function validateUserId({ userId }) { + const response = await axios.get(`${ROOT_URL}/users/sign-up/check-duplicate-auth-id?auth-id=${userId}`); + return !response.data.notDuplicated; } function apiErrorHandler(res, error) { - if (error.response.data.code) { + if (error.response?.data.status) { return res.status(400).json(error.response.data); } return res.status(500).json({ - code: 500, + status: 500, message: '서버에 장애가 있습니다.', }); } @@ -72,10 +74,9 @@ router.post('/file-upload', upload.single('file'), async function (req, res) { try { const pdfText = await parsePDF(formData); - const accessToken = getAuthorizationCookie(req); const response = await axios.post( - `${ROOT_URL}/users/me/taken-lectures`, + `${ROOT_URL}/parsing-text`, { parsingText: pdfText, }, @@ -93,22 +94,16 @@ router.post('/file-upload', upload.single('file'), async function (req, res) { router.post('/signin', async function (req, res) { const formData = { - userId: req.body.id, + authId: req.body.authId, password: req.body.password, }; try { const result = await axios.post(`${ROOT_URL}/auth/sign-in`, formData); - res.cookie('authorization', result.headers.authorization, { + res.cookie('authorization', `${result.data.accessToken}`, { httpOnly: true, }); - - const response = await axios.get(`${ROOT_URL}/users/me/init`, { - headers: { - Authorization: result.headers.authorization, - }, - }); - res.status(200).json({ isInit: response.data.init }); + res.status(200).json({ isInit: false }); } catch (error) { apiErrorHandler(res, error); } @@ -124,7 +119,7 @@ router.get('/signout', function (req, res) { router.post('/signup', async function (req, res) { const formData = { - userId: req.body.id, + authId: req.body.id, password: req.body.password, studentNumber: req.body.studentId, engLv: req.body.englishLevel, @@ -133,17 +128,17 @@ router.post('/signup', async function (req, res) { try { if (await validateUserId({ userId: req.body.id })) return res.status(400).json({ - code: 400, + status: 400, message: '이미 아이디가 존재합니다.', }); if (await validateStudentNumber({ studentNumber: req.body.studentId })) return res.status(400).json({ - code: 400, + status: 400, message: '이미 등록된 학번입니다.', }); - const result = await axios.post(`${ROOT_URL}/auth/sign-up`, formData); + const result = await axios.post(`${ROOT_URL}/users/sign-up`, formData); res.status(200).end(); } catch (error) { apiErrorHandler(res, error); @@ -151,12 +146,10 @@ router.post('/signup', async function (req, res) { }); router.post('/secession', async function (req, res) { - const formData = { - password: req.body.password, - }; const accessToken = getAuthorizationCookie(req); try { - const result = await axios.post(`${ROOT_URL}/users/leave`, formData, { + const result = await axios.delete(`${ROOT_URL}/users/me`, { + data: { password: req.body.password }, headers: { Authorization: accessToken, }, @@ -169,11 +162,11 @@ router.post('/secession', async function (req, res) { router.post('/userConfirm', async function (req, res) { const formData = { - userId: req.body.id, + authId: req.body.authId, studentNumber: req.body.studentNumber, }; try { - await axios.post(`${ROOT_URL}/users/pwinquiry`, formData, { + await axios.get(`${ROOT_URL}/users/${formData.studentNumber}/validate?auth-id=${formData.authId}`, formData, { headers: { 'Content-Type': 'application/json', }, @@ -195,7 +188,7 @@ router.get('/check-atk', async function (req, res) { router.get('/takenLectures', async function (req, res) { try { const accessToken = getAuthorizationCookie(req); - const result = await axios.get(`${ROOT_URL}/users/me/taken-lectures`, { + const result = await axios.get(`${ROOT_URL}/taken-lectures`, { headers: { Authorization: accessToken, }, @@ -205,26 +198,6 @@ router.get('/takenLectures', async function (req, res) { apiErrorHandler(res, error); } }); -router.get('/curriculumInfos', async function (req, res) { - try { - const lectureResult = await axios.get(`${ROOT_URL}/bachelor-info/lectures`, { - headers: { - 'Content-Type': 'application/json', - }, - params: req.query, - }); - const creditResult = await axios.get(`${ROOT_URL}/bachelor-info/requirement`, { - headers: { - // Authorization: accessToken, - 'Content-Type': 'application/json', - }, - params: req.query, - }); - res.json([creditResult.data, lectureResult.data]); - } catch (error) { - apiErrorHandler(res, error); - } -}); router.get('/search-lecture', async function (req, res) { try { @@ -236,7 +209,7 @@ router.get('/search-lecture', async function (req, res) { params: req.query, }); res.status(200).json({ - searchedLectures: response.data, + searchedLectures: response.data.lectures, }); } catch (error) { apiErrorHandler(res, error); @@ -251,7 +224,7 @@ router.post('/update-lecture', async function (req, res) { try { const accessToken = getAuthorizationCookie(req); - const result = await axios.patch(`${ROOT_URL}/users/me/taken-lectures`, formData, { + const result = await axios.post(`${ROOT_URL}/taken-lectures/update`, formData, { headers: { Authorization: accessToken, }, @@ -268,11 +241,11 @@ router.get('/myInfo', async function (req, res) { const accessToken = getAuthorizationCookie(req); if (accessToken === 'null') { res.status(500).json({ - code: 500, + status: 500, message: '서버에 장애가 있습니다.', }); } else { - const result = await axios.get(`${ROOT_URL}/users/me/information`, { + const result = await axios.get(`${ROOT_URL}/users/me`, { headers: { Authorization: accessToken, }, @@ -301,7 +274,7 @@ router.get('/graduation-result', async function (req, res) { router.get('/findId', async function (req, res) { try { const path = req._parsedUrl.query; - const response = await axios.get(`${ROOT_URL}/users/by/student-number/${path}`, { + const response = await axios.get(`${ROOT_URL}/users/${path}/auth-id`, { headers: { 'Content-Type': 'application/json', }, @@ -314,12 +287,12 @@ router.get('/findId', async function (req, res) { router.post('/findPw', async function (req, res) { const formData = { - userId: req.body.userId, + authId: req.body.authId, newPassword: req.body.newPassword, passwordCheck: req.body.passwordCheck, }; try { - const result = await axios.post(`${ROOT_URL}/users/reset-pw`, formData); + const result = await axios.patch(`${ROOT_URL}/users/password`, formData); res.status(200).end(); } catch (error) { apiErrorHandler(res, error); @@ -330,18 +303,8 @@ router.get('/check-user', async function (req, res) { const accessToken = req.cookies.authorization; if (accessToken === undefined) { res.status(400).end(); - } else { - try { - const response = await axios.get(`${ROOT_URL}/users/me/init`, { - headers: { - Authorization: accessToken, - }, - }); - res.status(200).json(response.data); - } catch (error) { - apiErrorHandler(res, error); - } } + res.status(200).json({ validToken: true, init: false }); }); export default router; diff --git a/src/async/auth.js b/src/async/auth.js index c454fe2..50dfb3c 100644 --- a/src/async/auth.js +++ b/src/async/auth.js @@ -15,10 +15,6 @@ export async function fetchSignIn(formData) { if (response.status === 200) { signIn(); - const result = await response.json(); - if (result.isInit) { - init(); - } return true; } @@ -135,31 +131,22 @@ export async function fetchValidateATK() { } export async function fetchValidateUser() { - const response = await fetch('/api/check-user'); + const response = await fetch('/api/myInfo'); if (response.status === 200) { const result = await response.json(); - - if (result.validToken) { - signIn(); - } else { - signOut(); - } - - if (result.init) { + if (!result.studentName) { init(); - } else { - unInit(); + return { init: true }; } - - return result; + unInit(); + return { init: false }; } signOut(); unInit(); return { - validToken: false, - init: false, + init: true, }; } diff --git a/src/async/file.js b/src/async/file.js index 5ed58b6..6ac167f 100644 --- a/src/async/file.js +++ b/src/async/file.js @@ -5,7 +5,6 @@ export async function fetchPDFFileUpload(formData) { method: 'POST', body: formData, }); - if (response.status === 400 || response.status === 500) { throw await makeError(response); } diff --git a/src/async/lecture.js b/src/async/lecture.js index 9b439d5..74a176e 100644 --- a/src/async/lecture.js +++ b/src/async/lecture.js @@ -10,7 +10,7 @@ export async function fetchGetSearchedLecture(query) { if (response.status === 400 || response.status === 500) { const result = await response.json(); const error = new Error(result.message); - error.code = result.code; + error.status = result.status; throw error; } @@ -45,20 +45,3 @@ export async function fetchGetTakenLectures() { const result = await response.json(); return result; } - -export async function fetchCurriculumInfos(query) { - const queryString = objectToQueryString(query); - - const response = await fetch(`/api/curriculumInfos?${queryString}`, { - headers: { - 'Content-Type': 'application/json', - }, - }); - - if (response.status === 400 || response.status === 500) { - throw await makeError(response); - } - const result = await response.json(); - - return result; -} diff --git a/src/components/GNB/GNB.component.js b/src/components/GNB/GNB.component.js index c90b5dd..e2bae12 100644 --- a/src/components/GNB/GNB.component.js +++ b/src/components/GNB/GNB.component.js @@ -60,7 +60,6 @@ export default class GNB extends Component {
결과페이지
` : `
로그인
` } -
커리큘럼
튜토리얼
팀소개
@@ -94,9 +93,6 @@ export default class GNB extends Component { this.addEvent('click', '.gnb-tutorial', () => { router.navigate('/tutorial'); }); - this.addEvent('click', '.gnb-curriculum', () => { - router.navigate('/curriculum'); - }); this.addEvent('click', '.gnb-about', () => { window.location.href = 'https://jade-sofa-1be.notion.site/7ebf97e49afe403eab8394eaec8e32a1'; }); diff --git a/src/components/category-card/category-card.component.js b/src/components/category-card/category-card.component.js index cba5cda..7e77d88 100644 --- a/src/components/category-card/category-card.component.js +++ b/src/components/category-card/category-card.component.js @@ -19,7 +19,7 @@ const [sizesAttr, srcsetAttr] = getResponseiveImage(sizes, `${IMAGE_URL}/images/ export default class CategoryCard extends Component { setDefaultProps() { this.props = { - title: '공통교양', + categoryName: '공통교양', key: 1, totalCredit: 30, takenCredit: 12, @@ -28,14 +28,14 @@ export default class CategoryCard extends Component { } hasDetails() { - const { title } = this.props; - if (title === '일반교양' || title === '자유선택' || title === '채플') return false; + const { categoryName } = this.props; + if (categoryName === '일반교양' || categoryName === '자유선택' || categoryName === '채플') return false; return true; } isChaple() { - const { title } = this.props; - if (title === '채플') return true; + const { categoryName } = this.props; + if (categoryName === '채플') return true; return false; } @@ -46,9 +46,8 @@ export default class CategoryCard extends Component { return (props) => { if (props) this.setProps(props); - const { title, totalCredit, takenCredit, key, buttonOnClick } = this.props; + const { categoryName, totalCredit, takenCredit, key, buttonOnClick } = this.props; const percentage = Math.round((takenCredit / totalCredit) * 100); - const pieChartProps = { percentage, }; @@ -66,7 +65,7 @@ export default class CategoryCard extends Component {
category-card__icon
- ${title} + ${categoryName}
diff --git a/src/components/category-info/category-info.component.js b/src/components/category-info/category-info.component.js index d2ffd42..672722a 100644 --- a/src/components/category-info/category-info.component.js +++ b/src/components/category-info/category-info.component.js @@ -3,7 +3,7 @@ import Component from '../../core/component'; export default class CategoryInfo extends Component { setDefaultProps() { this.props = { - part: '', + categoryName: '', totalCredits: '', takenCredits: '', leftCredits: '', @@ -30,11 +30,11 @@ export default class CategoryInfo extends Component { return (props) => { if (props) this.setProps(props); - const { part } = this.props; + const { categoryName } = this.props; return `
-
${part}
+
${categoryName}
${this.getCredit()}
`; diff --git a/src/components/curriculum-image/curriculum-image.component.js b/src/components/curriculum-image/curriculum-image.component.js deleted file mode 100644 index 03c4f45..0000000 --- a/src/components/curriculum-image/curriculum-image.component.js +++ /dev/null @@ -1,37 +0,0 @@ -import Component from '../../core/component'; -import { getResponseiveImage } from '../../helper/images'; -import { departmentList } from '../../helper/data'; - -const sizes = { - mobile: 486, - tablet: 624, - sm: 935, - md: 1250, - lg: 1300, -}; - -export default class CurriculumImage extends Component { - template() { - return (props) => { - if (props) this.setProps(props); - const { major } = this.props; - - const majorImage = - // eslint-disable-next-line no-nested-ternary - major && departmentList[major] === '670' - ? this.props.major === '응용소프트웨어전공' - ? 'ict_sw_application' - : 'ict_sw_data' - : departmentList[major]; - - const [sizeAttr, srcsetAttr] = getResponseiveImage(sizes, `${IMAGE_URL}/images/department/${majorImage}.png`); - - return ` -
-
전공이수로드맵
- curriculum-image__content -
- `; - }; - } -} diff --git a/src/components/curriculum-image/curriculum-image.style.scss b/src/components/curriculum-image/curriculum-image.style.scss deleted file mode 100644 index 1f61bde..0000000 --- a/src/components/curriculum-image/curriculum-image.style.scss +++ /dev/null @@ -1,11 +0,0 @@ -.curriculum-image { - width: 100%; - - &__title { - @include title4; - } - &__content { - width: 90%; - margin: 0.8rem 5%; - } -} diff --git a/src/components/curriculum-list/curriculum-list.component.js b/src/components/curriculum-list/curriculum-list.component.js deleted file mode 100644 index 53d78b1..0000000 --- a/src/components/curriculum-list/curriculum-list.component.js +++ /dev/null @@ -1,111 +0,0 @@ -import Component from '../../core/component'; -import * as utils from '../../helper/utils'; -import { detailCategoryToKorean, categoryNameToKorean } from '../../helper/parse'; - -export default class CurriculumList extends Component { - setDefaultProps() { - this.props = { - lecture: [], - }; - } - - initState() { - this.state = { - common: false, - }; - } - - isNote(partName) { - const { year } = this.props; - let text = ''; - if (this.state.common) { - text = '* 선택 1'; - } - if (partName === '기독교') { - year < 20 ? (text = '* 성서와 인간이해(필수)외 선택 1') : (text = '* 선택 2'); - } - if (partName === '영어') { - text = '* 교과목(영어, 영어회화)당 1,2 또는 3,4 이수'; - } - return text; - } - - getList(props) { - return props - .map((prop) => { - return ` -
-
${prop.name}
-
${ - prop.credit === 0 ? `0.5` : prop.credit - }학점
-
`; - }) - .join(''); - } - - getTable() { - const { common } = this.state; - const { lecture } = this.props; - return ( - lecture && - Object.values(common ? lecture[1] : lecture[0]) - .map((obj) => { - return ` -
-
${categoryNameToKorean[Object.keys(obj)[0]]}
-
- ${Object.values(obj)[0] - .map((value) => { - const partName = - value.categoryName in detailCategoryToKorean - ? detailCategoryToKorean[value.categoryName] - : value.categoryName; - return `
-
${partName}
-
${this.getList(value.lectures)}
-
${this.isNote(partName)}
-
`; - }) - .join('')} -
-
`; - }) - .join('') - ); - } - - template() { - return (props) => { - if (props) this.setProps(props); - const { common } = this.state; - const barStyle = { right: common ? '1.3rem' : '6.7rem' }; - return ` -
-
과목 정보
-
-
-
-
전필/전선/학기교
-
핵심/공통교양
-
-
-
${this.getTable()}
-
- `; - }; - } - - setEvent() { - this.addEvent('click', '.curriculum-list__content__option-major', () => { - this.setState({ common: false }); - }); - this.addEvent('click', '.curriculum-list__content__option-culture', () => { - this.setState({ common: true }); - }); - } -} diff --git a/src/components/curriculum-list/curriculum-list.style.scss b/src/components/curriculum-list/curriculum-list.style.scss deleted file mode 100644 index 35cd323..0000000 --- a/src/components/curriculum-list/curriculum-list.style.scss +++ /dev/null @@ -1,110 +0,0 @@ -.curriculum-list { - &__title { - @include title5; - } - &__content { - margin: 2rem 0; - width: 100%; - border-top: 5px solid $color-grey-scale3; - &__option { - position: relative; - top: -50px; - right: -40px; - @include mobile { - top: -30px; - } - float: right; - @include subhead4; - display: flex; - &-major { - cursor: pointer; - } - &-culture { - cursor: pointer; - margin-left: 1.5rem; - } - } - &__bar { - border-radius: 4px; - border-top: 7px solid $color-g2; - width: 2rem; - position: relative; - top: -6px; - z-index: 1; - float: right; - } - } - &__info { - &__category { - @include mobile { - width: 100%; - margin: 1.5rem 0rem; - font: smaller; - } - margin: 1.5rem 1rem; - &__categoryName { - width: fit-content; - background-color: $color-secondary; - padding: 0.33rem 1rem; - color: white; - @include title2; - margin-bottom: 0.5rem; - } - &__content { - display: flex; - flex-direction: row-reverse; - flex-wrap: wrap-reverse; - justify-content: flex-start; - &__item { - width: 45%; - margin: 0.33rem auto; - &-detailcatogory { - display: flex; - justify-content: center; - background-color: $color-g1; - padding: 0.33rem; - color: $color-g2; - @include title2; - border-radius: 1.875rem; - margin-bottom: 0.5rem; - } - &-list { - border: 1px solid rgba(0, 0, 0, 0.3); - border-radius: 1rem; - height: 8rem; - overflow: scroll; - - @include subhead3; - color: $color-title; - &__item { - display: flex; - padding: 0.33rem 0.5rem; - justify-content: space-between; - border-bottom: 1px solid rgba(0, 0, 0, 0.1); - &-name { - width: 75%; - } - &-credit { - color: $color-grey-scale4; - } - } - &__item:last-child { - border-bottom: 0px; - } - } - &-list::-webkit-scrollbar { - display: none; /* Chrome, Safari, Opera*/ - } - &-notice { - @include subhead3; - color: $color-grey-scale4; - padding: 0.2rem 0.5rem; - @include mobile { - font: smaller; - } - } - } - } - } - } -} diff --git a/src/components/curriculum-more/curriculum-more.component.js b/src/components/curriculum-more/curriculum-more.component.js deleted file mode 100644 index b5d88bc..0000000 --- a/src/components/curriculum-more/curriculum-more.component.js +++ /dev/null @@ -1,65 +0,0 @@ -import Component from '../../core/component'; -import { getResponseiveImage } from '../../helper/images'; -import Button from '../button/button.component'; -import { buttonTypes } from '../../helper/types'; -import { departmentList } from '../../helper/data'; - -const sizes = { - mobile: 130, - tablet: 130, - sm: 178, - md: 178, - lg: 238, -}; -const [sizeAttr, srcsetAttr] = getResponseiveImage(sizes, `${IMAGE_URL}/images/maru_upperbody.png`); - -export default class CurriculumMore extends Component { - template() { - const styleOption = { - background: '#F5F5F5', - color: 'black', - }; - const majorPageButton = this.addChild(Button); - const guideButton = this.addChild(Button); - const majorPageButtonProps = { - content: '전공홈페이지로 이동', - type: buttonTypes.primary, - size: 'md', - key: 'majorpageButton', - styleOption, - }; - const guideButtonProps = { - content: '학사안내문으로 이동', - type: buttonTypes.primary, - size: 'md', - key: 'guideButton', - styleOption, - }; - return (props) => { - if (props) this.setProps(props); - return ` -
- curriculum-more__img -
-
-
학과 관련 정보
-
더 확인하고 싶다면 클릭!
-
- -
-
- `; - }; - } -} diff --git a/src/components/curriculum-more/curriculum-more.style.scss b/src/components/curriculum-more/curriculum-more.style.scss deleted file mode 100644 index d124fce..0000000 --- a/src/components/curriculum-more/curriculum-more.style.scss +++ /dev/null @@ -1,45 +0,0 @@ -.curriculum-more { - width: 100%; - - &__img { - position: relative; - top: 10px; - left: 15%; - z-index: 0; - width: 15%; - min-width: 130px; - } - &__content { - position: relative; - padding: 1rem; - border-radius: 150px; - background-color: $color-g2; - display: flex; - justify-content: space-around; - @include tablet { - padding: 1rem 0.5rem; - } - &-explain { - @include mobile { - display: none; - } - @include tablet { - font-size: smaller; - } - padding: 0; - color: white; - &__title { - @include title4; - } - &__subtitle { - @include body2; - } - } - &-btn { - display: flex; - &-item { - margin-left: 0.5rem; - } - } - } -} diff --git a/src/components/curriculum-result/curriculum-result.component.js b/src/components/curriculum-result/curriculum-result.component.js deleted file mode 100644 index d86030f..0000000 --- a/src/components/curriculum-result/curriculum-result.component.js +++ /dev/null @@ -1,29 +0,0 @@ -import Component from '../../core/component'; -import CurriculumList from '../curriculum-list/curriculum-list.component'; -import CurriculumSort from '../curriculum-sort/curriculum-sort.component'; -import CurriculumImage from '../curriculum-image/curriculum-image.component'; -import CurriculumMore from '../curriculum-more/curriculum-more.component'; - -export default class LoadmapResult extends Component { - template() { - const curriculumSort = this.addChild(CurriculumSort); - const curriculumList = this.addChild(CurriculumList); - const curriculumImage = this.addChild(CurriculumImage); - const curriculumMore = this.addChild(CurriculumMore); - return (props) => { - if (props) this.setProps(props); - const { credit, lecture, major, year } = this.props; - - return ` -
-
${curriculumSort.render({ ...credit })}
-
-
${curriculumList.render({ lecture, year })}
-
-
${curriculumImage.render({ major })}
-
${curriculumMore.render({ major })}
-
- `; - }; - } -} diff --git a/src/components/curriculum-result/curriculum-result.style.scss b/src/components/curriculum-result/curriculum-result.style.scss deleted file mode 100644 index f8e850f..0000000 --- a/src/components/curriculum-result/curriculum-result.style.scss +++ /dev/null @@ -1,8 +0,0 @@ -.curriculum-result { - &-bar { - background-color: $color-grey-scale5; - height: 1px; - width: 100%; - margin: 2.5rem 0; - } -} diff --git a/src/components/curriculum-sort/curriculum-sort.component.js b/src/components/curriculum-sort/curriculum-sort.component.js deleted file mode 100644 index 757d2a7..0000000 --- a/src/components/curriculum-sort/curriculum-sort.component.js +++ /dev/null @@ -1,39 +0,0 @@ -import Component from '../../core/component'; -import Credit from '../credit/credit.component'; -import { categoryNameToKorean } from '../../helper/parse'; - -export default class CurriculumSort extends Component { - setDefaultProps() { - this.props = {}; - } - - getList() { - const creditComponent = this.addChild(Credit); - const keys = Object.keys(this.props); - const values = Object.values(this.props); - return values - .map((credit, index) => { - return ` -
${creditComponent.render({ - title: categoryNameToKorean[keys[index].slice(0, -6)], - value: credit, - })}
- `; - }) - .join(''); - } - - template() { - return (props) => { - if (props) this.setProps(props); - return ` -
-
분류
-
- ${this.getList()} -
-
- `; - }; - } -} diff --git a/src/components/curriculum-sort/curriculum-sort.style.scss b/src/components/curriculum-sort/curriculum-sort.style.scss deleted file mode 100644 index 2b88f11..0000000 --- a/src/components/curriculum-sort/curriculum-sort.style.scss +++ /dev/null @@ -1,13 +0,0 @@ -.curriculum-sort { - &__title { - @include title5; - } - &__list { - display: flex; - max-width: 26rem; - margin: auto; - flex-wrap: wrap; - justify-content: center; - align-items: center; - } -} diff --git a/src/components/curriculum/curriculum.component.js b/src/components/curriculum/curriculum.component.js deleted file mode 100644 index a8a590b..0000000 --- a/src/components/curriculum/curriculum.component.js +++ /dev/null @@ -1,153 +0,0 @@ -import Component from '../../core/component'; -import { getResponseiveImage } from '../../helper/images'; -import { parseLectureResult } from '../../helper/parse'; -import ModalLoading from '../modal-loading/modal-loading.component'; -import Modal from '../modal/modal.component'; - -import InputGroup from '../input-group/input-group.component'; -import Button from '../button/button.component'; -import CurriculumResult from '../curriculum-result/curriculum-result.component'; - -import { fetchCurriculumInfos } from '../../async/lecture'; -import { inputTypes, buttonTypes } from '../../helper/types'; -import { departmentList } from '../../helper/data'; - -const sizes = { - mobile: 17, - tablet: 21, - sm: 31, - md: 41, - lg: 41, -}; - -const [sizesAttr, srcsetAttr] = getResponseiveImage(sizes, `${IMAGE_URL}/images/loadmap.png`); - -export default class Curriculum extends Component { - initState() { - this.state = { - auth: false, - categoryList: {}, - lectureList: {}, - isLoading: false, - year: '', - major: '', - }; - } - - async submitData() { - const { year, major } = this.state; - const formData = { - entryYear: year, - department: major, - }; - this.setState({ - isLoading: true, - }); - const response = await fetchCurriculumInfos(formData); - this.setState({ - isLoading: false, - }); - if (response) { - const parseResult = parseLectureResult(response[1]); - this.setState({ auth: true, categoryList: response[0], lectureList: parseResult }); - } - } - - showDetail() { - const curriculumResult = this.addChild(CurriculumResult); - const { categoryList, lectureList, major, year, auth } = this.state; - return `${ - auth - ? `
${curriculumResult.render({ - credit: categoryList, - lecture: lectureList, - major, - year, - })}
` - : `
` - }`; - } - - validation() { - const { year, major } = this.state; - return major === '' || year === ''; - } - - template() { - const inputStyle = { - overflow: 'visible', - background: '#F5F5F5', - border: 'none', - 'border-radius': '2rem', - width: '8rem', - }; - const modalLoadingContainer = this.addChild(Modal); - const modalLoading = this.addChild(ModalLoading); - const yearInputGroup = this.addChild(InputGroup); - const majorInputGroup = this.addChild(InputGroup); - const curriculumButton = this.addChild(Button); - - const { isLoading } = this.state; - - const modalLoadingProps = { - isModalShow: isLoading, - contentComponent: modalLoading, - width: 790, - padding: 200, - key: 'sign-in-loading', - }; - - return (props) => { - if (props) this.setProps(props); - - return ` -
- ${modalLoadingContainer.render(modalLoadingProps)} -
-
-
curriculum__explain-icon나와 맞는 과목 정보 확인하기
-
학과와 학번을 선택하시면 해당 조건과 일치하는 과목 정보들을 알려드릴게요!
-
-
-
-
학과
-
${majorInputGroup.render({ - value: this.state.major, - type: inputTypes.select, - options: Object.keys(departmentList), - onChange: (newMajor) => { - this.setState({ major: newMajor }); - }, - key: 'curriculum-major', - styleOption: inputStyle, - })}
-
-
-
학번
-
${yearInputGroup.render({ - value: this.state.year, - type: inputTypes.select, - options: ['16', '17', '18', '19', '20', '21', '22'], - onChange: (newYear) => { - this.setState({ year: newYear }); - }, - key: 'curriculum-year', - styleOption: inputStyle, - })}
-
-
-
${curriculumButton.render({ - content: '확인', - type: this.validation() ? buttonTypes.grey : buttonTypes.primary, - size: 'md', - key: 'curriculum-btn', - disabled: this.validation(), - onClick: this.submitData.bind(this), - })}
-
- ${this.state.auth ? this.showDetail() : `
`} -
- `; - }; - } -} diff --git a/src/components/curriculum/curriculum.style.scss b/src/components/curriculum/curriculum.style.scss deleted file mode 100644 index b3c5eec..0000000 --- a/src/components/curriculum/curriculum.style.scss +++ /dev/null @@ -1,78 +0,0 @@ -.curriculum { - width: 100%; - &__explain { - &-icon { - margin-right: 0.3rem; - width: 3%; - @include mobile { - width: 5%; - } - } - &-title { - @include title5; - margin: 0.3rem 0; - } - &-detail { - @include subhead5; - color: $color-grey-scale4; - } - } - &__select { - margin: 1.25rem 0; - display: flex; - justify-content: center; - align-items: center; - border: 1px solid #cfcfcf; - border-radius: 0.75rem; - display: flex; - @include mobile { - display: flex; - flex-direction: column; - } - @include tablet { - display: flex; - flex-direction: column; - } - &__bundle { - display: flex; - margin: 1.25rem auto; - @include mobile { - margin: 0.5rem 0; - } - @include tablet { - margin: 0.5rem 0; - } - &-label { - margin-right: 0.5rem; - margin-top: 0.1rem; - display: flex; - justify-content: center; - align-items: center; - height: 1.25rem; - width: 2.5rem; - background-color: $color-g2; - border-radius: 100px; - @include subhead5; - color: #ffffff; - } - &-input { - padding-right: 0rem; - } - } - } - &__btn { - display: flex; - align-items: center; - justify-content: center; - } -} -.box { - @include mobile { - padding: 1rem; - } - padding: 2rem; - background-color: white; - border-radius: 16px; - box-shadow: 0px 4px 20px rgba(0, 0, 0, 0.1), 0px 4px 20px rgba(0, 0, 0, 0.1); - margin-bottom: 1rem; -} diff --git a/src/components/find-id-form/find-id-form.component.js b/src/components/find-id-form/find-id-form.component.js index 901e395..05154d6 100644 --- a/src/components/find-id-form/find-id-form.component.js +++ b/src/components/find-id-form/find-id-form.component.js @@ -28,7 +28,7 @@ export default class FindIdForm extends Component { ); } else { const response = await fetchId(studentId); - response && this.setState({ id: response.userId, find: true }); + response && this.setState({ id: response.authId, find: true }); } } diff --git a/src/components/find-pw-form/fine-pw-form.component.js b/src/components/find-pw-form/fine-pw-form.component.js index eab9e66..217ca22 100644 --- a/src/components/find-pw-form/fine-pw-form.component.js +++ b/src/components/find-pw-form/fine-pw-form.component.js @@ -21,7 +21,7 @@ export default class FindPwForm extends Component { async resettingPassword() { const { id, repassword, reconfirmpassword } = this.state; const result = await fetchPw({ - userId: id, + authId: id, newPassword: repassword, passwordCheck: reconfirmpassword, }); @@ -52,7 +52,7 @@ export default class FindPwForm extends Component { const passwordInputProps = { name: '변경할 비밀번호', id: 'repassword', - placeholder: '문자, 숫자, 기호(!@#$%^&*) 조합 8자 이상 20자 이하', + placeholder: '기호(!@#$%^&*)를 포함한 8자 이상 20자 이하', value: repassword, onChange: (newValue) => { this.setState({ repassword: newValue }); @@ -122,7 +122,6 @@ export default class FindPwForm extends Component { key: 'find-pw', onClick: find ? this.resettingPassword.bind(this) : this.confirmUser.bind(this), }; - // style="display: ${find ? `none` : `block`}" return `
diff --git a/src/components/info/info.component.js b/src/components/info/info.component.js index b193cf4..0c7ffec 100644 --- a/src/components/info/info.component.js +++ b/src/components/info/info.component.js @@ -4,7 +4,7 @@ export default class Info extends Component { setDefaultProps() { this.props = { studentName: '', - department: '', + major: '', studentNumber: '', exist: false, }; @@ -13,7 +13,7 @@ export default class Info extends Component { template() { return (props) => { if (props) this.setProps(props); - const { studentName, department, studentNumber, exist } = this.props; + const { studentName, major, studentNumber, exist } = this.props; return `
@@ -21,7 +21,7 @@ export default class Info extends Component {
${studentName}
${exist ? '님' : ''}
-
${department}
+
${major}
${studentNumber}
`; diff --git a/src/components/lecture-table-list/lecture-table-list.component.js b/src/components/lecture-table-list/lecture-table-list.component.js index b0e4a89..8186f2a 100644 --- a/src/components/lecture-table-list/lecture-table-list.component.js +++ b/src/components/lecture-table-list/lecture-table-list.component.js @@ -33,8 +33,8 @@ export default class LectureTableList extends Component {
${year}
${semester}
-
${lecture.code}
-
${lecture.name}
+
${lecture.lectureCode}
+
${lecture.lectureName}
${lecture.credit}
`; diff --git a/src/components/mobile-category/mobile-category.component.js b/src/components/mobile-category/mobile-category.component.js index bdc2242..73d8781 100644 --- a/src/components/mobile-category/mobile-category.component.js +++ b/src/components/mobile-category/mobile-category.component.js @@ -17,7 +17,6 @@ export default class MobileCategory extends Component { template() { const myInfo = this.addChild(MyInfo); const tutorialNavigate = this.addChild(MobileNavigate); - const curriculumNavigate = this.addChild(MobileNavigate); const mypageNavigate = this.addChild(MobileNavigate); const resultNavigate = this.addChild(MobileNavigate); const aboutNavigate = this.addChild(MobileNavigate); @@ -40,10 +39,6 @@ export default class MobileCategory extends Component {
${resultNavigate.render({ title: '결과페이지', navigate: 'result' })}
${mypageNavigate.render({ title: '마이페이지', navigate: 'mypage' })}
-
${curriculumNavigate.render({ - title: '커리큘럼', - navigate: 'curriculum', - })}
${tutorialNavigate.render({ title: '튜토리얼', navigate: 'tutorial', @@ -59,10 +54,6 @@ export default class MobileCategory extends Component { : `
-
${curriculumNavigate.render({ - title: '커리큘럼', - navigate: 'curriculum', - })}
${tutorialNavigate.render({ title: '튜토리얼', navigate: 'tutorial', diff --git a/src/components/modal-agreement/modal-agreement.component.js b/src/components/modal-agreement/modal-agreement.component.js index 7ea2e34..9b4475d 100644 --- a/src/components/modal-agreement/modal-agreement.component.js +++ b/src/components/modal-agreement/modal-agreement.component.js @@ -35,15 +35,15 @@ export default class ModalAgreement extends Component {
  • 학번: 16 ~ 22학번
    1. -
    2. 교직, 다전공, 편입, 전과, 재외국민/외국인전형에 해당하는 사용자는 검사 기준이 따로 설정되지 않아 검사가 불가능합니다.

      +
    3. 교직, 다전공, 연계전공, 편입, 전과, 재외국민/외국인전형에 해당하는 사용자는 검사 기준이 따로 설정되지 않아 검사가 불가능합니다.

    4. 검사를 위해선 성적표를 직접 업로드해야하므로 PC환경에서 진행하는 것을 권장합니다.

    5. -
    6. 검사 기준은 최신버전 학사안내문(2022.07.28) 반영하여 설정되었으며, 학사안내문은 매년 개편되므로 자신이 알고 있는 구버전과 다를 수 있습니다.

      +
    7. 검사 기준은 최신버전 학사안내문(2023.07.24) 반영하여 설정되었으며, 학사안내문은 매년 개편되므로 자신이 알고 있는 구버전과 다를 수 있습니다.

    1. 본 서비스 정보는 공식적인 효력을 갖지 않으며, 정확한 졸업사정결과를 위해서는 소속 단과대 교학팀에서의 확인을 권장합니다.
    2. diff --git a/src/components/modal-error/modal-error.component.js b/src/components/modal-error/modal-error.component.js index fdb86dc..493fe38 100644 --- a/src/components/modal-error/modal-error.component.js +++ b/src/components/modal-error/modal-error.component.js @@ -18,7 +18,7 @@ export default class ModalError extends Component { if (props) this.setProps(props); const { error } = store.getState(); - const isShow = !!error.code; + const isShow = !!error.status; const modalErrorContentProps = { errorMessage: error.message, diff --git a/src/components/modal-result-content/modal-result-content.component.js b/src/components/modal-result-content/modal-result-content.component.js index 8ccae90..d6c29b1 100644 --- a/src/components/modal-result-content/modal-result-content.component.js +++ b/src/components/modal-result-content/modal-result-content.component.js @@ -2,7 +2,6 @@ import Component from '../../core/component'; import CategoryInfo from '../category-info/category-info.component'; import ResultCompleteContent from '../result-complete-content/result-complete-content.component'; import ResultLectureTable from '../result-lecture-table/result-lecture-table.component'; -import { detailCategoryToKorean } from '../../helper/parse'; export default class ModalResultContent extends Component { setDefaultProps() { @@ -25,22 +24,12 @@ export default class ModalResultContent extends Component { diff --git a/src/components/pie-chart/pie-chart.component.js b/src/components/pie-chart/pie-chart.component.js index 4901c81..beca2ca 100644 --- a/src/components/pie-chart/pie-chart.component.js +++ b/src/components/pie-chart/pie-chart.component.js @@ -17,7 +17,7 @@ export default class PieChart extends Component { return `
      - ${percentage}% + ${percentage > 100 ? 100 : percentage}%
      `; diff --git a/src/components/result-lecture-table-list/result-lecture-table-list.component.js b/src/components/result-lecture-table-list/result-lecture-table-list.component.js index fd86c6f..575dbdc 100644 --- a/src/components/result-lecture-table-list/result-lecture-table-list.component.js +++ b/src/components/result-lecture-table-list/result-lecture-table-list.component.js @@ -1,7 +1,5 @@ import Component from '../../core/component'; import { lectureTableItemTypes } from '../../helper/types'; -import { detailCategoryToKorean } from '../../helper/parse'; -import * as utils from '../../helper/utils'; export default class ResultLectureTableList extends Component { setDefaultProps() { @@ -27,34 +25,19 @@ export default class ResultLectureTableList extends Component { return this.getEditableTableList(); } - isManyCategory(part) { - const filterList = Object.keys(detailCategoryToKorean).slice(0, 8); - return filterList.includes(part); - } - getLectures() { - const { lectures, takenLectures, part, completionList } = this.props; - let concatLectures = []; - + const { lectures, takenLectures, completionList } = this.props; if (completionList) { - if (this.isManyCategory(part) || part === '전공선택필수') { - concatLectures = takenLectures.concat(lectures); - return concatLectures; - } return takenLectures; } return lectures; } getPlainTableList() { - const { takenLectures } = this.props; return this.getLectures() .map((lecture) => { - const modalStyle = { - color: takenLectures.includes(lecture) ? 'blue' : 'black', - }; return ` -
      +
      ${lecture.code}
      ${lecture.name}
      ${lecture.credit}
      diff --git a/src/components/search-lecture-table/search-lecture-table.component.js b/src/components/search-lecture-table/search-lecture-table.component.js index 43054e6..35b36cb 100644 --- a/src/components/search-lecture-table/search-lecture-table.component.js +++ b/src/components/search-lecture-table/search-lecture-table.component.js @@ -54,7 +54,7 @@ export default class SearchLectureTable extends Component { const formData = { keyword: searchText, - qtype: searchLectureOptionTypes.code === option ? 'code' : 'name', + type: searchLectureOptionTypes.code === option ? 'code' : 'name', }; this.setState({ diff --git a/src/components/sign-in-form/sign-in-form.component.js b/src/components/sign-in-form/sign-in-form.component.js index f25a3fc..1055683 100644 --- a/src/components/sign-in-form/sign-in-form.component.js +++ b/src/components/sign-in-form/sign-in-form.component.js @@ -27,7 +27,7 @@ export default class SigninForm extends Component { isLoading: true, }); const result = await fetchSignIn({ - id: this.state.id, + authId: this.state.id, password: this.state.password, }); this.setState({ diff --git a/src/components/sign-up-form/sign-up-form.component.js b/src/components/sign-up-form/sign-up-form.component.js index 1ed694b..6350a91 100644 --- a/src/components/sign-up-form/sign-up-form.component.js +++ b/src/components/sign-up-form/sign-up-form.component.js @@ -140,14 +140,14 @@ export default class SignupForm extends Component { const passwordInputProps = { name: '비밀번호', id: 'password', - placeholder: '문자, 숫자, 기호(!@#$%^&*) 조합 8자 이상 20자 이하', + placeholder: '기호(!@#$%^&*)를 포함한 8자 이상 20자 이하', value: this.state.password, onChange: (newValue) => { this.setState({ password: newValue }); }, isValidation: this.state.isValidationOfPassword, validationCallback: this.validationCallbackOfPassword.bind(this), - errorMessage: '문자, 숫자, 기호(!@#$%^&*) 조합 8자 이상 20자 이하이어야 합니다', + errorMessage: '기호(!@#$%^&*)를 포함한 8자 이상 20자 이하이어야 합니다', key: 'sign-up-password', type: inputTypes.password, }; diff --git a/src/components/taken-lecture-list-header/taken-lecture-list-header.component.js b/src/components/taken-lecture-list-header/taken-lecture-list-header.component.js index b1a6831..17a9382 100644 --- a/src/components/taken-lecture-list-header/taken-lecture-list-header.component.js +++ b/src/components/taken-lecture-list-header/taken-lecture-list-header.component.js @@ -102,7 +102,7 @@ export default class TakenLectureListHeader extends Component {
      ${modalCustomContainer.render(modalCustomProps)}
      - ${tableInfo.render({ part: '내 기이수 과목' })} + ${tableInfo.render({ categoryName: '내 기이수 과목' })}
      ${ isEditableMode @@ -116,7 +116,6 @@ export default class TakenLectureListHeader extends Component { ${uploadNavigationButton.render(uploadNavigationButtonProps)} ` } -
      diff --git a/src/core/browser-router.js b/src/core/browser-router.js index afc7123..fe5cf37 100644 --- a/src/core/browser-router.js +++ b/src/core/browser-router.js @@ -47,11 +47,9 @@ export default class BrowserRouter extends Router { const auth = await fetchValidateUser(); - if (auth.validToken === false) return this.redirectAuthPage(); - if (routerObject.authentication === userRule.init) return routerObject; - if (auth.init === false) return this.redirectInitPage(); + if (auth.init === true) return this.redirectInitPage(); return routerObject; } diff --git a/src/core/middleware.js b/src/core/middleware.js index bfcf820..0ce1fb4 100644 --- a/src/core/middleware.js +++ b/src/core/middleware.js @@ -6,9 +6,6 @@ export const logger = (store) => (next) => (action) => { }; }, {}); const result = next(action); - // console.log('prevState', prevState); - // console.log('action', action); - // console.log('nextState', store.getState()); return result; }; diff --git a/src/helper/errorHandler.js b/src/helper/errorHandler.js index 047058b..b044cff 100644 --- a/src/helper/errorHandler.js +++ b/src/helper/errorHandler.js @@ -12,7 +12,7 @@ export function showErrorModal(error) { export async function makeError(response) { const result = await response.json(); const error = new Error(result.message); - error.code = result.code; + error.status = result.status; return error; } @@ -23,7 +23,7 @@ export async function handleErrorResponse(response) { export async function handleErrorObject(error) { showErrorModal({ - code: error.code, + status: error.status, message: error.message, }); } diff --git a/src/helper/parse.js b/src/helper/parse.js index 9503b83..ff302e0 100644 --- a/src/helper/parse.js +++ b/src/helper/parse.js @@ -1,235 +1,64 @@ -export const detailCategoryToKorean = { - CAREER: '진로', - CHRISTIAN: '기독교', - ENGLISH: '영어', - EXPRESSION: '사고와 표현', - HISTORY_AND_PHILOSOPHY: '역사와 철학', - SOCIETY_AND_COMMUNITY: '사회와 공동체', - SCIENCE_AND_TECHNOLOGY: '과학과 기술', - CULTURE_AND_ART: '문화와 예술', - ICT: 'ICT융합대학', - RAW: '법과대학', - MANAGEMENT_INFORMATION: '경영정보', - INTERNATIONAL_TRADE: '국제통상', - HUMANITY: '인문대학', - SOCIAL_SCIENCE: '사회과학대학', - BUSINESS: '경영', -}; - -export const categoryNameToKorean = { - commonCulture: '공통교양', - coreCulture: '핵심교양', - basicAcademicalCulture: '학문기초교양', - normalCulture: '일반교양', - major: '전공', - madantory: '전공필수', - elective: '전공선택', - freeElective: '자유선택', - total: '총 학점', -}; - -export function parseMandatoruMajorDetailCategory(detailCatory, categoryName) { - const major = detailCatory.takenMandatoryLectures.reduce( - (acc, lecture) => { - acc.totalCredit += lecture.credit; - acc.takenCredit += lecture.credit; - acc.detailCategory[0].totalCredits += lecture.credit; - acc.detailCategory[0].takenCredits += lecture.credit; - acc.detailCategory[0].takenMandatoryLectures.push(lecture); - return acc; - }, - { - totalCredit: 0, - takenCredit: 0, - categoryName, - detailCategory: [ - { - categoryName, - totalCredits: 0, - takenCredits: 0, - takenMandatoryLectures: [], - haveToMandatoryLectures: [], - takenElectiveLectures: [], - haveToElectiveLectures: [], - }, - ], - } - ); - - return detailCatory.haveToMandatoryLectures.reduce((acc, lecture) => { - acc.totalCredit += lecture.credit; - acc.detailCategory[0].totalCredits += lecture.credit; - acc.detailCategory[0].haveToMandatoryLectures.push(lecture); - return acc; - }, major); -} - -export function parseDetailElectiveMajorResult(detailCatory, categoryName) { - const major = detailCatory.takenElectiveLectures.reduce( - (acc, lecture) => { - acc.totalCredit += lecture.credit; - acc.takenCredit += lecture.credit; - acc.detailCategory[0].totalCredits += lecture.credit; - acc.detailCategory[0].takenCredits += lecture.credit; - acc.detailCategory[0].takenElectiveLectures.push(lecture); - return acc; - }, - { - totalCredit: 0, - takenCredit: 0, +const parseMajorSubject = (majorList) => { + return majorList.map((category) => { + const { categoryName, totalCredits, takenCredits, completed } = category; + return { categoryName, - detailCategory: [ - { - categoryName, - totalCredits: 0, - takenCredits: 0, - takenMandatoryLectures: [], - haveToMandatoryLectures: [], - takenElectiveLectures: [], - haveToElectiveLectures: [], - }, - ], - } - ); - - return detailCatory.haveToElectiveLectures.reduce((acc, lecture) => { - acc.totalCredit += lecture.credit; - acc.detailCategory[0].totalCredits += lecture.credit; - acc.detailCategory[0].haveToElectiveLectures.push(lecture); - return acc; - }, major); -} - -export const parseMandatoryMajorResult = (majorResult) => { - let mandatoryMajor; - if (majorResult.detailCategory.length === 2) { - if (majorResult.detailCategory[0].detailCategƒoryName.search(/_A$/) > 0) { - mandatoryMajor = parseMandatoruMajorDetailCategory(majorResult.detailCategory[1], '전공필수'); - mandatoryMajor.detailCategory[1] = { ...majorResult.detailCategory[0] }; - mandatoryMajor.detailCategory[1].detailCategoryName = '전공선택필수'; - const { totalCredits, takenCredits } = mandatoryMajor.detailCategory[1]; - mandatoryMajor.totalCredit += totalCredits; - mandatoryMajor.takenCredit += Math.min(totalCredits, takenCredits); - } else { - mandatoryMajor = parseMandatoruMajorDetailCategory(majorResult.detailCategory[0], '전공필수'); - mandatoryMajor.detailCategory[1] = { ...majorResult.detailCategory[1] }; - mandatoryMajor.detailCategory[1].detailCategoryName = '전공선택필수'; - const { totalCredits, takenCredits } = mandatoryMajor.detailCategory[1]; - mandatoryMajor.totalCredit += totalCredits; - mandatoryMajor.takenCredit += Math.min(totalCredits, takenCredits); - } - } else { - mandatoryMajor = parseMandatoruMajorDetailCategory(majorResult.detailCategory[0], '전공필수'); - } - - return mandatoryMajor; + completed, + totalCredit: totalCredits, + takenCredit: takenCredits, + detailCategory: [{ ...category }], + }; + }); }; -export const parseElectiveMajorResult = (majorResult) => { - let electiveMajor; - if (majorResult.detailCategory.length === 2) { - if (majorResult.detailCategory[0].detailCategoryName.search(/_A$/) > 0) { - electiveMajor = parseDetailElectiveMajorResult(majorResult.detailCategory[1], '전공선택'); - const { totalCredits, takenCredits } = majorResult.detailCategory[0]; - const leftCredits = Math.max(0, takenCredits - totalCredits); - electiveMajor.takenCredit += leftCredits; - // electiveMajor.detailCategory[0].leftCredit = leftCredits; - } else { - electiveMajor = parseDetailElectiveMajorResult(majorResult.detailCategory[0], '전공선택'); - const { totalCredits, takenCredits } = majorResult.detailCategory[1]; - const leftCredits = Math.max(0, takenCredits - totalCredits); - electiveMajor.takenCredit += leftCredits; - // electiveMajor.detailCategory[0].leftCredit = leftCredits; - } - } else { - const { totalCredits, takenCredits } = majorResult.detailCategory[0]; - const leftCredits = Math.max(0, takenCredits - totalCredits); - electiveMajor = parseDetailElectiveMajorResult(majorResult.detailCategory[0], '전공선택'); - // electiveMajor.detailCategory[0].leftCredit = leftCredits; - } +const parseGeneralElectiveSubject = (result) => { + const GeneralElectiveSubject = { + commonCulture: '공통교양', + coreCulture: '핵심교양', + basicAcademicalCulture: '학문기초교양', + normalCulture: '일반교양', + freeElective: '자유선택', + }; + const categories = Object.keys(GeneralElectiveSubject).map((category) => ({ + ...result[category], + categoryName: GeneralElectiveSubject[category], + })); + + const { takenCount } = result.chapelResult; + const chapelInfo = { code: 'KMA02101', credit: 0.5, id: 0, name: '채플' }; + categories[0].detailCategory.push({ + categoryName: '채플', + completed: takenCount === 4, + takenCredits: takenCount * 0.5, + totalCredits: 2, + haveToLectures: takenCount < 4 ? [chapelInfo] : [], + takenLectures: takenCount > 0 ? [chapelInfo] : [], + }); - return electiveMajor; + return categories; }; -export const filterCategoryListCredit = (categoryList) => { - return categoryList.map((category) => { - category.takenCredit = Math.min(category.takenCredit, category.totalCredit); - if (category.detailCategory) { - category.detailCategory = category.detailCategory.map((detail) => { - detail.takenCredits = Math.min(detail.takenCredits, detail.totalCredits); - return detail; - }); - } - return category; - }); +const parseChapelSubject = (chapel) => { + return [ + { + ...chapel, + categoryName: '채플', + totalCredit: 4, + takenCredit: chapel.takenCount, + }, + ]; }; - -export function checkCompletedDetailCategory(category) { - category.detailCategory.map((item) => { - item.completed = item.takenCredits >= item.totalCredits; - return item; - }); -} - export const parseGraduationResult = (result) => { const basicUserInfo = { ...result.basicInfo }; const categoryList = []; - - const mandatoryMajor = parseMandatoryMajorResult(result.major); - const electiveyMajor = parseElectiveMajorResult(result.major); - electiveyMajor.totalCredit = result.major.totalCredit - mandatoryMajor.totalCredit; - - electiveyMajor.detailCategory[0].totalCredits = electiveyMajor.totalCredit; - - electiveyMajor.takenCredit = Math.min(electiveyMajor.takenCredit, electiveyMajor.totalCredit); - - electiveyMajor.detailCategory[0].takenCredits = electiveyMajor.takenCredit; - - checkCompletedDetailCategory(electiveyMajor); - checkCompletedDetailCategory(mandatoryMajor); - - mandatoryMajor.detailCategory[0].detailCategoryName = '전공필수'; - electiveyMajor.detailCategory[0].detailCategoryName = '전공선택'; - categoryList.push(mandatoryMajor); - categoryList.push(electiveyMajor); - result.commonCulture.categoryName = '공통교양'; - categoryList.push({ ...result.commonCulture }); - - result.coreCulture.categoryName = '핵심교양'; - categoryList.push({ ...result.coreCulture }); - - result.basicAcademicalCulture.categoryName = '학문기초교양'; - categoryList.push({ ...result.basicAcademicalCulture }); - - result.normalCulture.categoryName = '일반교양'; - categoryList.push({ ...result.normalCulture }); - - result.freeElective.categoryName = '자유선택'; - categoryList.push({ ...result.freeElective }); - - result.chapelResult.categoryName = '채플'; - result.chapelResult.takenCredit = result.chapelResult.takenCount; - result.chapelResult.totalCredit = result.chapelResult.totalCount; - - categoryList.push({ ...result.chapelResult }); - - const filteredCategoryList = filterCategoryListCredit(categoryList); + const majorResult = parseMajorSubject(result.major.detailCategory, categoryList); + const generalElectiveResult = parseGeneralElectiveSubject(result, categoryList); + const chapelResult = parseChapelSubject(result.chapelResult, categoryList); + categoryList.push(...majorResult); + categoryList.push(...generalElectiveResult); + categoryList.push(...chapelResult); return { basicUserInfo, - categoryList: filteredCategoryList, + categoryList, }; }; - -export const parseLectureResult = (result) => { - const lectureList = []; - const unique = []; - const common = []; - - unique.push({ major: result.major }); - unique.push({ basicAcademicalCulture: result.basicAcademicalCulture }); - common.push({ coreCulture: result.coreCulture }); - common.push({ commonCulture: result.commonCulture }); - lectureList.push(unique); - lectureList.push(common); - return lectureList; -}; diff --git a/src/root.scss b/src/root.scss index 591be7b..9bff693 100644 --- a/src/root.scss +++ b/src/root.scss @@ -30,7 +30,6 @@ $color-error: #ff1111; @import './components/modal/modal.style.scss'; @import './components/category-card/category-card.style.scss'; @import './routers/main-page/main-page.style.scss'; -@import './routers/curriculum-page/curriculum-page.style.scss'; @import './routers/tutorial-page/tutorial-page.style.scss'; @import './components/pie-chart/pie-chart.style.scss'; @import './components/modal-result-header/modal-result-header.style.scss'; @@ -77,13 +76,7 @@ $color-error: #ff1111; @import './components/modal-success-content/modal-success-content.style.scss'; @import './components/info/info.style.scss'; @import './components/modal-notice/modal-notice.style.scss'; -@import './components/curriculum/curriculum.style.scss'; @import './components/credit/credit.style.scss'; -@import './components/curriculum-result/curriculum-result.style.scss'; -@import './components/curriculum-sort/curriculum-sort.style.scss'; -@import './components/curriculum-list/curriculum-list.style.scss'; -@import './components/curriculum-image/curriculum-image.style.scss'; -@import './components/curriculum-more/curriculum-more.style.scss'; @import './components/modal-secession/modal-secession.style.scss'; @import './components/find-id-form/find-id-form.style.scss'; @import './components/find-pw-form/find-pw-form.style.scss'; diff --git a/src/routers/curriculum-page/curriculum-page.component.js b/src/routers/curriculum-page/curriculum-page.component.js deleted file mode 100644 index 22c2c24..0000000 --- a/src/routers/curriculum-page/curriculum-page.component.js +++ /dev/null @@ -1,26 +0,0 @@ -import Component from '../../core/component'; -import Header from '../../components/header/header.component'; -import Curriculum from '../../components/curriculum/curriculum.component'; - -export default class CurriculumPage extends Component { - template() { - const header = this.addChild(Header); - const curriculum = this.addChild(Curriculum); - return (props) => { - if (props) this.setProps(props); - - return ` -
      -
      - ${header.render()} -
      -
      -
      - ${curriculum.render()} -
      -
      -
      - `; - }; - } -} diff --git a/src/routers/curriculum-page/curriculum-page.style.scss b/src/routers/curriculum-page/curriculum-page.style.scss deleted file mode 100644 index 6be2a69..0000000 --- a/src/routers/curriculum-page/curriculum-page.style.scss +++ /dev/null @@ -1,23 +0,0 @@ -.curriculum-page { - &__header { - background-color: $color-primary; - height: 7.1rem; - position: relative; - } - - &__body { - display: flex; - justify-content: center; - &__content { - width: 80%; - @include mobile { - width: 90%; - } - top: -3rem; - z-index: 10; - display: flex; - justify-content: center; - position: relative; - } - } -} diff --git a/src/routers/file-upload-page/file-upload-page.component.js b/src/routers/file-upload-page/file-upload-page.component.js index ed25490..734582f 100644 --- a/src/routers/file-upload-page/file-upload-page.component.js +++ b/src/routers/file-upload-page/file-upload-page.component.js @@ -6,7 +6,7 @@ import Modal from '../../components/modal/modal.component'; import ModalLoading from '../../components/modal-loading/modal-loading.component'; import { fetchPDFFileUpload } from '../../async/file'; import { handleErrorObject } from '../../helper/errorHandler'; -import { init, redirectMypage } from '../../helper/auth'; +import { unInit, redirectMypage } from '../../helper/auth'; export default class FileUploadPage extends Component { initState() { @@ -31,7 +31,7 @@ export default class FileUploadPage extends Component { formData.append('file', this.state.file, 'grade.pdf'); try { await fetchPDFFileUpload(formData); - init(); + unInit(); redirectMypage(); } catch (error) { handleErrorObject(error); diff --git a/src/routers/index.js b/src/routers/index.js index b80e909..eb85166 100644 --- a/src/routers/index.js +++ b/src/routers/index.js @@ -5,7 +5,6 @@ import SignInPage from './sign-in-page/sign-in-page.component'; import SignUpPage from './sign-up-page/sign-up-page.component'; import FileUploadPage from './file-upload-page/file-upload-page.component'; import MypagePage from './mypage-page/mypage-page.component'; -import CurriculumPage from './curriculum-page/curriculum-page.component'; import FindIdPage from './find-id-page/find-id-page.component'; import FindPwPage from './find-pw-page/find-pw-page.component'; import App from '../app'; @@ -25,11 +24,6 @@ export const routerObjects = [ element: TutorialPage, authentication: userRule.guest, }, - { - path: 'curriculum', - element: CurriculumPage, - authentication: userRule.guest, - }, { path: 'sign-up', element: SignUpPage, diff --git a/src/routers/result-page/result-page.component.js b/src/routers/result-page/result-page.component.js index 1a9f6a6..99b8d00 100644 --- a/src/routers/result-page/result-page.component.js +++ b/src/routers/result-page/result-page.component.js @@ -22,7 +22,7 @@ export default class ResultPage extends Component { basicUserInfo: { name: '', studentNumber: '', - department: '', + major: '', totalCredit: 0, takenCredit: 0, }, @@ -53,7 +53,6 @@ export default class ResultPage extends Component { }); try { const result = await fetchGraduationResult(); - const parseResult = parseGraduationResult(result); this.setState({ basicUserInfo: parseResult.basicUserInfo, @@ -135,7 +134,7 @@ export default class ResultPage extends Component { ${categoryList .map(({ categoryName, totalCredit, takenCredit }, index) => { return categoryCardList[index].render({ - title: categoryName, + categoryName, totalCredit, takenCredit, key: index + 1, diff --git a/src/store/async-action.js b/src/store/async-action.js index 2d27a1f..95a7006 100644 --- a/src/store/async-action.js +++ b/src/store/async-action.js @@ -1,6 +1,5 @@ import { createAction } from './store'; import { RESULT_ACTION_TYPES, SIGNIN_ACTION_TYPES } from './types'; -import { parseGraduationResult } from '../helper/parse'; const ROOT_URL = 'https://1db2775e-5c12-4472-ba45-a118a0c06ef5.mock.pstmn.io/test'; // eslint-disable-line no-unused-vars @@ -42,7 +41,7 @@ export const fetchSign = (formData) => (dispatch, getState) => { return response.json(); }) .then((result) => { - if (result.code) { + if (result.status) { dispatch( createAction(SIGNIN_ACTION_TYPES.FETCH_SIGNIN_FAILED, { error: result, diff --git a/src/store/store.js b/src/store/store.js index d5da32c..b78e74f 100644 --- a/src/store/store.js +++ b/src/store/store.js @@ -6,8 +6,8 @@ const initState = { test: 'ok', router: () => {}, isLoadingModalShow: false, - error: { code: null, message: null }, - success: { code: null, message: null }, + error: { status: null, message: null }, + success: { status: null, message: null }, }; export const actionType = { @@ -32,7 +32,7 @@ export const reducer = (state = initState, action = {}) => { return { ...state, error: { - code: null, + status: null, message: null, }, }; @@ -42,7 +42,7 @@ export const reducer = (state = initState, action = {}) => { return { ...state, success: { - code: null, + status: null, message: null, }, }; diff --git a/src/store/types.js b/src/store/types.js index ecd03f9..d512d20 100644 --- a/src/store/types.js +++ b/src/store/types.js @@ -16,34 +16,34 @@ export const SIGNIN_ACTION_TYPES = { export const ERROR_TYPES = { FILE_EXTENSTION: { - code: 100, + status: 100, message: '파일 형식이 pdf가 아닙니다.', }, SEARCH_TEXT_LENGTH: { - code: 101, + status: 101, message: '검색어를 2자리 이상 입력해주세요', }, ALREADY_ADD_LECTURE: { - code: 100, + status: 100, message: '이미 추가한 과목입니다.', }, ALREADY_ADD_TAKEN: { - code: 101, + status: 101, message: '이미 수강한 과목입니다.', }, NULL_INPUT_VALUE: { - code: 100, + status: 100, message: '입력하지 않은 값이 존재합니다.', }, }; export const SUCCESS_TYPES = { SIGN_UP: { - code: 100, + status: 100, message: '회원가입에 성공하셨습니다.', }, CUSTOM_LECTURE: { - code: 101, + status: 101, message: '커스텀에 성공하셨습니다.', }, };