Skip to content

Commit

Permalink
Feat: added ghost legion
Browse files Browse the repository at this point in the history
  • Loading branch information
Akalanka47000 committed Oct 15, 2023
1 parent 6429b0a commit aed54b8
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 20 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"dependencies": {
"@azure/storage-blob": "12.15.0",
"@reduxjs/toolkit": "1.9.5",
"@sliit-foss/bashaway-ui": "0.10.6",
"@sliit-foss/bashaway-ui": "0.12.3",
"async-mutex": "^0.4.0",
"chart.js": "4.4.0",
"framer-motion": "10.14.0",
Expand Down
8 changes: 4 additions & 4 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 25 additions & 0 deletions src/components/dashboard/ghost-legion.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { twMerge } from "tailwind-merge";
import { Ghost } from "@sliit-foss/bashaway-ui/icons";

const GhostLegion = ({ ghostLegion, toggleGhostLegion, round }) => {
return (
<div
className={twMerge(
"group transition-all duration-medium rounded-full cursor-pointer flex justify-center items-center",
ghostLegion ? "bg-[#f00]" : "bg-gray-200 hover:bg-[#f00]",
round === 2 ? "w-12 h-12 opacity-100 p-2" : "w-0 h-0 opacity-0 p-0"
)}
onClick={toggleGhostLegion}
>
<Ghost
className={twMerge(
"transition-all duration-medium fill-current",
ghostLegion ? "text-white" : "text-black group-hover:text-white",
round === 2 ? "w-6 h-6 opacity-100" : "w-0 h-0 opacity-0"
)}
/>
</div>
);
};

export default GhostLegion;
1 change: 1 addition & 0 deletions src/components/dashboard/index.jsx
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export { default as DashboardCard } from "./card";
export { default as GhostLegion } from "./ghost-legion";
export { default as RegistrationChart } from "./registrations";
4 changes: 2 additions & 2 deletions src/components/dashboard/registrations.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ import { Body2 } from "@sliit-foss/bashaway-ui/typography";

ChartJS.register(CategoryScale, LinearScale, BarElement, ArcElement, Title, Tooltip, Legend, Filler);

const RegistrationChart = ({ round }) => {
const { data: { data: registrationInfo } = {} } = useGetRegistrationInfoQuery({ round });
const RegistrationChart = ({ round, ghostLegion }) => {
const { data: { data: registrationInfo } = {} } = useGetRegistrationInfoQuery({ round, ghostLegion });

const { md, lg } = useBreakpoint();

Expand Down
19 changes: 12 additions & 7 deletions src/pages/dashboard.jsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
import { useMemo } from "react";
import { DashboardCard, RegistrationChart } from "@/components/dashboard";
import { DashboardCard, GhostLegion, RegistrationChart } from "@/components/dashboard";
import { useTitle } from "@/hooks";
import { Building, Folder, UserGroup, Users, Users2 } from "@/icons";
import { useGetQuestionSubmissionsQuery, useGetRegistrationInfoQuery, useGetTeamSubmissionsQuery } from "@/store/api";
import { TwinSwitch } from "@sliit-foss/bashaway-ui/components";
import { useRound } from "@sliit-foss/bashaway-ui/hooks";
import { useGhostLegion, useRound } from "@sliit-foss/bashaway-ui/hooks";
import { Title } from "@sliit-foss/bashaway-ui/typography";

const Dashboard = () => {
const { rounds, round, roundKey, onRoundChange } = useRound();

const { data: { data: registrationInfo } = {} } = useGetRegistrationInfoQuery({ round });
const { data: { data: questionSubmissionInfo } = {} } = useGetQuestionSubmissionsQuery({ round });
const { data: { data: teamSubmissionInfo } = {} } = useGetTeamSubmissionsQuery({ round });
const { ghostLegion, toggleGhostLegion } = useGhostLegion();

const { data: { data: registrationInfo } = {} } = useGetRegistrationInfoQuery({ round, ghostLegion });
const { data: { data: questionSubmissionInfo } = {} } = useGetQuestionSubmissionsQuery({ round, ghostLegion });
const { data: { data: teamSubmissionInfo } = {} } = useGetTeamSubmissionsQuery({ round, ghostLegion });

useTitle("Dashboard | Bashaway");

Expand All @@ -23,7 +25,10 @@ const Dashboard = () => {

return (
<div className="w-full min-h-[60vh] flex flex-col gap-7 items-start">
<TwinSwitch values={rounds} className="mx-auto mb-3" onChange={onRoundChange} selectedValue={roundKey} />
<div className="w-full flex justify-center items-center gap-4 mb-3">
<TwinSwitch values={rounds} className="" onChange={onRoundChange} selectedValue={roundKey} />
<GhostLegion ghostLegion={ghostLegion} toggleGhostLegion={toggleGhostLegion} round={round} />
</div>
<div className="w-full h-full grid grid-cols-2 md:grid-cols-3 lg:grid-cols-5 justify-start items-start gap-5">
<DashboardCard icon={Building} title="Universities" value={registrationInfo?.university_counts?.length} />
<DashboardCard icon={Users} title="Teams" value={registrationInfo?.total_registrations} />
Expand All @@ -37,7 +42,7 @@ const Dashboard = () => {
/>
</div>
<Title>Statistics</Title>
<RegistrationChart round={round} />
<RegistrationChart round={round} ghostLegion={ghostLegion} />
</div>
);
};
Expand Down
11 changes: 5 additions & 6 deletions src/store/api/dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,15 @@ export const dashboardApi = createApi({
baseQuery,
endpoints: (builder) => ({
getRegistrationInfo: builder.query({
query: ({ round, ghost_legion = false }) =>
`/api/dashboard/registrations?round=${round}&ghost_legion=${ghost_legion}`
query: ({ round, ghostLegion = false }) =>
`/api/dashboard/registrations?round=${round}&ghost_legion=${ghostLegion}`
}),
getQuestionSubmissions: builder.query({
query: ({ round, ghost_legion = false }) =>
`/api/dashboard/submissions?round=${round}&ghost_legion=${ghost_legion}`
query: ({ round, ghostLegion = false }) => `/api/dashboard/submissions?round=${round}&ghost_legion=${ghostLegion}`
}),
getTeamSubmissions: builder.query({
query: ({ round, ghost_legion = false }) =>
`/api/dashboard/submissions/team?round=${round}&ghost_legion=${ghost_legion}`
query: ({ round, ghostLegion = false }) =>
`/api/dashboard/submissions/team?round=${round}&ghost_legion=${ghostLegion}`
})
})
});
Expand Down

0 comments on commit aed54b8

Please sign in to comment.