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

SCRUM-47 Basic information about Carpool Group #128

Merged
merged 51 commits into from
Dec 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
17d086a
Backend logic working, now just frontend edits remaining
sinhaaaryan Nov 18, 2024
b33bead
Various changes to group page + changes to DB to support more charact…
sinhaaaryan Nov 19, 2024
9bedbd1
Minor changes on rider side group page when in group
sinhaaaryan Nov 20, 2024
dabc6dd
Fixed tsc + lint errors
sinhaaaryan Nov 21, 2024
549694c
Backend logic working, now just frontend edits remaining
sinhaaaryan Nov 18, 2024
f87d963
Various changes to group page + changes to DB to support more charact…
sinhaaaryan Nov 19, 2024
6fd35e8
Minor changes on rider side group page when in group
sinhaaaryan Nov 20, 2024
2519c6e
Fixed tsc + lint errors
sinhaaaryan Nov 21, 2024
5304a86
rebased off staging
sinhaaaryan Nov 21, 2024
b731e4b
rebased changes from email.ts
sinhaaaryan Nov 21, 2024
e1a280a
FTUE tracking + view route event fix
matherg Nov 22, 2024
b5ad2ff
Merge pull request #130 from sandboxnu/mixpanelFTUE
sinhaaaryan Nov 22, 2024
4ce2c52
Changes per review
sinhaaaryan Nov 25, 2024
6a7e4cd
Admin dashboard initial setup
matherg Nov 25, 2024
6e2db62
Admin setup and perm management done
matherg Nov 26, 2024
cece952
hide overflow
matherg Nov 26, 2024
6d9859e
missed file
matherg Nov 26, 2024
317b07f
Merge pull request #132 from sandboxnu/adminInitial
matherg Nov 26, 2024
f546506
Logic improvement for admin users + tooltip
matherg Nov 26, 2024
1a00643
Admin Charts
matherg Nov 26, 2024
75ab43d
Both charts fully implemented
matherg Nov 27, 2024
a6e5432
Slider step by week
matherg Nov 27, 2024
20ad307
End range of slider inclusive
matherg Nov 27, 2024
11b51b7
Merge pull request #133 from sandboxnu/adminData
matherg Nov 27, 2024
c458bf5
Inactive user settings, main is overwhelmed otherwise
matherg Nov 27, 2024
69860fb
Added toast popup, blocks drivers from switching roles in a group
matherg Dec 2, 2024
f9f6f20
Merge pull request #136 from sandboxnu/SCRUM-125
sinhaaaryan Dec 3, 2024
86b3622
Backend logic working, now just frontend edits remaining
sinhaaaryan Nov 18, 2024
d596dd3
Various changes to group page + changes to DB to support more charact…
sinhaaaryan Nov 19, 2024
c9151bd
Minor changes on rider side group page when in group
sinhaaaryan Nov 20, 2024
f0fe5c6
Fixed tsc + lint errors
sinhaaaryan Nov 21, 2024
fd1d453
Backend logic working, now just frontend edits remaining
sinhaaaryan Nov 18, 2024
11c2436
Various changes to group page + changes to DB to support more charact…
sinhaaaryan Nov 19, 2024
44913a6
Changes per review
sinhaaaryan Nov 25, 2024
d6e99d5
Merge branch 'SCRUM-47' of https://github.com/sandboxnu/nucarpool int…
sinhaaaryan Dec 3, 2024
10de778
Backend logic working, now just frontend edits remaining
sinhaaaryan Nov 18, 2024
e771ec1
Various changes to group page + changes to DB to support more charact…
sinhaaaryan Nov 19, 2024
85fcdf0
Minor changes on rider side group page when in group
sinhaaaryan Nov 20, 2024
6eed630
Fixed tsc + lint errors
sinhaaaryan Nov 21, 2024
740b137
Backend logic working, now just frontend edits remaining
sinhaaaryan Nov 18, 2024
2135e50
Various changes to group page + changes to DB to support more charact…
sinhaaaryan Nov 19, 2024
0138d1a
Fixed tsc + lint errors
sinhaaaryan Nov 21, 2024
e159d15
rebased changes from email.ts
sinhaaaryan Nov 21, 2024
17544c6
Changes per review
sinhaaaryan Nov 25, 2024
f040fd5
Backend logic working, now just frontend edits remaining
sinhaaaryan Nov 18, 2024
501c5de
Various changes to group page + changes to DB to support more charact…
sinhaaaryan Nov 19, 2024
35b4070
Fixed tsc + lint errors
sinhaaaryan Nov 21, 2024
03ab954
Backend logic working, now just frontend edits remaining
sinhaaaryan Nov 18, 2024
679d9bd
Various changes to group page + changes to DB to support more charact…
sinhaaaryan Nov 19, 2024
9941d33
Merge branch 'SCRUM-47' of https://github.com/sandboxnu/nucarpool int…
sinhaaaryan Dec 3, 2024
6a8e445
rebased off schema
sinhaaaryan Dec 3, 2024
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 chartjs-adapter-date-fns.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
declare module "chartjs-adapter-date-fns";
7 changes: 5 additions & 2 deletions next-auth.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { DefaultSession } from "next-auth";
import { Permission } from "@prisma/client";

declare module "next-auth" {
/**
Expand All @@ -8,10 +9,12 @@ declare module "next-auth" {
user?: {
id?: string;
isOnboarded: boolean;
permission: Permission;
} & DefaultSession["user"];
}

interface User {
isOnboarded: boolean & DefaultUser;
interface User extends DefaultUser {
isOnboarded: boolean;
permission: Permission;
}
}
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@
"@types/styled-components": "^5.1.26",
"antd": "^5.22.1",
"axios": "^0.27.2",
"chart.js": "^4.4.6",
"chartjs-adapter-date-fns": "^3.0.0",
"chartjs-plugin-zoom": "^2.2.0",
"date-fns": "^4.1.0",
"dayjs": "1.11.13",
"envsafe": "^2.0.3",
Expand All @@ -63,6 +66,7 @@
"rc-picker": "^4.8.1",
"rc-trigger": "^5.3.4",
"react": "^18.3.1",
"react-chartjs-2": "^5.2.0",
"react-dom": "^18.3.1",
"react-easy-crop": "^5.1.0",
"react-hook-form": "^7.32.2",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
-- AlterTable
ALTER TABLE `conversation` ADD COLUMN `dateCreated` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3);

-- AlterTable
ALTER TABLE `group` ADD COLUMN `dateCreated` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3);

-- AlterTable
ALTER TABLE `user` ADD COLUMN `coop_end_date` DATE NULL,
ADD COLUMN `coop_start_date` DATE NULL,
ADD COLUMN `dateCreated` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
ADD COLUMN `dateModified` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
ADD COLUMN `group_message` TEXT NULL,
MODIFY `role` ENUM('RIDER', 'DRIVER', 'VIEWER') NOT NULL DEFAULT 'VIEWER';
2 changes: 2 additions & 0 deletions prisma/migrations/20241119202706_add_text_type/migration.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-- AlterTable
ALTER TABLE `group` MODIFY `message` TEXT NOT NULL;
10 changes: 9 additions & 1 deletion prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ enum Role {
VIEWER
}

enum Permission {
USER
ADMIN
MANAGER
}

// Represents a Status.
enum Status {
ACTIVE
Expand Down Expand Up @@ -132,6 +138,7 @@ model User {
accounts Account[] // can have multiple accounts
sessions Session[] // can have multiple settings
role Role @default(VIEWER)
permission Permission @default(USER)
status Status @default(ACTIVE)
seatAvail Int @default(0) @map("seat_avail")
companyName String @default("") @map("company_name")
Expand Down Expand Up @@ -163,6 +170,7 @@ model User {
Message Message[]
dateCreated DateTime @default(now())
dateModified DateTime @default(now()) @updatedAt
groupMessage String? @map("group_message") @db.Text

@@index([carpoolId])
@@map(name: "user")
Expand All @@ -176,4 +184,4 @@ model VerificationToken {

@@unique([identifier, token])
@@map(name: "verification_token")
}
}
39 changes: 39 additions & 0 deletions src/components/Admin/AdminData.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import React, { useEffect, useState } from "react";
import Spinner from "../Spinner";
import { trpc } from "../../utils/trpc";
import { TempUser, TempGroup } from "../../utils/types";
import BarChartUserCounts from "./BarChartUserCounts";
import LineChartCount from "./LineChartCount";

function AdminData() {
const [loading, setLoading] = useState<boolean>(true);
const { data: users = [] } =
trpc.user.admin.getAllUsers.useQuery<TempUser[]>();
const { data: groups = [] } =
trpc.user.admin.getCarpoolGroups.useQuery<TempGroup[]>();

useEffect(() => {
if (users && groups) {
setLoading(false);
}
}, [users, groups]);

if (loading) {
return <Spinner />;
}

return (
<div className="relative my-4 h-[91.5%] w-full">
<div className="absolute inset-0 flex h-full flex-col space-y-6 px-8">
<div className="min-h-0 flex-[1.5] ">
<BarChartUserCounts users={users} />
</div>
<div className="min-h-0 flex-[2]">
<LineChartCount users={users} groups={groups} />
</div>
</div>
</div>
);
}

export default AdminData;
28 changes: 28 additions & 0 deletions src/components/Admin/AdminSidebar.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
type AdminSidebarProps = {
option: string;
setOption: React.Dispatch<React.SetStateAction<string>>;
};

const AdminSidebar = ({ option, setOption }: AdminSidebarProps) => {
const baseButton = "px-4 py-2 text-northeastern-red font-montserrat text-xl ";
const selectedButton = " font-bold underline underline-offset-8 ";
return (
<div className="h-full w-full ">
<div className="mt-6 flex flex-col items-start gap-4">
<button
className={baseButton + (option === "management" && selectedButton)}
onClick={() => setOption("management")}
>
Management
</button>
<button
className={baseButton + (option === "data" && selectedButton)}
onClick={() => setOption("data")}
>
Data
</button>
</div>
</div>
);
};
export default AdminSidebar;
141 changes: 141 additions & 0 deletions src/components/Admin/BarChartUserCounts.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
import React from "react";
import { Bar } from "react-chartjs-2";
import {
Chart as ChartJS,
CategoryScale,
LinearScale,
BarElement,
Title,
Tooltip,
Legend,
ChartData,
ChartOptions,
} from "chart.js";

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

import { TempUser } from "../../utils/types";

interface BarChartOnboardingProps {
users: TempUser[];
}

function BarChartUserCounts({ users }: BarChartOnboardingProps) {
const activeUsers = users.filter((user) => user.status === "ACTIVE");
const totalCount = activeUsers.length;
const inactiveCount = users.length - totalCount;
const countOnboarded = activeUsers.filter((user) => user.isOnboarded).length;
const countNotOnboarded = totalCount - countOnboarded;
const driverCount = activeUsers.filter(
(user) => user.role === "DRIVER"
).length;
const riderCount = activeUsers.filter((user) => user.role === "RIDER").length;

const viewerCount = totalCount - (driverCount + riderCount);
const dataPoints = [
totalCount,
countOnboarded,
countNotOnboarded,
driverCount,
riderCount,
viewerCount,
inactiveCount,
];
const barColors = [
"#000000",
"#FFA9A9",
"#808080",
"#C8102E",
"#DA7D25",
"#2454DD",
"#808080",
];
const labels = [
"Total",
"Onboarded",
"Not Onboarded",
"Driver",
"Rider",
"Viewer",
"Inactive",
];

const barData: ChartData<"bar"> = {
labels,

datasets: [
{
label: "Active User Counts",
data: dataPoints,
backgroundColor: barColors,
},
],
};

const barOptions: ChartOptions<"bar"> = {
responsive: true,
maintainAspectRatio: false,
plugins: {
legend: {
display: false,
},
title: {
display: true,
text: "User Counts",
font: {
family: "Montserrat",
size: 18,
style: "normal",
weight: "bold",
},
color: "#000000",
},
},
scales: {
x: {
ticks: {
font: {
family: "Montserrat",
size: 16,
style: "normal",
weight: "bold",
},
},
},
y: {
beginAtZero: true,
title: {
display: true,
text: "Number of Users",
font: {
family: "Montserrat",
size: 16,
style: "normal",
weight: "bold",
},
},
},
},
};

return (
<div className="h-full w-full ">
<div className="relative flex h-full flex-col">
<Bar data={barData} options={barOptions} />
<span className="w-full text-center font-lato text-sm text-gray-400">
All bars currently only include active users aside from
&quot;Inactive&quot;
</span>
</div>
</div>
);
}

export default BarChartUserCounts;
Loading
Loading