-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: 스터디 신청 api 연결 및 응답 포맷팅 로직 추가 * feat: body 추가 * feat: 헤더 뺀 부분 * refactor: parseDate 상단에서 하도록 수정, padWitZero 유틸 추가 * feat: padWithZero export * feat: utils 패키지에 next 설치 * fix: fetcher 클래스 client, server 환경 분리 로직 추가 * chore: root 의존성 충돌 문제 해결 * chore: 불필요한 헤더 주입 로직 삭제 * chore: admin 헤더 관련 로직 삭제 * fix: 빌드 실패하는 문제 해결 * feat: async await 으로 변경, success 여부만 넘기는 것으로 * refactor: Table.Content 삭제, 핸들러 이름 변경 * feat: 에러 페이지 추가, header 제거 * feat: Table export 추가 및 빌드 스크립트 수정 * fix: 빌드 에러 수정 * feat: Table Content 부분 삭제 * fix: 구조분해할당으로 리팩토링 * fix: respose.ok 값 체크 * chore: 필요없는 주석 제거 * chore: notion link 로 열리게 수정 --------- Co-authored-by: ghdtjgus76 <[email protected]>
- Loading branch information
1 parent
e2f6fe0
commit 55b19a2
Showing
24 changed files
with
275 additions
and
161 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
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
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,31 @@ | ||
import { fetcher } from "@wow-class/utils"; | ||
import { apiPath } from "constants/apiPath"; | ||
import { tags } from "constants/tags"; | ||
import type { StudyListApiResponseDto } from "types/dtos/apply-study"; | ||
|
||
export const studyApplyApi = { | ||
getStudyList: async () => { | ||
const response = await fetcher.get<StudyListApiResponseDto[]>( | ||
apiPath.applyStudy, | ||
{ | ||
next: { tags: [tags.studyApply] }, | ||
cache: "force-cache", | ||
} | ||
); | ||
|
||
return response.data; | ||
}, | ||
applyStudy: async (studyId: number) => { | ||
const response = await fetcher.post( | ||
`${apiPath.applyStudy}/${studyId}`, | ||
null | ||
); | ||
|
||
return { success: response.ok }; | ||
}, | ||
cancelStudyApplication: async (studyId: number) => { | ||
const response = await fetcher.delete(`${apiPath.applyStudy}/${studyId}`); | ||
|
||
return { success: response.ok }; | ||
}, | ||
}; |
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
102 changes: 102 additions & 0 deletions
102
apps/client/app/(afterLogin)/study-apply/_components/StudyItem.tsx
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,102 @@ | ||
"use client"; | ||
|
||
import { css } from "@styled-system/css"; | ||
import { Flex, styled } from "@styled-system/jsx"; | ||
import { Table, Text } from "@wow-class/ui"; | ||
import { parseISODate, splitTime } from "@wow-class/utils"; | ||
import { studyApplyApi } from "apis/studyApplyApi"; | ||
import { dayToKorean } from "constants/dayToKorean"; | ||
import type { ComponentProps } from "react"; | ||
import type { StudyListApiResponseDto } from "types/dtos/apply-study"; | ||
import Button from "wowds-ui/Button"; | ||
import Tag from "wowds-ui/Tag"; | ||
|
||
interface StudyItemProps { | ||
study: StudyListApiResponseDto; | ||
} | ||
|
||
const StudyItem = ({ study }: StudyItemProps) => { | ||
const { | ||
studyId, | ||
title, | ||
introduction, | ||
notionLink, | ||
mentorName, | ||
studyType, | ||
dayOfWeek, | ||
startTime: startTimeString, | ||
openingDate: openingDateString, | ||
totalWeek, | ||
} = study; | ||
|
||
const handleClickApplyButton = async () => { | ||
const result = await studyApplyApi.applyStudy(studyId); | ||
|
||
if (!result.success) { | ||
console.error("스터디 신청 실패"); | ||
} else { | ||
console.log("스터디 신청 성공"); | ||
} | ||
}; | ||
|
||
const handleClickCancelButton = async () => { | ||
const result = await studyApplyApi.cancelStudyApplication(studyId); | ||
|
||
if (!result.success) { | ||
console.error("스터디 신청 실패"); | ||
} else { | ||
console.log("스터디 취소 성공"); | ||
} | ||
}; | ||
|
||
const startTime = splitTime(startTimeString); | ||
const openingDate = parseISODate(openingDateString); | ||
const studyTime = `${dayToKorean[dayOfWeek.toUpperCase()]} ${startTime.hours}:${startTime.minutes} - ${ | ||
Number(startTime.hours) + 1 | ||
}:${startTime.minutes}`; | ||
|
||
return ( | ||
<Table> | ||
<Flex direction="column" gap="xxs" justifyContent="center"> | ||
<Flex gap="xs"> | ||
<Text typo="h3">{title}</Text> | ||
<Tag color={sessionColors[studyType] ?? "green"} variant="solid1"> | ||
{studyType} | ||
</Tag> | ||
</Flex> | ||
<Text color="sub" typo="body2"> | ||
{`${introduction} -`} | ||
<a href={notionLink} target="_blank"> | ||
{notionLink} | ||
</a> | ||
</Text> | ||
</Flex> | ||
<Text className={textCellStyle}>{mentorName}</Text> | ||
<Text className={textCellStyle}>{studyTime}</Text> | ||
<Text className={textCellStyle}>{totalWeek}주 코스</Text> | ||
<Text className={textCellStyle}> | ||
{`${openingDate.month}.${openingDate.day} 개강`} | ||
</Text> | ||
<styled.div paddingX="24px"> | ||
<Button size="sm" variant="solid" onClick={handleClickApplyButton}> | ||
수강 신청 | ||
</Button> | ||
<Button size="sm" variant="solid" onClick={handleClickCancelButton}> | ||
신청 취소 | ||
</Button> | ||
</styled.div> | ||
</Table> | ||
); | ||
}; | ||
|
||
const textCellStyle = css({ | ||
paddingX: "28px", | ||
}); | ||
|
||
const sessionColors: Record<string, ComponentProps<typeof Tag>["color"]> = { | ||
"과제 스터디": "green", | ||
"온라인 세션": "blue", | ||
"오프라인 세션": "yellow", | ||
}; | ||
|
||
export default StudyItem; |
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 @@ | ||
export { default as StudytItem } from "./StudyItem"; |
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,45 +1,22 @@ | ||
import { css } from "@styled-system/css"; | ||
import { styled } from "@styled-system/jsx"; | ||
import { Space, Table, Text } from "@wow-class/ui"; | ||
import Button from "wowds-ui/Button"; | ||
import Tag from "wowds-ui/Tag"; | ||
import { Space, Text } from "@wow-class/ui"; | ||
import { studyApplyApi } from "apis/studyApplyApi"; | ||
|
||
import StudyItem from "./_components/StudyItem"; | ||
|
||
const StudyApplyPage = async () => { | ||
const studyList = await studyApplyApi.getStudyList(); | ||
|
||
const StudyApplyPage = () => { | ||
const array = [0, 1, 2]; | ||
return ( | ||
<> | ||
<Text as="h1" typo="h1"> | ||
신청 가능한 스터디 | ||
</Text> | ||
<Space height={19} /> | ||
{array.map(() => ( | ||
<Table> | ||
<Table.Content | ||
subText="(스터디 한 줄 소개-스터디 상세 설명 노션 링크로 연결)" | ||
text="기초 웹 스터디" | ||
rightContent={ | ||
<Tag color="yellow" variant="solid1"> | ||
신규 | ||
</Tag> | ||
} | ||
/> | ||
<Text className={textCellStyle}>강가은 멘토</Text> | ||
<Text className={textCellStyle}>화 18:00-19:00</Text> | ||
<Text className={textCellStyle}>4주 코스</Text> | ||
<Text className={textCellStyle}>06.18 개강</Text> | ||
<styled.div paddingX="24px"> | ||
<Button size="sm" variant="solid"> | ||
수강 신청 | ||
</Button> | ||
</styled.div> | ||
</Table> | ||
{studyList?.map((study) => ( | ||
<StudyItem key={study.studyId} study={study} /> | ||
))} | ||
</> | ||
); | ||
}; | ||
|
||
export default StudyApplyPage; | ||
|
||
const textCellStyle = css({ | ||
paddingX: "28px", | ||
}); |
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,6 @@ | ||
"use client"; | ||
const ErrorPage = () => { | ||
return <div>error</div>; | ||
}; | ||
|
||
export default ErrorPage; |
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,3 +1,5 @@ | ||
export const enum apiPath { | ||
dashboard = "/onboarding/members/me/dashboard", | ||
|
||
applyStudy = "/studies/apply", | ||
} |
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,9 @@ | ||
export const dayToKorean: Record<string, string> = { | ||
MONDAY: "월", | ||
TUESDAY: "화", | ||
WEDNESDAY: "수", | ||
THURSDAY: "목", | ||
FRIDAY: "금", | ||
SATURDAY: "토", | ||
SUNDAY: "일", | ||
}; |
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,3 +1,4 @@ | ||
export const enum tags { | ||
dashboard = "dashboard", | ||
studyApply = "studyApply", | ||
} |
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,19 @@ | ||
export interface StudyListApiResponseDto { | ||
studyId: number; | ||
title: string; | ||
studyType: string; | ||
notionLink: string; | ||
introduction: string; | ||
mentorName: string; | ||
dayOfWeek: | ||
| "MONDAY" | ||
| "TUESDAY" | ||
| "WEDNESDAY" | ||
| "THURSDAY" | ||
| "FRIDAY" | ||
| "SATURDAY" | ||
| "SUNDAY"; | ||
startTime: string; | ||
totalWeek: number; | ||
openingDate: string; | ||
} |
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.