Skip to content

Commit

Permalink
Merge branch 'dev' into style/#159
Browse files Browse the repository at this point in the history
  • Loading branch information
pp449 authored Aug 16, 2023
2 parents 91aadeb + 9b08145 commit 65c19a6
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 24 deletions.
3 changes: 1 addition & 2 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,5 @@ const App = () => {
export default App;

const Body = styled.div`
height: calc(100vh - 16vh);
padding: 8vh 0 8vh 0;
padding: 8.5vh 0 8.5vh 0;
`;
41 changes: 24 additions & 17 deletions src/mocks/handlers/graudationHandler.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,29 @@
import { SERVER_URL } from '@config/index';
import { RequestHandler, rest } from 'msw';

type GRADUATION_LINK = {
[key in string]: {
link: string;
};
};
interface GraduationLink {
department: string;
link: string;
}

const MOCK_GRDUATION_LINK: GRADUATION_LINK = {
컴퓨터인공지능학부: {
link: 'https://ce.pknu.ac.kr/ce/2889',
const MOCK_GRDUATION_LINK: GraduationLink[] = [
{
department: '데이터정보과학부',
link: 'https://archieng.pknu.ac.kr/archieng/1423?action=view&no=9911252',
},
데이터정보과학부: {
link: 'https://www.youtube.com',
{
department: '미디어커뮤니케이션학부',
link: 'https://masscom.pknu.ac.kr/comm/3128?action=view&no=9916308',
},
'조형학부 건축학전공': {
link: 'https://www.naver.com',
{
department: '컴퓨터인공지능학부',
link: 'https://ce.pknu.ac.kr/ce/2889',
},
미디어커뮤니케이션학부: {
link: 'https://www.google.com',
{
department: '조형학부 건축학전공',
link: 'https://pknuarchi.pknu.ac.kr/pknuarchi/969?action=view&no=9933526',
},
};
];

export const graduationHandler: RequestHandler[] = [
rest.get(`${SERVER_URL}/api/graduation`, (req, res, ctx) => {
Expand All @@ -30,8 +33,12 @@ export const graduationHandler: RequestHandler[] = [
return res(
ctx.status(200),
ctx.json({
major: major,
graduationLink: MOCK_GRDUATION_LINK[major].link,
department: major,
link: MOCK_GRDUATION_LINK[
MOCK_GRDUATION_LINK.findIndex(
(graduationLink) => graduationLink.department === major,
)
].link,
}),
);
}
Expand Down
13 changes: 8 additions & 5 deletions src/pages/Home/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,25 @@ import InformCard from '@components/Card/InformCard';
import styled from '@emotion/styled';
import useMajor from '@hooks/useMajor';
import useRouter from '@hooks/useRouter';
import { AxiosResponse } from 'axios';
import { useEffect, useState } from 'react';

const Home = () => {
const [graduationLink, setGraduationLink] = useState<string>('');
const [graduationLink, setGraduationLink] = useState<string | null>('');
const { routerTo } = useRouter();
const { major } = useMajor();

const routerToGraduationRequired = () => {
window.location.href = graduationLink;
const routerToGraduationRequiredPage = (graduationLink: string | null) => {
graduationLink && window.open(graduationLink, '_blank');
};

useEffect(() => {
if (!major) return;
const getGraduationLink = async () => {
const response = await http.get(`/api/graduation?major=${major}`);
setGraduationLink(response.data.graduationLink);
const response: AxiosResponse<GraduationLink> = await http.get(
`/api/graduation?major=${major}`,
);
setGraduationLink(response.data.link);
};
getGraduationLink();
}, [major]);
Expand Down

0 comments on commit 65c19a6

Please sign in to comment.