-
Notifications
You must be signed in to change notification settings - Fork 2
Feat: 일정 상세 페이지 추가 #58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from all commits
72b26de
1ceafaa
6d58287
e24398e
68dbaf9
0619ed8
d38cc30
7e4172e
9d20423
ce063e0
f395356
d05ee8f
9a46f3a
a588386
8c539ae
563a374
d52be9e
b796842
0fc32ce
ae03185
ff65960
c1a42c7
7001613
288d340
cdad9a4
60cd9b3
061fb1a
a847fb2
4cd8eac
b8980cb
ce11a83
c0cf741
925adbb
c1e78e9
2499665
ab3fcf8
df223ac
d593a41
781fbcf
fc13413
839e2b5
98d62f4
eb3be13
17b8db5
b53e7cd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| import { CardType } from "@findSchedule/components/Card"; | ||
| import axios from "axios"; | ||
|
|
||
| interface scheduleListParams { | ||
| theme: string; | ||
| dateStart: string; | ||
| dateEnd: string; | ||
| expense?: number; | ||
| location: string; | ||
| personnel?: number; | ||
| keywordOption?: number; | ||
| keyword?: string; | ||
| } | ||
|
|
||
| export const findSchedule = async (params?: scheduleListParams) => { | ||
| try { | ||
| const res = await axios.get<CardType[]>( | ||
| `${process.env.NEXT_PUBLIC_BASE_URL}/schedule/list`, | ||
| { | ||
| params, | ||
| }, | ||
| ); | ||
|
|
||
| if (res.status === 200) { | ||
| console.log("res.data", res.data); | ||
| return res.data; | ||
| } else { | ||
| return []; | ||
| } | ||
| } catch (error) { | ||
| console.error("API 호출 중 오류 발생:", error); | ||
| throw error; // 오류를 호출자에게 전달 | ||
| } | ||
| }; |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,72 @@ | ||||||
| import { CommentWithReComments } from "@detail/CommentBox"; | ||||||
| import Detail from "@detail/Detail"; | ||||||
| import { hostInfo } from "@detail/HostInfo"; | ||||||
| import { participateInfoType } from "@detail/ParticipationStatus"; | ||||||
| import axios from "axios"; | ||||||
| import { GetServerSideProps } from "next"; | ||||||
| import React from "react"; | ||||||
|
|
||||||
| export interface DetailCard { | ||||||
| id: number; | ||||||
| hostInfo: hostInfo; | ||||||
| img: string; | ||||||
| theme: string; | ||||||
| title: string; | ||||||
| content: string; | ||||||
| location: string; | ||||||
| dateStart: string; | ||||||
| dateEnd: string; | ||||||
| expense: number; | ||||||
| tags: string[]; | ||||||
| like: number; | ||||||
| likeStatus: boolean; | ||||||
| comment: number; | ||||||
| scrap: number; | ||||||
| isParticipate: number; // 0: 미신청, 1: 신청완료 (대기중), 2: 참여 | ||||||
| scrapStatus: boolean; | ||||||
| recruitStart: string; | ||||||
| recruitEnd: string; | ||||||
| applicantNum: number; | ||||||
| participateNum: number; | ||||||
| participateCapacity: number; | ||||||
| participateInfos: participateInfoType[]; | ||||||
| createdAt: string; | ||||||
| comments: CommentWithReComments[]; | ||||||
| } | ||||||
|
|
||||||
| interface DetailProps { | ||||||
| detailData: DetailCard; | ||||||
| } | ||||||
|
|
||||||
| const detail = ({ detailData }: DetailProps) => { | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [Lv2] 가급적이면 컴포넌트명은 대문자로 시작하는게 좋습니다! |
||||||
| return ( | ||||||
| <div className="flex justify-center mt-[78px]"> | ||||||
| <Detail detailData={detailData}></Detail> | ||||||
| </div> | ||||||
| ); | ||||||
| }; | ||||||
|
|
||||||
| export default detail; | ||||||
|
|
||||||
| export const getServerSideProps: GetServerSideProps = async (context) => { | ||||||
| const { id } = context.params || {}; | ||||||
|
|
||||||
| try { | ||||||
| const response = await axios.get( | ||||||
| `${process.env.NEXT_PUBLIC_BASE_URL}/getCardDetail`, | ||||||
| { params: { id } }, | ||||||
| ); | ||||||
|
|
||||||
| const detailData = response.data; | ||||||
| console.log("datas", detailData); | ||||||
|
|
||||||
| return { | ||||||
| props: { detailData }, | ||||||
| }; | ||||||
| } catch (error) { | ||||||
| console.error("Error fetching data", error); | ||||||
| return { | ||||||
| props: { data: "" }, | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
[Lv3] api 통신중 에러가 발생했다면 (데이터가 없거나) 여기서는 notFound 페이지를 띄워주는게 맞습니다! |
||||||
| }; | ||||||
| } | ||||||
| }; | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 주어진 코드 패치는 다음과 같은 리뷰를 제공하고 있습니다. 수정 제안 및 버그 위험 사항 등을 포함합니다:
이러한 리뷰는 코드 패치의 특정 부분에 대해서만 내용을 포함하고 있습니다. 전체 애플리케이션 또는 프로젝트에 대한 세부 내용이 제공되면 더 정확하고 철저한 리뷰를 제공할 수 있습니다. |
||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,12 +1,38 @@ | ||
| import { CardType } from "@findSchedule/components/Card"; | ||
| import Page from "findSchedule/components/Page"; | ||
| import { GetServerSideProps } from "next"; | ||
| import React from "react"; | ||
| import { findSchedule } from "@pages/api/findSchedule"; | ||
|
|
||
| const index = () => { | ||
| interface FindPageProps { | ||
| defaultCardList: CardType[]; | ||
| } | ||
|
|
||
| const index = ({ defaultCardList }: FindPageProps) => { | ||
| return ( | ||
| <div className="flex justify-center mt-[78px]"> | ||
| <Page /> | ||
| <Page defaultCardList={defaultCardList} /> | ||
| </div> | ||
| ); | ||
| }; | ||
|
|
||
| export default index; | ||
|
|
||
| export const getServerSideProps: GetServerSideProps = async () => { | ||
| try { | ||
| const res = await findSchedule(); | ||
|
|
||
| return { | ||
| props: { | ||
| defaultCardList: res, | ||
| }, | ||
| }; | ||
| } catch (error) { | ||
| console.error("Error fetching data1", error); | ||
| return { | ||
| props: { | ||
| defaultCardList: [], | ||
| }, | ||
| }; | ||
| } | ||
| }; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 이 코드 패치의 주요 변경 사항은 다음과 같습니다:
이 코드 패치에서 특별한 버그나 큰 위험 요소는 보이지 않습니다. 하지만 몇 가지 개선 제안은 있습니다:
추가적인 정보나 팁이 필요한 경우 말씀해주세요! |
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
주어진 코드 패치에 대해 간단한 코드 리뷰를 도와드리겠습니다. 버그 위험과/또는 개선 제안을 언급하겠습니다.
@@ -4,3 +4,6 행: 이 부분은 diff 형식으로 변경 사항을 보여줍니다. 코드 자체의 문제는 없습니다.
NEXT_PUBLIC_NODE_ENV, NEXT_PUBLIC_MOCK, NEXT_PUBLIC_BASE_URL 변수: 이 세 가지 변수에는 API 키 대신 API 키를 설정할 문자열이 포함되어 있습니다. 변수 이름에서 예상되는 것보다 정작 API 키를 저장하는 용도로 사용하실 거 같지 않으며, 이름과 목적을 일치시켜 주셔야 합니다.
개선 제안:
코드 패치에는 실제 코드가 포함되어 있지 않기 때문에 코드 자체에 대한 전체적인 검토는 제공하기 어렵습니다. 그러나 제공된 정보만으로는 코드 내에 오류나 개선 가능한 부분에 대해 자세히 언급할 수 없습니다. 코드의 실제 내용을 공유해주시면 더 자세하게 도움을 드릴 수 있습니다.