Skip to content

Commit

Permalink
fix: admin여부에 따라 스터디 생성 박스 보이지 않도록
Browse files Browse the repository at this point in the history
  • Loading branch information
eugene028 committed Aug 13, 2024
1 parent 96dead7 commit beae0f1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
9 changes: 7 additions & 2 deletions apps/admin/components/createStudy/CreateStudyButton.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
import { css } from "@styled-system/css";
import { Flex } from "@styled-system/jsx";
import Link from "next/link";
import isAdmin from "utils/isAdmin";

const CreateStudyButton = async () => {
const adminStatus = await isAdmin();

if (!adminStatus) return null;

const CreateStudyButton = () => {
return (
<Link href="/studies/create-study">
<Link href="studies/create-study">
<button className={createStudyButtonStyle}>
<Flex gap="xs">
<p className={css({ textStyle: "label1", color: "sub" })}>
Expand Down
6 changes: 3 additions & 3 deletions apps/admin/utils/isAdmin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ import { fetcher } from "@wow-class/utils";
import { apiPath } from "constants/apiPath";
import type { DashboardApiResponseDto } from "types/dto/auth";

const isAdmin = async () => {
const isAdmin = async (): Promise<boolean> => {
const { data } = await fetcher.get<DashboardApiResponseDto>(
apiPath.dashboard
);

return data?.member.manageRole === "ADMIN";
if (data) return data?.member.manageRole === "ADMIN";
else return false;
};

export default isAdmin;

0 comments on commit beae0f1

Please sign in to comment.