Skip to content

Commit

Permalink
Org Table Changes
Browse files Browse the repository at this point in the history
  • Loading branch information
roshanbellary committed Nov 25, 2024
1 parent 22a3b1f commit 274ee45
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 17 deletions.
4 changes: 3 additions & 1 deletion client/src/AdminDashboard/AdminDashboardPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ function AdminDashboardPage() {
return (
<ScreenGrid>
<Grid item>
<Typography variant="h2">Welcome to the Admin Dashboard</Typography>
<Typography variant="h2">
Welcome to the Admin User Dashboard
</Typography>
</Grid>
<Grid item container width="60vw" justifyContent="flex-end">
<InviteUserButton />
Expand Down
4 changes: 3 additions & 1 deletion client/src/AdminDashboard/OrgAdminPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ function OrgAdminPage() {
return (
<ScreenGrid>
<Grid item>
<Typography variant="h2">Welcome to the Admin Dashboard</Typography>
<Typography variant="h2">
Welcome to the Admin Organization Dashboard
</Typography>
</Grid>
<Grid item>
<div style={{ height: '60vh', width: '60vw' }}>
Expand Down
9 changes: 2 additions & 7 deletions client/src/AdminDashboard/OrgTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,8 @@ function OrgTable() {
try {
const [kitchenRes, programRes] = await Promise.all([
getData(`kitchen_outcomes/get/all/${organizationId}`),
getData(`program_outcomes/get/all/${organizationId}`),
getData(`program_outcomes/org/${organizationId}/all`),
]);

setKitchenOutcomes(kitchenRes.data);
setProgramOutcomes(programRes.data);

Expand Down Expand Up @@ -146,7 +145,7 @@ function OrgTable() {
),
}));

const programRows: OutcomeRow[] = programOutcomes.map((outcome) => ({
const programRows: OutcomeRow[] = programOutcomes.map((outcome: any) => ({
// eslint-disable-next-line no-underscore-dangle
key: outcome._id,
date: new Date(outcome.year).toISOString().slice(0, 10),
Expand Down Expand Up @@ -197,12 +196,8 @@ function OrgTable() {
</MenuItem>
))}
</Select>

<Box mt={2} />

{/* Outcomes Table */}
<PaginationTable rows={createOutcomeRows()} columns={columns} />

{/* Notification Snackbar */}
<Snackbar
open={notification.open}
Expand Down
16 changes: 8 additions & 8 deletions server/src/services/program.outcomes.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const getOneProgramOutcomes = async (year: Date, orgId: string) => {
const endDate = new Date(Date.UTC(year.getFullYear() + 1, 0, 1));

const outcomes = await ProgramOutcomes.findOne({
orgId: orgId,
orgId,
year: {
$gte: startDate,
$lt: endDate,
Expand All @@ -40,7 +40,7 @@ const getAllProgramOutcomesByOrg = async (orgId: string) => {
const getDistinctYearsByOrgId = async (orgId: string): Promise<number[]> => {
console.log('Service - Getting years for orgId:', orgId);
const outcomes = await ProgramOutcomes.find({ orgId }, ['year']);
const years = outcomes.map((outcome) => outcome.year.getUTCFullYear());
const years = outcomes.map((outcome: any) => outcome.year.getUTCFullYear());
return [...new Set(years)].sort((a, b) => b - a);
};

Expand Down Expand Up @@ -112,20 +112,20 @@ const getNetworkAverage = async (

const getFieldValuesByYear = async (
orgId: string,
field: keyof IProgramOutcomes
field: keyof IProgramOutcomes,
): Promise<Map<number, number | null>> => {
try {
const outcomes = await ProgramOutcomes.find(
{
{
orgId,
[field]: { $exists: true }
[field]: { $exists: true },
},
['year', field]
['year', field],
).exec();

const valuesByYear = new Map<number, number | null>();
outcomes.forEach(outcome => {

outcomes.forEach((outcome: any) => {
const year = outcome.year.getUTCFullYear();
const value = outcome[field] as number | null;
valuesByYear.set(year, value);
Expand Down

0 comments on commit 274ee45

Please sign in to comment.