-
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.
- Loading branch information
Showing
40 changed files
with
494 additions
and
331 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { fetcher } from "@wow-class/utils"; | ||
import { apiPath } from "constants/apiPath"; | ||
import { tags } from "constants/tags"; | ||
import type { DashboardApiResponseDto } from "types/dtos/auth"; | ||
|
||
export const dashboardApi = { | ||
getDashboardInfo: async () => { | ||
const response = await fetcher.get<DashboardApiResponseDto>( | ||
apiPath.dashboard, | ||
{ | ||
next: { tags: [tags.dashboard] }, | ||
} | ||
); | ||
|
||
const studyRole = response.data?.member.studyRole; | ||
const manageRole = response.data?.member.manageRole; | ||
|
||
return { studyRole, manageRole }; | ||
}, | ||
}; |
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
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,5 @@ | ||
const NotFound = () => { | ||
return <div>요청하신 페이지를 찾을 수 없어요.</div>; | ||
}; | ||
|
||
export default NotFound; |
55 changes: 55 additions & 0 deletions
55
apps/admin/app/studies/create-study/_components/CreateStudyButton.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,55 @@ | ||
import { css } from "@styled-system/css"; | ||
import { Flex } from "@styled-system/jsx"; | ||
import Link from "next/link"; | ||
import isAdmin from "utils/isAdmin"; | ||
import { Plus } from "wowds-icons"; | ||
|
||
const CreateStudyButton = async () => { | ||
const adminStatus = await isAdmin(); | ||
|
||
if (!adminStatus) return null; | ||
|
||
return ( | ||
<Link href="studies/create-study"> | ||
<button className={createStudyButtonStyle}> | ||
<Flex gap="xs"> | ||
<p className={css({ textStyle: "label1", color: "sub" })}> | ||
새로운 스터디 개설하기 | ||
</p> | ||
<div className={PlusIconStyle}> | ||
<Plus height={14} width={14} /> | ||
</div> | ||
</Flex> | ||
</button> | ||
</Link> | ||
); | ||
}; | ||
|
||
export default CreateStudyButton; | ||
|
||
const createStudyButtonStyle = css({ | ||
width: "100%", | ||
display: "flex", | ||
justifyContent: "center", | ||
borderRadius: "md", | ||
borderStyle: "dashed", | ||
borderWidth: "1px", | ||
borderColor: "outline", | ||
padding: "32px", | ||
_hover: { | ||
backgroundColor: "backgroundAlternative", | ||
borderWidth: "0px", | ||
cursor: "pointer", | ||
}, | ||
}); | ||
|
||
const PlusIconStyle = css({ | ||
display: "flex", | ||
justifyContent: "center", | ||
alignItems: "center", | ||
width: "20px", | ||
height: "20px", | ||
borderRadius: "full", | ||
backgroundColor: "primary", | ||
color: "white", | ||
}); |
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,5 @@ | ||
const CreateStudyPage = () => { | ||
return <div>스터디 생성</div>; | ||
}; | ||
|
||
export default CreateStudyPage; |
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 { Flex, styled } from "@styled-system/jsx"; | ||
import Navbar from "components/Navbar"; | ||
const StudiesLayout = ({ | ||
children, | ||
}: Readonly<{ | ||
children: React.ReactNode; | ||
}>) => { | ||
return ( | ||
<> | ||
<Navbar /> | ||
<styled.div padding="54px 101px" width="100%"> | ||
<Flex direction="column" gap="sm" width="100%"> | ||
{children} | ||
</Flex> | ||
</styled.div> | ||
</> | ||
); | ||
}; | ||
|
||
export default StudiesLayout; |
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,5 +1,17 @@ | ||
const Studies = () => { | ||
return <div>Studies</div>; | ||
import { css } from "@styled-system/css"; | ||
import { Flex } from "@styled-system/jsx"; | ||
|
||
import CreateStudyButton from "./create-study/_components/CreateStudyButton"; | ||
|
||
const StudiesPage = () => { | ||
return ( | ||
<> | ||
<Flex align="center" justifyContent="space-between"> | ||
<p className={css({ textStyle: "h1" })}>개설된 스터디</p> | ||
</Flex> | ||
<CreateStudyButton /> | ||
</> | ||
); | ||
}; | ||
|
||
export default Studies; | ||
export default StudiesPage; |
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,3 @@ | ||
export const enum apiPath { | ||
dashboard = "/onboarding/members/me/dashboard", | ||
} |
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,3 @@ | ||
export const enum tags { | ||
dashboard = "dashboard", | ||
} |
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,32 @@ | ||
import { dashboardApi } from "apis/auth/dashboardApi"; | ||
import { cookies } from "next/headers"; | ||
import type { NextRequest } from "next/server"; | ||
import { NextResponse } from "next/server"; | ||
|
||
export const config = { | ||
matcher: ["/studies/:path*", "/participants/:path*"], | ||
}; | ||
|
||
const middleware = async (req: NextRequest) => { | ||
const cookieStore = cookies(); | ||
const accessToken = cookieStore.get("accessToken")?.value; | ||
|
||
if (!accessToken) { | ||
return NextResponse.redirect(new URL("/not-found", req.url)); | ||
} | ||
|
||
const { studyRole, manageRole } = await dashboardApi.getDashboardInfo(); | ||
|
||
if (studyRole === "STUDENT" && manageRole === "NONE") { | ||
const url = | ||
process.env.NODE_ENV === "production" | ||
? process.env.CLIENT_PROD_URL | ||
: process.env.CLIENT_DEV_URL; | ||
|
||
return NextResponse.redirect(new URL("/auth", url)); | ||
} | ||
|
||
return NextResponse.next(); | ||
}; | ||
|
||
export default middleware; |
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,47 @@ | ||
import type { StatusType } from "../entities/auth"; | ||
|
||
export interface DashboardApiResponseDto { | ||
member: { | ||
memberId: number; | ||
role: "GUEST" | "ADMIN" | "REGULAR"; | ||
manageRole: "ADMIN" | "NONE"; | ||
studyRole: "MENTOR" | "STUDENT"; | ||
basicInfo: { | ||
name: string; | ||
studentId: string; | ||
email: string; | ||
department: string; | ||
phone: string; | ||
discordUsername: string; | ||
nickname: string; | ||
}; | ||
associateRequirement: { | ||
univStatus: StatusType; | ||
discordStatus: Extract<StatusType, "UNSATISFIED" | "SATISFIED">; | ||
bevyStatus: Extract<StatusType, "UNSATISFIED" | "SATISFIED">; | ||
infoStatus: Extract<StatusType, "UNSATISFIED" | "SATISFIED">; | ||
}; | ||
}; | ||
currentRecruitmentRound: { | ||
recruitmentId: number; | ||
name: string; | ||
period: { | ||
startDate: string; | ||
endDate: string; | ||
open: boolean; | ||
}; | ||
fee: number; | ||
roundType: "FIRST" | "SECOND"; | ||
roundTypeValue: string; | ||
}; | ||
currentMembership: { | ||
membershipId: number; | ||
memberId: number; | ||
recruitmentId: number; | ||
regularRequirement: { | ||
paymentStatus: Extract<StatusType, "UNSATISFIED" | "SATISFIED">; | ||
paymentSatisfied: boolean; | ||
allSatisfied: boolean; | ||
}; | ||
}; | ||
} |
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 type StatusType = "UNSATISFIED" | "IN_PROGRESS" | "SATISFIED"; |
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,3 @@ | ||
export type ManageRole = "ADMIN" | "NONE"; | ||
export type StudyRole = "MENTOR" | "STUDENT"; | ||
export type UserRoleType = "GUEST" | "ASSOCIATE" | "REGULAR"; |
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,2 @@ | ||
export type Status = "UNSATISFIED" | "SATISFIED"; | ||
export type UnivEmailStatus = "IN_PROGRESS" | "UNSATISFIED" | "SATISFIED"; |
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 type { ManageRole, StudyRole, UserRoleType } from "./role"; | ||
import type { Status, UnivEmailStatus } from "./status"; | ||
|
||
export type User = { | ||
memberId: string; // C000000 (학번) | ||
role: UserRoleType; | ||
basicInfo: UserBasicInfo; | ||
manageRole: ManageRole; | ||
studyRole: StudyRole; | ||
associateRequirement: { | ||
univStatus: UnivEmailStatus; | ||
discordStatus: Status; | ||
bevyStatus: Status; | ||
infoStatus: Status; | ||
}; | ||
}; | ||
|
||
export type AssociateRequirement = { | ||
univStatus: UnivEmailStatus; | ||
discordStatus: Status; | ||
bevyStatus: Status; | ||
infoStatus: Status; | ||
}; | ||
|
||
export type UserBasicInfo = { | ||
name: string; | ||
studentId: string; | ||
email: string; | ||
department: string; | ||
phone: string; | ||
discordUsername: string; | ||
nickname: 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { dashboardApi } from "apis/auth/dashboardApi"; | ||
|
||
const isAdmin = async (): Promise<boolean> => { | ||
const { manageRole } = await dashboardApi.getDashboardInfo(); | ||
return manageRole === "ADMIN"; | ||
}; | ||
|
||
export default isAdmin; |
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
Oops, something went wrong.