-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #163 from GDSC-PKNU-21-22/dev
부리미 v0.23 배포
- Loading branch information
Showing
7 changed files
with
85 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,60 @@ | ||
import http from '@apis/http'; | ||
import InformCard from '@components/Card/InformCard'; | ||
import { css } from '@emotion/react'; | ||
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]); | ||
|
||
return ( | ||
<> | ||
<div | ||
css={css` | ||
display: flex; | ||
justify-content: center; | ||
`} | ||
> | ||
<InformCard | ||
icon="notification" | ||
title="공지사항" | ||
majorRequired={false} | ||
onClick={() => routerTo('/announcement')} | ||
/> | ||
<InformCard | ||
icon="school" | ||
title="졸업요건" | ||
majorRequired={true} | ||
onClick={() => routerToGraduationRequired()} | ||
/> | ||
</div> | ||
</> | ||
<Container> | ||
<InformCard | ||
icon="notification" | ||
title="공지사항" | ||
majorRequired={false} | ||
onClick={() => routerTo('/announcement')} | ||
/> | ||
<InformCard | ||
icon="school" | ||
title="졸업요건" | ||
majorRequired={true} | ||
onClick={() => routerToGraduationRequiredPage(graduationLink)} | ||
/> | ||
</Container> | ||
); | ||
}; | ||
|
||
export default Home; | ||
|
||
const Container = styled.div` | ||
display: flex; | ||
flex-direction: column; | ||
width: 85%; | ||
text-aligb: center; | ||
margin: 0 auto; | ||
`; | ||
|
||
interface GraduationLink { | ||
department: string; | ||
link: string | null; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters