Skip to content

Commit 70eba7b

Browse files
authored
Merge pull request #37 from CoPlay-FE/feature/dashboard_id
✨ Feat: 대시보드 상세 페이지
2 parents a0ee89e + 769c5b6 commit 70eba7b

File tree

16 files changed

+259
-4
lines changed

16 files changed

+259
-4
lines changed

next.config.mjs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,17 @@
11
/** @type {import('next').NextConfig} */
22
const nextConfig = {
33
output: 'standalone',
4+
5+
images: {
6+
remotePatterns: [
7+
{
8+
protocol: 'https',
9+
hostname: 'sprint-fe-project.s3.ap-northeast-2.amazonaws.com',
10+
port: '',
11+
pathname: '/**',
12+
},
13+
],
14+
},
415
}
516

617
export default nextConfig

public/images/calendar.svg

Lines changed: 3 additions & 0 deletions
Loading

public/images/config.svg

Lines changed: 3 additions & 0 deletions
Loading

public/images/plus.svg

Lines changed: 3 additions & 0 deletions
Loading

src/app/api/.gitkeep

Whitespace-only changes.

src/app/api/axiosClient.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import axios from 'axios'
2+
3+
const axiosClient = axios.create({
4+
baseURL: 'https://sp-taskify-api.vercel.app/7-6',
5+
})
6+
7+
// 작업용 임시 토큰
8+
const TEMP_TOKEN = process.env.NEXT_PUBLIC_API_TOKEN
9+
10+
axiosClient.interceptors.request.use((config) => {
11+
if (TEMP_TOKEN) {
12+
config.headers['Authorization'] = `Bearer ${TEMP_TOKEN}`
13+
}
14+
15+
return config
16+
})
17+
18+
export default axiosClient

src/app/api/useCards.ts

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
//size일단 10으로 하고, 나중에 커서아이디 받아서 무한 스크롤 구현해야 함.
2+
import { useQuery } from '@tanstack/react-query'
3+
4+
import axiosClient from './axiosClient'
5+
6+
export interface Assignee {
7+
id: number
8+
nickname: string
9+
profileImageUrl: string | null
10+
}
11+
export interface Card {
12+
id: number
13+
title: string
14+
description: string
15+
tags: string[]
16+
dueDate: string
17+
assignee: Assignee
18+
imageUrl: string
19+
teamId: string
20+
dashboardId: number
21+
columnId: number
22+
createdAt: string
23+
updatedAt: string
24+
}
25+
export interface CardResponse {
26+
cards: Card[]
27+
totalCount: number
28+
cursorId: number
29+
}
30+
31+
export async function fetchCards(
32+
columnId: number,
33+
size: number = 10,
34+
): Promise<CardResponse> {
35+
const res = await axiosClient.get<CardResponse>(
36+
`/cards?size=${size}&columnId=${columnId}`,
37+
)
38+
return res.data
39+
}
40+
41+
export default function useCards(columnId: number) {
42+
return useQuery<CardResponse>({
43+
queryKey: ['columnId', columnId],
44+
queryFn: () => fetchCards(columnId),
45+
})
46+
}

src/app/api/useColumns.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import { useQuery } from '@tanstack/react-query'
2+
3+
import axiosClient from './axiosClient'
4+
5+
//타입
6+
export interface Column {
7+
id: number
8+
title: string
9+
teamId: string
10+
dashboardId: number
11+
createdAt: string
12+
updatedAt: string
13+
}
14+
export interface ColumnsResponse {
15+
data: Column[]
16+
}
17+
18+
//fetch 함수 (API 호출 전용)
19+
export async function fetchColumns(dashboardId: number): Promise<Column[]> {
20+
const res = await axiosClient.get<ColumnsResponse>(
21+
`/columns?dashboardId=${dashboardId}`,
22+
)
23+
return res.data.data
24+
}
25+
26+
//useQuery
27+
export default function useColumns(dashboardId: number) {
28+
return useQuery<Column[]>({
29+
queryKey: ['columns', dashboardId],
30+
queryFn: () => fetchColumns(dashboardId),
31+
})
32+
}

src/app/dashboard/.gitkeep

Whitespace-only changes.
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import Image from 'next/image'
2+
3+
import type { Card } from '@/app/api/useCards'
4+
5+
import Tags from './Tags'
6+
7+
export default function Card({ card }: { card: Card }) {
8+
const { imageUrl, title, tags, dueDate, assignee } = card
9+
return (
10+
<div className="BG-white Border-section relative w-314 rounded-6 border-solid px-20 py-16">
11+
Todo Card
12+
{imageUrl && (
13+
<Image
14+
src={imageUrl}
15+
alt="카드 이미지"
16+
width={400}
17+
height={600}
18+
className="h-auto w-full rounded-6 object-contain"
19+
priority
20+
/>
21+
)}
22+
<p>{title}</p>
23+
<Tags tags={tags} />
24+
<p>{dueDate}</p>
25+
<p>프로필</p>
26+
</div>
27+
)
28+
}

0 commit comments

Comments
 (0)