-
Notifications
You must be signed in to change notification settings - Fork 0
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 #33 from School-of-Company/feature/expo-detail-get…
…-training 🔀 박람회 연수 불러오기
- Loading branch information
Showing
5 changed files
with
138 additions
and
12 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { AxiosError } from 'axios'; | ||
import { cookies } from 'next/headers'; | ||
import { NextRequest, NextResponse } from 'next/server'; | ||
import { apiClient } from '@/shared/libs/apiClient'; | ||
|
||
export async function GET( | ||
request: NextRequest, | ||
{ params }: { params: { expo_id: number } }, | ||
) { | ||
const { expo_id } = params; | ||
const cookieStore = cookies(); | ||
const accessToken = cookieStore.get('accessToken')?.value; | ||
try { | ||
const response = await apiClient.get(`/standard/program/${expo_id}`, { | ||
headers: { | ||
Authorization: `Bearer ${accessToken}`, | ||
}, | ||
}); | ||
return NextResponse.json(response.data); | ||
} catch (error) { | ||
const axiosError = error as AxiosError<{ message: string }>; | ||
const status = axiosError.response?.status || 500; | ||
const message = axiosError.response?.data?.message || 'expoDetail failed'; | ||
return NextResponse.json({ error: message }, { status }); | ||
} | ||
} |
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,26 @@ | ||
import { AxiosError } from 'axios'; | ||
import { cookies } from 'next/headers'; | ||
import { NextRequest, NextResponse } from 'next/server'; | ||
import { apiClient } from '@/shared/libs/apiClient'; | ||
|
||
export async function GET( | ||
request: NextRequest, | ||
{ params }: { params: { expo_id: number } }, | ||
) { | ||
const { expo_id } = params; | ||
const cookieStore = cookies(); | ||
const accessToken = cookieStore.get('accessToken')?.value; | ||
try { | ||
const response = await apiClient.get(`/training/program/${expo_id}`, { | ||
headers: { | ||
Authorization: `Bearer ${accessToken}`, | ||
}, | ||
}); | ||
return NextResponse.json(response.data); | ||
} catch (error) { | ||
const axiosError = error as AxiosError<{ message: string }>; | ||
const status = axiosError.response?.status || 500; | ||
const message = axiosError.response?.data?.message || 'expoDetail failed'; | ||
return NextResponse.json({ error: message }, { status }); | ||
} | ||
} |
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,33 @@ | ||
import React from 'react'; | ||
|
||
interface ExpoStandard { | ||
title: string; | ||
startedAt: string; | ||
endedAt: string; | ||
} | ||
|
||
interface Props { | ||
data: ExpoStandard[]; | ||
title: string; | ||
} | ||
|
||
const ContentListText = ({ data, title }: Props) => { | ||
// data가 없으면 빈 배열로 처리 | ||
const validData = data || []; | ||
|
||
return ( | ||
<div className="space-y-4"> | ||
<p className="text-body1 font-bold text-gray-600">{title}</p> | ||
{validData.map((item, index) => ( | ||
<div key={index} className="flex items-center gap-3"> | ||
<p className="text-body1 text-gray-400">- {item.title}</p> | ||
<p className="text-body2 text-gray-400"> | ||
({item.startedAt} ~ {item.endedAt}) | ||
</p> | ||
</div> | ||
))} | ||
</div> | ||
); | ||
}; | ||
|
||
export default ContentListText; |
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