Skip to content

Commit

Permalink
Merge pull request #1666 from gtech-mulearn/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
nashnsulthan authored Nov 5, 2024
2 parents eda4e92 + 2729037 commit fe6ebe1
Show file tree
Hide file tree
Showing 31 changed files with 3,633 additions and 948 deletions.
960 changes: 92 additions & 868 deletions package-lock.json

Large diffs are not rendered by default.

35 changes: 35 additions & 0 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,13 @@ import SettingsHome from "./modules/Dashboard/modules/Settings/pages/Settings/Se
import LcReportAttendee from "./modules/Dashboard/modules/LearningCircle/pages/LcDashboard/components/LcAttendeeReport";
import LcAdmin from "./modules/Dashboard/modules/LearningCircle/pages/LcAdmin/LcAdmin";
import VerifyOrganizations from "./modules/Dashboard/modules/VerifyOrganizations/VerifyOrganizations";
import CreateLC from "./modules/Dashboard/modules/LearningCircleV2/pages/CreateLC/CreateLC";
import LearningCircleLanding from "./modules/Dashboard/modules/LearningCircleV2/pages/landing/LearningCircleLanding";
import CreateLCMeetup from "./modules/Dashboard/modules/LearningCircleV2/pages/CreateLCMeetup/CreateLCMeetup";
import DashboardLC from "./modules/Dashboard/modules/LearningCircleV2/pages/dashboard/DashboardLC";
import YourLC from "./modules/Dashboard/modules/LearningCircleV2/pages/YourLC/YourLC";
import MoreInfoLC from "./modules/Dashboard/modules/LearningCircleV2/pages/moreInfoLC/MoreInfoLC";
import AttendeeReport from "./modules/Dashboard/modules/LearningCircleV2/pages/AttendeeReport/AttendeeReport";

const Profile = lazy(
() => import("./modules/Dashboard/modules/Profile/pages/Profile")
Expand Down Expand Up @@ -721,6 +728,34 @@ function App() {
path: "learning-circle",
element: <LearningCircleLandingPage />
},
{
path: "learningcircle",
element: <LearningCircleLanding />
},
{
path: "learningcircle/your-circles",
element: <YourLC />
},
{
path: "learningcircle/dashboard/:id",
element: <DashboardLC />
},
{
path: "learningcircle/create",
element: <CreateLC />
},
{
path: "learningcircle/meetup/:id",
element: <MoreInfoLC />
},
{
path: "learningcircle/attendee-report/:meet_id",
element: <AttendeeReport />
},
{
path: "learningcircle/create-meetup/:circle_id",
element: <CreateLCMeetup />
},
{
path: "learning-circle/meetup/:id",
element: <LcMeetupIfo />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,9 @@ export default function UserInterest() {
toast.success(res.data?.message.general[0]);
navigate(
ruri
? `/register/organization/?ruri=${ruri}`
? ruri == "noredirect"
? "/dashboard/profile"
: `/register/organization/?ruri=${ruri}`
: "/register/organization"
);
} catch (err: any) {
Expand Down
2 changes: 1 addition & 1 deletion src/modules/Dashboard/layouts/DashboardRootLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ const DashboardRootLayout = (props: { component?: any }) => {
icon: <i className="fi fi-sr-head-side-thinking"></i>
},
{
url: "/dashboard/learning-circle",
url: "/dashboard/learningcircle",
title: "Learning Circle",
hasView: true,
icon: <i className="fi fi-sr-books"></i>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export const getInfo = (
);
if (response.data.response?.interest_selected) {
toast.error(response.data.response?.interest_selected);
navigate("/register/interests");
navigate("/register/interests?ruri=noredirect");
}
if (setMuid) setMuid(response.data.response.muid);
if (onComplete) onComplete();
Expand Down
198 changes: 129 additions & 69 deletions src/modules/Dashboard/modules/DiscordModeration/DiscordModeration.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import React, { useEffect, useState } from 'react'
import styles from './DiscordModeration.module.css'
import React, { useEffect, useState } from "react";
import styles from "./DiscordModeration.module.css";
import SelectTab from "react-select";
import { customReactSelectStyles } from "../../utils/common";
import { getLeaderBoard, getTaskCount, getTaskList } from './services/apis';
import TableTop from '@/MuLearnComponents/TableTop/TableTop';
import { getLeaderBoard, getTaskCount, getTaskList } from "./services/apis";
import TableTop from "@/MuLearnComponents/TableTop/TableTop";
import Table from "@/MuLearnComponents/Table/Table";
import THead from "@/MuLearnComponents/Table/THead";
import Pagination from "@/MuLearnComponents/Pagination/Pagination";
import { Blank } from '@/MuLearnComponents/Table/Blank';
import { sort } from 'd3';
import { Blank } from "@/MuLearnComponents/Table/Blank";
import { sort } from "d3";

interface Option {
value: string;
Expand All @@ -25,7 +25,7 @@ type taskData = {
fullname: string;
task_name: string;
status: string;
discordlink: string
discordlink: string;
};

type leaderBoardData = {
Expand All @@ -35,35 +35,38 @@ type leaderBoardData = {
muid: string;
};


const DiscordModeration = () => {
const taskColumnOrder: ColOrder[] = [
{ column: "full_name", Label: "Fullname", isSortable: true },
{ column: "task_name", Label: "Task name", isSortable: true },
{ column: "status", Label: "Status", isSortable: true },
{ column: "discordlink", Label: "Discord link", isSortable: true },
{ column: "discordlink", Label: "Discord link", isSortable: true }
];
const leaderBoardColumnOrder: ColOrder[] = [
{ column: "name", Label: "Name", isSortable: true },
{ column: "count", Label: "Task Count", isSortable: true },
{ column: "muid", Label: "Muid", isSortable: true },
{ column: "muid", Label: "Muid", isSortable: true }
];
const options: Option[] = [
{ value: "appraiser", label: "Appraiser" },
{ value: "peer", label: "Peer" },
{ value: "peer", label: "Peer" }
];

const taskOptions: TaskOption[] = [
{ value: "all", label: "All" },
{ value: "pending", label: "Pending" },
{ value: "approved", label: "Approved" },
]
{ value: "approved", label: "Approved" }
];

const [selectedLeaderBoardOption, setSelectedLeaderBoardOption] = useState<Option | null>(options[0]);
const [selectedTaskOption, setSelectedTaskOption] = useState<TaskOption | null>(taskOptions[0]);
const [selectedLeaderBoardOption, setSelectedLeaderBoardOption] =
useState<Option | null>(options[0]);
const [selectedTaskOption, setSelectedTaskOption] =
useState<TaskOption | null>(taskOptions[0]);
const [currentTab, setCurrentTab] = useState("leaderboard");
const [taskData, setTaskData] = useState<taskData[]>([]);
const [leaderBoardData, setLeaderBoardData] = useState<leaderBoardData[]>([]);
const [leaderBoardData, setLeaderBoardData] = useState<leaderBoardData[]>(
[]
);
const [currentPageTD, setCurrentPageTD] = useState(1);
const [totalPagesTD, setTotalPagesTD] = useState(1);
const [currentPageLD, setCurrentPageLD] = useState(1);
Expand All @@ -75,8 +78,12 @@ const DiscordModeration = () => {
const [sortTD, setSortTD] = useState("-created_at");
const [sortLD, setSortLD] = useState("-created_at");
const [peerTaskCount, setpeerTaskCount] = useState<number | null>();
const [appraiserTaskCount, setappraiserTaskCount] = useState<number | null>();
const [moderatorType, setModeratorType] = useState<String | null>("appraiser");
const [appraiserTaskCount, setappraiserTaskCount] = useState<
number | null
>();
const [moderatorType, setModeratorType] = useState<String | null>(
"appraiser"
);

const handleLeaderBoardChange = (selected: Option | null) => {
setSelectedLeaderBoardOption(selected);
Expand All @@ -91,14 +98,44 @@ const DiscordModeration = () => {

//to get the leaderboard data when loading the page.
useEffect(() => {
getLeaderBoard(setLeaderBoardData,1, perPageLD,moderatorType, setTotalPagesLD, sortLD, setLoading);
getLeaderBoard(setLeaderBoardData,currentPageLD, perPageLD,moderatorType, setTotalPagesLD, `${sortLD}`, setLoading);
}, [moderatorType]);//to call the getleaderboard method when the moderatortype is changed.
getLeaderBoard(
setLeaderBoardData,
1,
perPageLD,
moderatorType,
setTotalPagesLD,
sortLD,
setLoading
);
getLeaderBoard(
setLeaderBoardData,
currentPageLD,
perPageLD,
moderatorType,
setTotalPagesLD,
`${sortLD}`,
setLoading
);
}, [moderatorType]); //to call the getleaderboard method when the moderatortype is changed.

//to get the task list & task count when loading the page.
useEffect(() => {
getTaskList(setTaskData, 1, perPageTD, setTotalPagesTD, sortTD, setLoading);
getTaskList(setTaskData, currentPageTD, perPageTD, setTotalPagesTD, `${sortTD}`, setLoading);
getTaskList(
setTaskData,
1,
perPageTD,
setTotalPagesTD,
sortTD,
setLoading
);
getTaskList(
setTaskData,
currentPageTD,
perPageTD,
setTotalPagesTD,
`${sortTD}`,
setLoading
);
getTaskCount(setpeerTaskCount, setappraiserTaskCount, setCountLoading);
}, []);

Expand All @@ -118,13 +155,7 @@ const DiscordModeration = () => {
const handlePerPageNumberTD = (selectedValueTD: number) => {
setCurrentPageTD(1);
setPerPageTD(selectedValueTD);
getTaskList(
setTaskData,
1,
selectedValueTD,
setTotalPagesTD,
"",
);
getTaskList(setTaskData, 1, selectedValueTD, setTotalPagesTD, "");
};

// pagination handling for leaderboard datas
Expand All @@ -149,11 +180,10 @@ const DiscordModeration = () => {
selectedValueLD,
moderatorType,
setTotalPagesLD,
"",
""
);
};


const handleIconClickTD = (column: string) => {
if (sortTD === column) {
setSortTD(`-${column}`);
Expand Down Expand Up @@ -207,26 +237,44 @@ const DiscordModeration = () => {
<div className={styles.DiscordModerationWrapper}>
<div className={styles.DiscordModerationContainer}>
<div className={styles.DiscordModerationRow}>
<button className={styles.DiscordModerationSwitchTab} style={{
background: currentTab === "leaderboard" ? "rgb(222, 230, 255)" : "#fff"
}} onClick={() => {
setCurrentTab("leaderboard")
}}>Leaderboard</button>
<button className={styles.DiscordModerationSwitchTab} style={{
background: currentTab != "leaderboard" ? "rgb(222, 230, 255)" : "#fff"
}} onClick={() => {
setCurrentTab("tasks")
}}>Tasks</button>
<button
className={styles.DiscordModerationSwitchTab}
style={{
background:
currentTab === "leaderboard"
? "rgb(222, 230, 255)"
: "#fff"
}}
onClick={() => {
setCurrentTab("leaderboard");
}}
>
Leaderboard
</button>
<button
className={styles.DiscordModerationSwitchTab}
style={{
background:
currentTab != "leaderboard"
? "rgb(222, 230, 255)"
: "#fff"
}}
onClick={() => {
setCurrentTab("tasks");
}}
>
Tasks
</button>
<div className={styles.DiscordModerationFrom}>
{currentTab === "leaderboard" ?
{currentTab === "leaderboard" ? (
<SelectTab
placeholder={"Select Role"}
options={options}
styles={customReactSelectStyles}
value={selectedLeaderBoardOption}
onChange={handleLeaderBoardChange}
/>
:
) : (
<SelectTab
isDisabled //currently disabled!!!
placeholder={"Select criteria"}
Expand All @@ -235,30 +283,44 @@ const DiscordModeration = () => {
value={selectedTaskOption}
onChange={handleTaskChange}
/>
}
)}
</div>
</div>

</div>
</div>
{!countLoading && <>
{currentTab === "tasks" &&
<div className={styles.DiscordModerationCountRow}>
<div className={styles.DiscordApprovalCount}>
<span className={styles.count}>{peerTaskCount}</span>
<span className={styles.txt}>tasks pending for <br /><span className={styles.highlight}>peer-approval</span></span>
</div>
<div className={styles.DiscordApprovalCount}>
<span className={styles.count}>{appraiserTaskCount}</span>
<span className={styles.txt}>tasks pending for <br /><span className={styles.highlight}>appraisal-approval</span></span>
{!countLoading && (
<>
{currentTab === "tasks" && (
<div className={styles.DiscordModerationCountRow}>
<div className={styles.DiscordApprovalCount}>
<span className={styles.count}>
{peerTaskCount}
</span>
<span className={styles.txt}>
tasks pending for <br />
<span className={styles.highlight}>
peer-approval
</span>
</span>
</div>
<div className={styles.DiscordApprovalCount}>
<span className={styles.count}>
{appraiserTaskCount}
</span>
<span className={styles.txt}>
tasks pending for <br />
<span className={styles.highlight}>
appraisal-approval
</span>
</span>
</div>
</div>
</div>
}
</>}
{currentTab === "leaderboard" ?
)}
</>
)}
{currentTab === "leaderboard" ? (
<div className={styles.DiscordModerationTable}>
<TableTop
/>
<TableTop />
<Table
rows={leaderBoardData}
page={currentPageLD}
Expand All @@ -284,10 +346,9 @@ const DiscordModeration = () => {
<Blank />
</Table>
</div>
:
) : (
<div className={styles.DiscordModerationTable}>
<TableTop
/>
<TableTop />
<Table
rows={taskData}
page={currentPageTD}
Expand All @@ -313,10 +374,9 @@ const DiscordModeration = () => {
<Blank />
</Table>
</div>
}
)}
</>
)
}

);
};

export default DiscordModeration;
Loading

0 comments on commit fe6ebe1

Please sign in to comment.