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

Add dashboard tab for Admin + basic query for mentors/mentees #164

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
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
6 changes: 6 additions & 0 deletions src/components/icons/Database.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/components/icons/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export { default as CircledCheck } from "./CircledCheck.svg";
export { default as CircledCheckSolid } from "./CircledCheckSolid.svg";
export { default as CircledCross } from "./CircledCross.svg";
export { default as Clipboard } from "./Clipboard.svg";
export { default as Database } from "./Database.svg";
export { default as Edit } from "./Edit.svg";
export { default as Filter } from "./Filter.svg";
export { default as Home } from "./Home.svg";
Expand Down
6 changes: 6 additions & 0 deletions src/layouts/TabLayout/AdminTabLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {
Clipboard,
Edit,
Home,
Database,
Settings,
User,
Users,
Expand All @@ -17,6 +18,11 @@ const AdminTabLayout: React.FC<BaseTabLayoutProps> = ({
return (
<TabLayout currentPageChildren={children}>
<PageItem label="Homepage" Icon={Home} path={joinPath(basePath)} />
<PageItem
label="Dashboard"
Icon={Database}
path={joinPath(basePath, "dashboard")}
/>
<PageItem
label="Settings"
Icon={Settings}
Expand Down
69 changes: 69 additions & 0 deletions src/pages/program/[slug]/[profileRoute]/dashboard.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
import React, { Fragment } from "react";
import { Card, Text } from "../../../../components/atomic";
import {
ProfileType,
useGetProfilesQuery,
} from "../../../../generated/graphql";
import { AuthorizationLevel, useCurrentProgram } from "../../../../hooks";
import AuthorizationWrapper from "../../../../layouts/AuthorizationWrapper";
import ChooseTabLayout from "../../../../layouts/ChooseTabLayout";
import PageContainer from "../../../../layouts/PageContainer";
import Page from "../../../../types/Page";

const DashboardPage: Page = () => {
const { currentProgram } = useCurrentProgram();
const { programId } = currentProgram || {
programId: ""
};

const mentors = useGetProfilesQuery({
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice!

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks! code in settings.tsx was very helpful B)

variables: {
programId: programId,
profileType: ProfileType.Mentor,
},
});

const mentees = useGetProfilesQuery({
variables: {
programId: programId,
profileType: ProfileType.Mentee,
},
});

if (!currentProgram || mentors.error || mentees.error) return <Fragment />;

return (
<Fragment>
<Text h2 b>
Dashboard
</Text>
<div className="h-4"></div>
<Card className="flex flex-col p-12 space-y-6 overflow-y-auto">
<div className="grid grid-cols-4 gap-4 justify-center items-center">
<Text b secondary className="col-span-1">
Mentors (#):
</Text>
<Text b>
{mentors.data?.getProfiles.length}
</Text>
<Text b secondary className="col-span-1">
Mentees (#):
</Text>
<Text b>
{mentees.data?.getProfiles.length}
</Text>
</div>
</Card>
</Fragment>
);
};

DashboardPage.getLayout = (page, pageProps) => (
<AuthorizationWrapper canView={[AuthorizationLevel.Admin]}>
<ChooseTabLayout {...pageProps}>
<PageContainer>{page}</PageContainer>
</ChooseTabLayout>
</AuthorizationWrapper>
);

export default DashboardPage;