Skip to content
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

[Feature] 내비게이션 바 역할에 따라 멘토 페이지 전환 버튼 보여주기 여부 조정 #58

Merged
merged 5 commits into from
Aug 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions apps/client/apis/dashboardApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,18 @@ export const dashboardApi = {
apiPath.dashboard,
{
next: { tags: [tags.dashboard] },
cache: "no-store",
}
);

const memberRole = response.data?.member.role;
const {
role: memberRole,
manageRole,
studyRole,
} = response.data?.member || {};
const currentRecruitmentOpen =
response.data?.currentRecruitmentRound?.period.open || false;

return { memberRole, currentRecruitmentOpen };
return { memberRole, currentRecruitmentOpen, manageRole, studyRole };
},
};
23 changes: 16 additions & 7 deletions apps/client/components/Navbar.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { css } from "@styled-system/css";
import { Flex } from "@styled-system/jsx";
import { NavItem } from "@wow-class/ui";
import { dashboardApi } from "apis/dashboardApi";
import { routePath } from "constants/routePath";
import Image from "next/image";

import { navMenu } from "../constants/navMenu";
Expand All @@ -11,7 +13,12 @@ import logoImageUrl from "../public/images/logo.svg";
* @description client 내비게이션 바 컴포넌트입니다.
*/

const Navbar = () => {
const Navbar = async () => {
const { manageRole, studyRole } = await dashboardApi.getDashboardInfo();

const showConvertToMentorPageButton =
manageRole === "ADMIN" || studyRole === "MENTOR";

return (
<aside aria-label="client navigation bar" className={navbarContainerStyle}>
<Flex align="center" gap={8} padding="6px 0px 7px 20px">
Expand Down Expand Up @@ -41,12 +48,14 @@ const Navbar = () => {
/>
))}
</ul>
<NavItem
alt="administrator-icon"
href=""
imageUrl={adminImageUrl}
name="멘토 페이지로 전환"
/>
{showConvertToMentorPageButton && (
<NavItem
alt="administrator-icon"
href={routePath.admin || ""}
imageUrl={adminImageUrl}
name="멘토 페이지로 전환"
/>
)}
</nav>
</aside>
);
Expand Down
8 changes: 4 additions & 4 deletions apps/client/constants/navMenu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,27 @@ import scheduleImageUrl from "../public/images/schedule.svg";

export const navMenu = [
{
href: "my-study",
href: "/my-study",
imageUrl: homeImageUrl,
alt: "home-icon",
name: "나의 스터디",
items: [
{
href: "my-assignment",
href: "/my-assignment",
imageUrl: folderImageUrl,
alt: "folder-icon",
name: "나의 과제",
},
],
},
{
href: "study-apply",
href: "/study-apply",
imageUrl: scheduleImageUrl,
alt: "schedule-icon",
name: "수강 신청",
},
{
href: "my-page",
href: "/my-page",
imageUrl: personImageUrl,
alt: "person-icon",
name: "마이 페이지",
Expand Down
4 changes: 4 additions & 0 deletions apps/client/constants/routePath.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,8 @@ export const routePath = {
["my-page-logout"]: "/my-page/logout",
onboarding: "https://onboarding.gdschongik.com",
github: "https://github.com",
admin:
process.env.NODE_ENV === "production"
? "https://mentor.study.gdschongik.com"
: "https://dev-mentor.study.gdschongik.com",
} as const;
6 changes: 1 addition & 5 deletions apps/client/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,7 @@ const middleware = async (req: NextRequest) => {
return NextResponse.redirect(new URL(routePath.auth, req.url));
}

const response = NextResponse.next();

response.headers.set("Authorization", `Bearer ${accessToken}`);

return response;
return NextResponse.next();
};

export default middleware;
2 changes: 1 addition & 1 deletion apps/client/types/dtos/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type { StatusType } from "types/entities/common/auth";
export interface DashboardApiResponseDto {
member: {
memberId: number;
role: "GUEST" | "ADMIN" | "REGULAR";
role: "GUEST" | "ASSOCIATE" | "REGULAR";
manageRole: "ADMIN" | "NONE";
studyRole: "MENTOR" | "STUDENT";
basicInfo: {
Expand Down
4 changes: 2 additions & 2 deletions packages/ui/src/components/NavItem/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ const NavItem = ({ href, imageUrl, alt, name, items }: NavItemProps) => {
aria-controls={items ? `${name}-submenu` : undefined}
aria-expanded={expanded ? "true" : "false"}
aria-haspopup={items?.length && items.length > 1 ? "true" : undefined}
href={`/${href}`}
href={`${href}`}
role="menuitem"
tabIndex={0}
className={navItemStyle({
Expand Down Expand Up @@ -91,7 +91,7 @@ const NavItem = ({ href, imageUrl, alt, name, items }: NavItemProps) => {
<li key={item.name} role="none">
<Link
aria-label={item.name}
href={`/${href}/${item.href}`}
href={`${href}/${item.href}`}
role="menuitem"
style={{ padding: "11px 36px" }}
className={navItemStyle({
Expand Down
Loading