Skip to content
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
1 change: 1 addition & 0 deletions .github/workflows/staging-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
push:
branches:
- development
workflow_dispatch:
jobs:
deploy:
name: Deploy to staging
Expand Down
4 changes: 2 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="description" content="Race against time with automation" />
<meta property="og:title" content="Bashaway | 2024" />
<meta property="og:title" content="Bashaway | 2025" />
<meta property="og:description" content="Race against time with automation" />
<meta property="og:image" content="https://admin.bashaway.sliitfoss.org/assets/icons/favicon.svg" />
<meta property="og:image:width" content="64" />
Expand All @@ -25,7 +25,7 @@
<meta property="twitter:title" content="Bashaway Competitor Portal">
<meta property="twitter:description" content="Race against time with automation">
<meta property="twitter:card" content="summary_large_image">
<title>Bashaway | 2024</title>
<title>Bashaway | 2025</title>
</head>

<body>
Expand Down
21 changes: 21 additions & 0 deletions src/components/dashboard/registrations.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,32 @@ const RegistrationChart = ({ round, ghostLegion }) => {
const labels = [],
data = [],
colors = [];

// Group universities by normalized (lowercase) name to handle case-insensitive aggregation
const universityMap = new Map();

registrationInfo?.university_counts?.forEach((university) => {
if (!university.name) return; // Skip entries with null or undefined names

const normalizedName = university.name.toLowerCase();
if (universityMap.has(normalizedName)) {
const existing = universityMap.get(normalizedName);
existing.count += university.count;
} else {
universityMap.set(normalizedName, {
name: university.name,
count: university.count
});
}
});

// Convert map to arrays for the chart
universityMap.forEach((university) => {
labels.push(university.name);
data.push(university.count);
colors.push("#ffcccc");
});

return { labels, data, colors };
}, [registrationInfo]);

Expand Down
57 changes: 57 additions & 0 deletions src/components/questions/bulk-status-dialog.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import { useSelector } from "react-redux";
import { store } from "@/store";
import { useBulkUpdateQuestionStatusMutation } from "@/store/api";
import { toggleBulkStatusDialog } from "@/store/reducers/ui/question";
import {
AlertDialog,
AlertDialogContent,
AlertDialogDescription,
AlertDialogFooter,
AlertDialogHeader,
AlertDialogTitle,
Button,
toast
} from "@sliit-foss/bashaway-ui/components";

const close = () => store.dispatch(toggleBulkStatusDialog({ open: false }));

const BulkStatusDialog = ({ refresh }) => {
const { open, enabled } = useSelector((store) => store.ui.question.bulkStatusDialog);

const [bulkUpdateStatus, { isLoading }] = useBulkUpdateQuestionStatusMutation();

const handleConfirm = async () => {
await bulkUpdateStatus({ enabled })
.unwrap()
.then((res) => {
toast({ title: res.message });
close();
refresh();
});
};

const action = enabled ? "enable" : "disable";

return (
<AlertDialog open={open} onOpenChange={(open) => !open && close()}>
<AlertDialogContent overlayClassName="z-[201]" className="z-[201]">
<AlertDialogHeader>
<AlertDialogTitle>Confirm Bulk {enabled ? "Enable" : "Disable"}</AlertDialogTitle>
<AlertDialogDescription>
Are you sure you want to {action} ALL questions? This action will affect all questions in the system.
</AlertDialogDescription>
</AlertDialogHeader>
<AlertDialogFooter className="mt-4">
<Button onClick={handleConfirm} loading={isLoading}>
Yes, {action} all
</Button>
<Button variant="secondary" onClick={close}>
Cancel
</Button>
</AlertDialogFooter>
</AlertDialogContent>
</AlertDialog>
);
};

export default BulkStatusDialog;
1 change: 1 addition & 0 deletions src/components/questions/index.jsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export * from "./question";
export * from "./question-details";
export { default as QuestionDialog } from "./dialog";
export { default as BulkStatusDialog } from "./bulk-status-dialog";
5 changes: 4 additions & 1 deletion src/components/questions/question/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@ export const Question = ({ question }) => {
<div className="flex flex-wrap gap-3 [&>span]:px-3 [&>span]:py-2 [&>span]:rounded-lg [&>span]:transition-all [&>span]:duration-medium">
<Footnote>{startCase(question.difficulty.toLowerCase())}</Footnote>
<Footnote>{question.max_score}PT</Footnote>
{question.constraints?.length && <Footnote>{question.constraints?.join(", ")}</Footnote>}
{question.constraints?.length > 0 && <Footnote>{question.constraints?.join(", ")}</Footnote>}
<Footnote className={question.enabled ? "!bg-green-500/20 !text-green-700" : "!bg-red-500/20 !text-red-700"}>
{question.enabled ? "Enabled" : "Disabled"}
</Footnote>
</div>
</div>
</Link>
Expand Down
2 changes: 1 addition & 1 deletion src/components/submissions/grade-dialog.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const GradeDialog = ({ refresh }) => {
})
.unwrap()
.then(() => {
toast({ title: `Question updated successfully` });
toast({ title: `Submission graded successfully` });
close();
refresh();
});
Expand Down
4 changes: 4 additions & 0 deletions src/components/users/dialog.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ const UserDialog = ({ refresh }) => {

const handleSubmit = async (e) => {
e.preventDefault();
if (!role) {
toast({ variant: "destructive", title: "Please select a role" });
return;
}
await addUser({
name: e.target.name.value,
email: e.target.email.value,
Expand Down
7 changes: 4 additions & 3 deletions src/components/users/user/index.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { GraduationCap, Power, Settings } from "lucide-react";
import { View } from "lucide-react";
import { twMerge } from "tailwind-merge";
import { store } from "@/store";
import { useUpdateUserMutation, userApi } from "@/store/api";
Expand Down Expand Up @@ -54,7 +55,7 @@ export const User = ({ user }) => {
<Body2 className="font-bold font-inter transition-all duration-medium text-start">{user.name}</Body2>
<Callout className="lg:text-[18px] text-start">{user.email}</Callout>
<div className="w-full sm:w-auto flex flex-col sm:flex-row gap-3 text-sm sm:text-base items-center text-black/40">
{user.role !== "ADMIN" ? (
{user.role === "GROUP" ? (
<>
<Metric
metric={<GraduationCap size={16} />}
Expand All @@ -75,13 +76,13 @@ export const User = ({ user }) => {
</>
) : (
<Metric
metric={<Settings size={16} />}
metric={user.role == "ADMIN" ? <Settings size={16} /> : <View size={16} />}
styles={{
root: "h-full card-red-body",
metric: "w-auto flex h-full flex justify-center items-center text-black card-red-title",
animate: "w-full"
}}
value="ADMIN"
value={user.role}
/>
)}
</div>
Expand Down
21 changes: 20 additions & 1 deletion src/filters/question.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,37 @@ export const questionFilters = [
label: "Extreme"
}
]
},
{
key: "enabled",
label: "Status",
options: [
{
key: "true",
label: "Enabled"
},
{
key: "false",
label: "Disabled"
}
]
}
];

export const questionSorts = [
{
key: "max_score",
label: "Sort by points",
direction: 0
direction: -1
},
{
key: "created_at",
label: "Sort by upload time",
direction: -1
},
{
key: "name",
label: "Sort by name",
direction: 1
}
];
21 changes: 20 additions & 1 deletion src/filters/submission.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,20 @@ export const submissionFilters = [
label: "Not Graded"
}
]
},
{
key: "automatically_graded",
label: "Grading Type",
options: [
{
key: "true",
label: "Auto Graded"
},
{
key: "false",
label: "Manually Graded"
}
]
}
];

Expand All @@ -29,6 +43,11 @@ export const submissionSorts = [
{
key: "score",
label: "Sort by score",
direction: 0
direction: -1
},
{
key: "updated_at",
label: "Sort by last updated",
direction: -1
}
];
2 changes: 1 addition & 1 deletion src/hooks/auth.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const useAuth = () => {
navigate("/");
}
setCompleted(true);
}, [location]);
}, [location, navigate]);

return completed;
};
Expand Down
40 changes: 30 additions & 10 deletions src/pages/questions.jsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { useState } from "react";
import { Plus } from "lucide-react";
import { Question, QuestionDialog, QuestionGridSkeleton } from "@/components/questions";
import { Ban, Plus, Power } from "lucide-react";
import { BulkStatusDialog, Question, QuestionDialog, QuestionGridSkeleton } from "@/components/questions";
import { questionFilters, questionSorts } from "@/filters";
import { useTitle } from "@/hooks";
import { store } from "@/store";
import { useAuthUserQuery, useGetQuestionsQuery, useLazyGetQuestionsQuery } from "@/store/api";
import { setSelectedQuestion, toggleAddQuestionDialog } from "@/store/reducers/ui/question";
import { setSelectedQuestion, toggleAddQuestionDialog, toggleBulkStatusDialog } from "@/store/reducers/ui/question";
import { AnimatedSwitcher, Button, Filters, NoRecords, Pagination, Sorts } from "@sliit-foss/bashaway-ui/components";
import { computeFilterQuery, computeSortQuery } from "@sliit-foss/bashaway-ui/utils";

Expand All @@ -29,20 +29,39 @@ const Questions = () => {

const refresh = () => trigger({ filters, sorts, page });

const openBulkStatusDialog = (enabled) => {
store.dispatch(toggleBulkStatusDialog({ open: true, enabled }));
};

useTitle("Challenges | Bashaway");

return (
<>
<div className="w-full flex flex-col justify-center items-center gap-6 mb-8 mt-4">
<div className="w-full flex flex-col md:flex-row gap-6">
{authUser?.role === "ADMIN" && (
<Button
className="w-full md:w-5/12 lg:w-4/12 xl:w-3/12 2xl:w-2/12 py-[13px] sm:py-4 md:py-1.5"
onClick={onAddClick}
>
<Plus strokeWidth="2.5" />
Add Question
</Button>
<div className="flex gap-3 shrink-0">
<Button className="py-[13px] sm:py-4 md:py-1.5 whitespace-nowrap" onClick={onAddClick}>
<Plus strokeWidth="2.5" />
Add Question
</Button>
<Button
className="py-[13px] sm:py-4 md:py-1.5 whitespace-nowrap"
variant="secondary"
onClick={() => openBulkStatusDialog(false)}
>
<Ban size={18} strokeWidth="2.5" />
Disable All
</Button>
<Button
className="py-[13px] sm:py-4 md:py-1.5 whitespace-nowrap"
variant="secondary"
onClick={() => openBulkStatusDialog(true)}
>
<Power size={18} strokeWidth="2.5" />
Enable All
</Button>
</div>
)}
<Filters filters={questionFilters} setFilterQuery={setFilters} />
</div>
Expand Down Expand Up @@ -73,6 +92,7 @@ const Questions = () => {
</div>
</div>
<QuestionDialog refresh={refresh} />
<BulkStatusDialog refresh={refresh} />
</>
);
};
Expand Down
6 changes: 5 additions & 1 deletion src/store/api/question.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ export const questionApi = createApi({
}),
updateQuestion: builder.mutation({
query: ({ id, data }) => patch(`/api/questions/${id}`, data)
}),
bulkUpdateQuestionStatus: builder.mutation({
query: (data) => patch(`/api/questions/bulk/status`, data)
})
})
});
Expand All @@ -39,5 +42,6 @@ export const {
useGetQuestionByIdQuery,
useLazyGetQuestionByIdQuery,
useAddQuestionMutation,
useUpdateQuestionMutation
useUpdateQuestionMutation,
useBulkUpdateQuestionStatusMutation
} = questionApi;
11 changes: 9 additions & 2 deletions src/store/reducers/ui/question.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@ import { createSlice } from "@reduxjs/toolkit";

const initialState = {
selected: null,
showAddQuestionDialog: false
showAddQuestionDialog: false,
bulkStatusDialog: {
open: false,
enabled: false
}
};

export const slice = createSlice({
Expand All @@ -14,10 +18,13 @@ export const slice = createSlice({
},
toggleAddQuestionDialog(state, action) {
state.showAddQuestionDialog = action.payload;
},
toggleBulkStatusDialog(state, action) {
state.bulkStatusDialog = action.payload;
}
}
});

export const { setSelectedQuestion, toggleAddQuestionDialog } = slice.actions;
export const { setSelectedQuestion, toggleAddQuestionDialog, toggleBulkStatusDialog } = slice.actions;

export default slice.reducer;