Skip to content
Open
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
80645b2
#376 Pull from main and move yesterday's work to a new branch
MahoMori Jun 23, 2022
6c39bfb
#377 Pull from main and move yesterday's work to a new branch
MahoMori Jun 23, 2022
9cebf66
#377 Change Table component in CompetenciesCategoriesTable to have a …
MahoMori Jun 23, 2022
e0d9ac0
#377 Add background color object for category row and change color ac…
MahoMori Jun 23, 2022
d07cb8c
#377 Create and stylize table inside each category dropdown with dumm…
MahoMori Jun 24, 2022
231c114
#377 Change color palette to coodinate with category images and chang…
MahoMori Jun 24, 2022
b0ec8ea
Merge branch 'main' into 377-competencies-page-should-display-previou…
MahoMori Jun 28, 2022
65b098e
#377 Run yarn delint and update comment of data from backend in Compe…
MahoMori Jun 28, 2022
980c54c
Merge branch 'main' into 377-competencies-page-should-display-previou…
MahoMori Jun 28, 2022
802be19
#377 Merge main, get competencies data by category, and show them in …
MahoMori Jun 28, 2022
fc462a9
#377 Get reflections from backend and show the craeted date.
MahoMori Jun 29, 2022
d00ee1a
Write code to show raitings only when there's a past assessment and c…
MahoMori Jun 30, 2022
8a477c4
Change width of table cell
MahoMori Jun 30, 2022
81da9a7
#377 Change width of table cell
MahoMori Jun 30, 2022
357491a
Merge branch '377-competencies-page-should-display-previous-reflectio…
MahoMori Jun 30, 2022
cf5a8ad
Merge branch 'main' into 377-competencies-page-should-display-previou…
MahoMori Jul 1, 2022
1ef245c
Apply value to MUI rating component by checking option label
MahoMori Jul 1, 2022
3a909d0
#377 Clean up some codes
MahoMori Jul 1, 2022
0acc3ee
#377 Change button name and delete empty line.
MahoMori Jul 1, 2022
c5dac23
Update CompetenciesDetailTable.tsx
MahoMori Aug 24, 2022
af569e9
#377 Run yarn delint.
MahoMori Aug 25, 2022
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
20 changes: 19 additions & 1 deletion webapp/src/components/App.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { BrowserRouter, Route, Routes } from 'react-router-dom';
import React, { useContext } from 'react';

import CompetenciesPage from './CompetenciesPage';
import CompetenciesView from './CompetenciesView';
import DocPage from './DocPage';
import Footer from './Footer';
import MeetingPage from './MeetingPage';
Expand All @@ -10,6 +10,7 @@ import Navbar from './Navbar';
import ReflectionsPage from './ReflectionsPage';
import RequireAuth from './RequireAuth';
import SessionContext from './SessionContext';
import CompetenciesPage from './CompetenciesPage';

const App = () => {
const { isAuthenticated } = useContext(SessionContext);
Expand Down Expand Up @@ -42,6 +43,23 @@ const App = () => {
</RequireAuth>
}
/>
<Route
path="/reflections/competencies"
element={
<RequireAuth>
<CompetenciesView />
</RequireAuth>
}
/>
{/* Placeholder for Categories route */}
{/* <Route
path="/questionnaires/categories"
element={
<RequireAuth>
<CategoriesPage />
</RequireAuth>
}
/> */}
<Route
path="/meetings/:id"
element={
Expand Down
61 changes: 61 additions & 0 deletions webapp/src/components/CompetenciesCategoriesTable.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import React from 'react';
import {
Table,
TableBody,
TableCell,
TableContainer,
TableHead,
TableRow,
Paper,
} from '@mui/material';
import CompetenciesDetailTable from './CompetenciesDetailTable';
import useApiData from '../helpers/useApiData';
import { CompetenciesByCategory } from '../types/api';

const CompetenciesCategoriesTable = () => {
const { data, isLoading, error } = useApiData<CompetenciesByCategory[]>({
deps: [],
path: `/competencies/categories`,
sendCredentials: true,
});
if (error) {
return <p>There was an error loading the competencies.</p>;
}
if (!data) {
return null;
}

return (
<TableContainer component={Paper}>
<Table aria-label="collapsible table">
<TableHead>
<TableRow
sx={{
'& > *': {
fontWeight: 'bold !important',
textTransform: 'uppercase',
},
}}
>
<TableCell sx={{ width: '5%' }} />
<TableCell sx={{ width: '25%' }}>Category</TableCell>
<TableCell align="left">Summary</TableCell>
</TableRow>
</TableHead>
<TableBody>
{!isLoading &&
data.map(({ id, label, description, competencies }) => (
<CompetenciesDetailTable
key={id}
catgoryLabel={label}
categoryDescription={description}
competencies={competencies}
/>
))}
</TableBody>
</Table>
</TableContainer>
);
};

export default CompetenciesCategoriesTable;
191 changes: 191 additions & 0 deletions webapp/src/components/CompetenciesDetailTable.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,191 @@
import React from 'react';
import {
Box,
Collapse,
IconButton,
Table,
TableBody,
TableCell,
TableHead,
TableRow,
Rating,
Tooltip,
} from '@mui/material';
import { styled } from '@mui/material/styles';
import KeyboardArrowDownIcon from '@mui/icons-material/KeyboardArrowDown';
import KeyboardArrowUpIcon from '@mui/icons-material/KeyboardArrowUp';
import CircleOutlinedIcon from '@mui/icons-material/CircleOutlined';
import CircleIcon from '@mui/icons-material/Circle';
import { Competency, Reflection } from '../types/api';
import useApiData from '../helpers/useApiData';
import { formatDate } from '../helpers/dateTime';

export interface IBackgroundColor {
[key: string]: string;
}
Comment thread
achichikalova marked this conversation as resolved.
export const categoryBackgroundColor: IBackgroundColor = {
Functional: '#CAE2FA',
Strategic: '#ffe59a',
Operational: '#b6d7a8',
Behavioural: '#b4a7d5',
Organizational: '#F7B8D7',
};

const StyledRating = styled(Rating)({
'& .MuiRating-iconFilled': {
color: '#42a5f5',
},
});

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and this line?

interface IRatingValue {
[key: string]: number;
}
const ratingValue: IRatingValue = {
Aware: 1,
Novice: 2,
Intermediate: 3,
Advanced: 4,
Expert: 5,
};

interface DetailTableProps {
catgoryLabel: string;
categoryDescription: string;
competencies: Competency[];
}

const CompetenciesDetailTable = ({
catgoryLabel,
categoryDescription,
competencies,
}: DetailTableProps) => {
const [open, setOpen] = React.useState(false);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

useState can directly be destructured in the import so that useState() can be utilized directly instead of React.useState()

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point! I changed code to import useState


const { data: reflections } = useApiData<Reflection[]>({
deps: [],
path: '/reflections',
sendCredentials: true,
});

return (
<>
<TableRow
sx={{
'& > *': { borderBottom: 'unset' },
backgroundColor: categoryBackgroundColor[catgoryLabel],
}}
>
<TableCell>
<IconButton
aria-label="expand row"
size="small"
onClick={() => setOpen(!open)}
>
{open ? <KeyboardArrowUpIcon /> : <KeyboardArrowDownIcon />}
</IconButton>
</TableCell>
<TableCell component="th" scope="row">
{catgoryLabel}
</TableCell>
<TableCell>{categoryDescription}</TableCell>
</TableRow>
<TableRow>
<TableCell style={{ paddingBottom: 0, paddingTop: 0 }} colSpan={6}>
<Collapse in={open} timeout="auto" unmountOnExit>
<Box sx={{ margin: 1 }}>
<Table size="small">
<TableHead>
<TableRow
sx={{
'& > *': {
fontWeight: 'bold !important',
textTransform: 'uppercase',
},
}}
>
<TableCell component="th" scope="row" sx={{ width: '20%' }}>
Name
</TableCell>
<TableCell>Definition</TableCell>
{reflections &&
reflections
.filter(reflection =>
reflection.responses.find(response =>
competencies.find(
competency =>
competency.label ===
response.option.prompt.label
)
)
)
.map(reflection => {
const reflectionCreatedAtDate = formatDate(
reflection.created_at
);
return (
<TableCell key={reflection.id} align="center">
{reflectionCreatedAtDate}
</TableCell>
);
})}
</TableRow>
</TableHead>
<TableBody>
{reflections &&
competencies.map(competency => (
<TableRow key={competency.id}>
<TableCell>{competency.label}</TableCell>
<TableCell>{competency.description}</TableCell>
{reflections
.filter(reflection =>
reflection.responses.find(response =>
competencies.find(
competency =>
competency.label ===
response.option.prompt.label
)
)
)
.map(reflection => {
const response = reflection.responses.find(
response =>
response.option.prompt.label ===
competency.label
);
if (response) {
return (
<Tooltip
key={response.id}
title={response.option.label}
placement="top"
arrow
>
<TableCell align="center">
<StyledRating
value={ratingValue[response.option.label]}
readOnly
icon={<CircleIcon />}
emptyIcon={<CircleOutlinedIcon />}
/>
</TableCell>
</Tooltip>
);
} else {
return (
<TableCell key={reflection.id}></TableCell>
);
}
})}
</TableRow>
))}
</TableBody>
</Table>
</Box>
</Collapse>
</TableCell>
</TableRow>
</>
);
};

export default CompetenciesDetailTable;
29 changes: 29 additions & 0 deletions webapp/src/components/CompetenciesView.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import React from 'react';
import { Box, Container, Grid, Button } from '@mui/material';

Comment thread
achichikalova marked this conversation as resolved.
Outdated
import CompetenciesCategoriesTable from './CompetenciesCategoriesTable';

const CompetenciesView = () => {
return (
<Container fixed>
<h1>Competencies</h1>
<Grid container justifyContent="center">
<Grid item xs={12}>
<Box textAlign="center">
<Button variant="contained" sx={{ my: 5 }}>

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What page should the user be shown on clicking this "Take Assessment" button?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe it takes to the assessment page with five pictures (CategoriesCompetenciesPage.tsx which @achichikalova was working on).

Take Assessment
</Button>
</Box>
<Box>
{/* The placeholder for the card with the rating instruction */}
</Box>
<Box>
<CompetenciesCategoriesTable />
</Box>
</Grid>
</Grid>
</Container>
);
};

export default CompetenciesView;
Comment thread
achichikalova marked this conversation as resolved.
7 changes: 7 additions & 0 deletions webapp/src/types/api.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@ export interface Prompt extends Entity {
query_text: string;
}

export interface CompetenciesByCategory extends Entity {
label: string;
description: string;
image_url: string;
competencies: Competency[];
}

export interface Option extends Entity {
label: string;
prompt: Prompt;
Expand Down