-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4c58233
commit c6f1e51
Showing
49 changed files
with
4,407 additions
and
314 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
@import '../styles/config.scss'; | ||
|
||
.main { | ||
margin-top: var(--header-height); | ||
padding: 16px; | ||
|
||
@include media($tablet) { | ||
padding: 16px 24px; | ||
} | ||
|
||
@include media($pc) { | ||
margin: var(--header-height) auto; | ||
padding: 24px; | ||
max-width: 1248px; | ||
} | ||
} | ||
|
||
.auth { | ||
max-width: 1248px; | ||
} |
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,21 +1,22 @@ | ||
import { ReactNode } from 'react'; | ||
import Header from './Header'; | ||
import s from './UI.module.scss'; | ||
import GNB from './layout/GNB'; | ||
import { useRouter } from 'next/router'; | ||
|
||
type layout = { | ||
children: ReactNode; | ||
}; | ||
|
||
function Layout({ children }: layout) { | ||
function UI({ children }: layout) { | ||
const router = useRouter(); | ||
const isAuthPage = router.pathname === ('/login' || '/signup'); | ||
|
||
return ( | ||
<> | ||
{!isAuthPage && <Header />} | ||
<main style={!isAuthPage ? { marginTop: 'var(--header-height)' } : {}}>{children}</main> | ||
{!isAuthPage && <GNB />} | ||
<main className={!isAuthPage ? s.main : s.auth}>{children}</main> | ||
</> | ||
); | ||
} | ||
|
||
export default Layout; | ||
export default UI; |
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 |
---|---|---|
@@ -0,0 +1,61 @@ | ||
@import '../../styles/config.scss'; | ||
|
||
.wrap { | ||
position: fixed; | ||
top: 0; | ||
z-index: 1; | ||
|
||
width: 100%; | ||
background-color: #fff; | ||
border-bottom: 1px solid #dfdfdf; | ||
|
||
.contain { | ||
display: flex; | ||
justify-content: space-between; | ||
align-items: center; | ||
|
||
max-width: 1600px; | ||
height: var(--header-height); | ||
padding: 0 16px; | ||
|
||
nav { | ||
display: flex; | ||
list-style: none; | ||
gap: 8px; | ||
font-weight: bold; | ||
font-size: 16px; | ||
color: var(--gray600); | ||
margin-left: 16px; | ||
flex-grow: 1; | ||
|
||
:hover { | ||
color: var(--blue); | ||
} | ||
} | ||
|
||
@include media($tablet) { | ||
padding: 0 24px; | ||
|
||
nav { | ||
gap: 36px; | ||
font-size: 18px; | ||
margin-left: 20px; | ||
} | ||
} | ||
|
||
@include media($pc) { | ||
margin: auto; | ||
|
||
nav { | ||
margin-left: 32px; | ||
} | ||
} | ||
|
||
.login { | ||
font-size: 16px; | ||
font-weight: 600; | ||
border-radius: 8px; | ||
padding: 14.5px 43px; | ||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import s from './GNB.module.scss'; | ||
import logo from '@/public/logo/icon_logo.png'; | ||
import Image from 'next/image'; | ||
import Link from 'next/link'; | ||
import { useRouter } from 'next/router'; | ||
|
||
function GNB() { | ||
const { pathname } = useRouter(); | ||
|
||
function getLinkStyle(isActive: boolean) { | ||
return { color: isActive ? 'var(--blue)' : undefined }; | ||
} | ||
|
||
return ( | ||
<header className={s.wrap}> | ||
<div className={s.contain}> | ||
<Link href='/' aria-label='홈으로 이동'> | ||
<Image src={logo} alt='판다마켓 로고' /> | ||
</Link> | ||
|
||
<nav> | ||
<Link href='/boards' style={getLinkStyle(pathname === '/boards')}> | ||
자유게시판 | ||
</Link> | ||
|
||
<Link href='/items' style={getLinkStyle(pathname === ('/items' || '/additem'))}> | ||
중고마켓 | ||
</Link> | ||
</nav> | ||
|
||
<Link href='/login' className={`button ${s.login}`}> | ||
로그인 | ||
</Link> | ||
</div> | ||
</header> | ||
); | ||
} | ||
|
||
export default GNB; |
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 |
---|---|---|
@@ -0,0 +1,40 @@ | ||
export async function getArticleDetail(articleId: number) { | ||
if (!articleId) { | ||
throw new Error('Invalid article ID'); | ||
} | ||
|
||
try { | ||
const response = await fetch(`https://panda-market-api.vercel.app/articles/${articleId}`); | ||
if (!response.ok) { | ||
throw new Error(`HTTP error: ${response.status}`); | ||
} | ||
const body = await response.json(); | ||
return body; | ||
} catch (error) { | ||
console.error('Failed to fetch article detail:', error); | ||
throw error; | ||
} | ||
} | ||
|
||
export async function getArticleComments({ articleId, limit = 10 }: { articleId: number; limit?: number }) { | ||
if (!articleId) { | ||
throw new Error('Invalid article ID'); | ||
} | ||
|
||
const params = { | ||
limit: String(limit), | ||
}; | ||
|
||
try { | ||
const query = new URLSearchParams(params).toString(); | ||
const response = await fetch(`https://panda-market-api.vercel.app/articles/${articleId}/comments?${query}`); | ||
if (!response.ok) { | ||
throw new Error(`HTTP error: ${response.status}`); | ||
} | ||
const body = await response.json(); | ||
return body; | ||
} catch (error) { | ||
console.error('Failed to fetch article comments:', error); | ||
throw error; | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,61 @@ | ||
export async function getProducts({ orderBy, pageSize, page = 1 }: ProductListFetcherParams) { | ||
const params = new URLSearchParams({ | ||
orderBy, | ||
pageSize: String(pageSize), | ||
page: String(page), | ||
}); | ||
|
||
try { | ||
const response = await fetch(`https://panda-market-api.vercel.app/products?${params}`); | ||
|
||
if (!response.ok) { | ||
throw new Error(`HTTP error: ${response.status}`); | ||
} | ||
const body = await response.json(); | ||
return body; | ||
} catch (error) { | ||
console.error('Failed to fetch products:', error); | ||
throw error; | ||
} | ||
} | ||
|
||
export async function getProductDetail(productId: number) { | ||
if (!productId) { | ||
throw new Error('Invalid product ID'); | ||
} | ||
|
||
try { | ||
const response = await fetch(`https://panda-market-api.vercel.app/products/${productId}`); | ||
if (!response.ok) { | ||
throw new Error(`HTTP error: ${response.status}`); | ||
} | ||
const body = await response.json(); | ||
return body; | ||
} catch (error) { | ||
console.error('Failed to fetch product detail:', error); | ||
throw error; | ||
} | ||
} | ||
|
||
export async function getProductComments({ productId, limit = 10 }: { productId: number; limit?: number }) { | ||
if (!productId) { | ||
throw new Error('Invalid product ID'); | ||
} | ||
|
||
const params = { | ||
limit: String(limit), | ||
}; | ||
|
||
try { | ||
const query = new URLSearchParams(params).toString(); | ||
const response = await fetch(`https://panda-market-api.vercel.app/products/${productId}/comments?${query}`); | ||
if (!response.ok) { | ||
throw new Error(`HTTP error: ${response.status}`); | ||
} | ||
const body = await response.json(); | ||
return body; | ||
} catch (error) { | ||
console.error('Failed to fetch product comments:', error); | ||
throw error; | ||
} | ||
} |
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
Oops, something went wrong.