Skip to content

Commit 4f4da56

Browse files
committed
후원사 상세 페이지 생성
1 parent 4b39025 commit 4f4da56

File tree

5 files changed

+124
-7
lines changed

5 files changed

+124
-7
lines changed

frontend/components/service/Sponsor/SponsorList.tsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,8 @@ import { Link } from '../../core/SnsLink'
22
import React from 'react'
33
import styled from 'styled-components'
44
import { ISponsorLevelItem, ISponsorList } from '../../../interfaces/ISponsor'
5-
import categoryList from '../Program/CategoryList'
6-
import Sponsor from '../../../pages/sponsor/list'
75
import { useTranslation } from 'react-i18next'
86
import { Heading3 } from '../../../assets/styles/typo'
9-
import sponsorLevel from '../../../locales/ko/sponsorLevel'
107
import { DEFAULT_PROFILE_PATH } from '../../../data/constants/config'
118

129
const SponsorLevel = styled.div`
@@ -75,7 +72,7 @@ const SponsorList = (props: { list: ISponsorList }) => {
7572
{item.list.map((sponsor) => (
7673
<SponsorItem key={sponsor.slug}>
7774
<Link
78-
href={`/sponsor/list/${sponsor.slug}`}
75+
href={`/sponsor/list/${sponsor.id}`}
7976
>
8077
<a>
8178
<SponsorImage

frontend/interfaces/ISponsor.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { IApiSponsorListItem } from './api/IApiSponsor'
1+
import { IApiSponsorDetail, IApiSponsorListItem } from './api/IApiSponsor'
22

33
export interface ISponsorListItem extends IApiSponsorListItem {}
44

@@ -11,3 +11,5 @@ export interface ISponsorLevelItem {
1111
name: string
1212
list: ISponsorListItem[]
1313
}
14+
15+
export interface ISponsorDetail extends IApiSponsorDetail {}

frontend/interfaces/api/IApiSponsor.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,24 @@ export interface IApiSponsorListItem {
88
logo_image: string | null
99
id: number
1010
}
11+
12+
export interface IApiSponsorDetail {
13+
id: number
14+
slug: string
15+
name: string
16+
level: number
17+
desc: string
18+
manager_name: string
19+
manager_email: string
20+
business_registration_number: string | null
21+
business_registration_file: string | null
22+
url: string | null
23+
logo_image: string | null
24+
virtual_booth_content: string
25+
submitted: boolean
26+
accepted: boolean
27+
paid_at: string | null
28+
exported: boolean
29+
created_at: string
30+
updated_at: string
31+
}

frontend/pages/api/sponsor.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,11 @@ import axios from 'axios'
22
import { IContents } from '../../interfaces/IContents'
33
import { IApiContents } from '../../interfaces/api/IApiContents'
44
import { API_SERVER } from '../../data/constants/config'
5-
import { IApiSponsorListItem } from '../../interfaces/api/IApiSponsor'
6-
import { ISponsorList } from '../../interfaces/ISponsor'
5+
import {
6+
IApiSponsorDetail,
7+
IApiSponsorListItem
8+
} from '../../interfaces/api/IApiSponsor'
9+
import { ISponsorDetail, ISponsorList } from '../../interfaces/ISponsor'
710

811
type SponsorDataEndPointType =
912
| 'prospectus'
@@ -21,6 +24,15 @@ export const getSponsorList = async (): Promise<ISponsorList> => {
2124
}
2225
}
2326

27+
export const getSponsorDetail = async (id: string): Promise<ISponsorDetail> => {
28+
const response = await axios.get(`${API_SERVER}/sponsor/${id}`)
29+
const data: IApiSponsorDetail = response.data
30+
31+
return {
32+
...data
33+
}
34+
}
35+
2436
export const getSponsorContentData = async (
2537
endPoint: SponsorDataEndPointType
2638
): Promise<IContents> => {
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
import React from 'react'
2+
import styled from 'styled-components'
3+
import Linkify from 'react-linkify'
4+
import PageTitle from '../../../components/core/PageTitle'
5+
import { ISponsorDetail, ISponsorListItem } from '../../../interfaces/ISponsor'
6+
import { GetServerSideProps, GetServerSidePropsContext, NextPage } from 'next'
7+
import { getSponsorDetail } from '../../api/sponsor'
8+
import { LocalePage } from '../../../interfaces/PageProps'
9+
import { useTranslation } from 'react-i18next'
10+
import { media } from '../../../assets/styles/mixin'
11+
12+
interface SponsorDetailProps extends LocalePage<ISponsorDetail> {
13+
locale: string
14+
}
15+
16+
const SponsorImage = styled.img`
17+
display: block;
18+
margin: 0 auto;
19+
max-width: 400px;
20+
margin-top: 4rem;
21+
${media.mobile(`
22+
width: 100%;
23+
`)}
24+
`
25+
const SponsorUrl = styled.a`
26+
display: block;
27+
margin-top: 2rem;
28+
color: ${(props) => props.theme.colors.blue0};
29+
&:hover {
30+
text-decoration: underline;
31+
}
32+
`
33+
const SponsorContent = styled.p`
34+
white-space: pre-wrap;
35+
margin-top: 6rem;
36+
a {
37+
color: ${(props) => props.theme.colors.blue0};
38+
}
39+
${media.mobile(`
40+
margin-top: 4rem;
41+
`)}
42+
`
43+
44+
const SponsorDetail: NextPage = (props: SponsorDetailProps) => {
45+
const { t } = useTranslation()
46+
const sponsor: ISponsorListItem = props[props.locale]
47+
48+
return (
49+
<>
50+
<PageTitle title={sponsor.name} />
51+
<SponsorImage src={sponsor.logo_image} alt={sponsor.name} />
52+
{!sponsor.url ?? (
53+
<SponsorUrl href={sponsor.url}>{sponsor.url}</SponsorUrl>
54+
)}
55+
<SponsorContent>
56+
<Linkify>{sponsor.desc}</Linkify>
57+
</SponsorContent>
58+
</>
59+
)
60+
}
61+
62+
export const getServerSideProps: GetServerSideProps = async (
63+
context: GetServerSidePropsContext
64+
) => {
65+
const { locale, params } = context
66+
try {
67+
const data = await getSponsorDetail(params?.id as string)
68+
69+
// TODO: Apply locale
70+
return {
71+
props: {
72+
locale,
73+
ko: data,
74+
en: data
75+
}
76+
}
77+
} catch (error) {
78+
// TODO: Return custom error message
79+
return {
80+
notFound: true
81+
}
82+
}
83+
}
84+
85+
export default SponsorDetail

0 commit comments

Comments
 (0)