-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ieee 259 add description box on teams homepage (#509)
* incident form init * implementing form components * fixing form style * fixing position of menu items * implement back button * adding helper text for radio * fixing button * cleaning up unused vars * adding report broken lost button * init test * fixing link * reset form on successful submission * setting up testing * fix test * fixing tests * removing unused code * adding name to readme * fix type error * padding qty to new page & adding snackbar * rewriting formik with map * fixing responsive issues on form * fixing checkedout tables style * adding map to radio options * using map in form * fixing textfield width * fixing validation onchange * adding more unit tests to check for rendering of form components and submit button * adding more padding between form elements and labels * removing inline styles (sorry bad habitsgit status) * removing unused code and console.log & changing url format a little bit to pass more info about hardware for incident form * added yup validation to check if the input string is 0 for qty, is so don't submit the form * IEEE-259 add input box on teams homepage * Delete hackathon_site/dashboard/frontend/package-lock.json * IEEE-259 remove unused ErrorMessage * IEEE-259 refactor and clean project description component * IEEE-259 Add title and project description to admin page * IEEE-259 Clean code in CartSummary.tsx * IEEE-259 Add project description character limit display and fix tests * IEEE-259 refactor project description component and teamDetail slice * IEEE-259 Fix dashboard and teamDetails test cases --------- Co-authored-by: Natalie <natapoke2@gmail.com> Co-authored-by: Mustafa <mus2003.abdul@gmail.com> Co-authored-by: Karandeep Lubana <karandeep.lubana@utoronto.ca>
- Loading branch information
1 parent
1dc1d95
commit 4585976
Showing
14 changed files
with
359 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
...oard/frontend/src/components/teamDetail/ProjectDescription/ProjectDescription.module.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
.formTextField { | ||
margin: 10px 5px 0 0; | ||
} | ||
|
||
.actionBtn { | ||
width: 120px; | ||
} | ||
|
||
.submitBtn { | ||
width: 120px; | ||
margin-right: 10px; | ||
} | ||
|
||
.projectDescriptionDetail { | ||
padding: 10px; | ||
} | ||
|
||
.title { | ||
margin-top: 30px; | ||
} |
126 changes: 126 additions & 0 deletions
126
...te/dashboard/frontend/src/components/teamDetail/ProjectDescription/ProjectDescription.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
import React, { useState } from "react"; | ||
import styles from "./ProjectDescription.module.scss"; | ||
import { Formik, Form, Field, FormikValues } from "formik"; | ||
import * as Yup from "yup"; | ||
import { TextField, Button, Box, Grid, Typography } from "@material-ui/core"; | ||
import { useDispatch, useSelector } from "react-redux"; | ||
import { updateProjectDescription } from "slices/event/teamDetailSlice"; | ||
import { minProjectDescriptionLength } from "constants.js"; | ||
import { teamSelector, isLoadingSelector } from "slices/event/teamSlice"; | ||
|
||
export interface ProjectDescriptionProps { | ||
teamCode: string; | ||
} | ||
|
||
const ProjectDescription = ({ teamCode }: ProjectDescriptionProps) => { | ||
const dispatch = useDispatch(); | ||
const isProjectDescriptionLoading: boolean = useSelector(isLoadingSelector); | ||
const initialProjectDescription = | ||
useSelector(teamSelector)?.project_description || | ||
"Project description is required"; | ||
const [isEditing, setIsEditing] = useState(false); | ||
const projectDescriptionSchema = Yup.object().shape({ | ||
projectDescription: Yup.string() | ||
.max(500) | ||
.required("Project description is required"), | ||
}); | ||
|
||
const handleSubmit = async (values: FormikValues, { setSubmitting }: any) => { | ||
await dispatch( | ||
updateProjectDescription({ | ||
teamCode: teamCode, | ||
projectDescription: values.projectDescription, | ||
}) | ||
); | ||
setSubmitting(false); | ||
setIsEditing(false); | ||
}; | ||
|
||
return ( | ||
<> | ||
{isProjectDescriptionLoading ? ( | ||
"" | ||
) : ( | ||
<div className={styles.title}> | ||
<Typography variant="h2" gutterBottom> | ||
Project Description | ||
</Typography> | ||
<Formik | ||
initialValues={{ | ||
projectDescription: initialProjectDescription, | ||
}} | ||
validationSchema={projectDescriptionSchema} | ||
onSubmit={handleSubmit} | ||
> | ||
{({ isSubmitting, isValid, values }) => ( | ||
<Form> | ||
<Field | ||
as={TextField} | ||
name="projectDescription" | ||
multiline | ||
fullWidth | ||
variant="outlined" | ||
disabled={!isEditing} | ||
rows={4} | ||
className={styles.formTextField} | ||
/> | ||
{minProjectDescriptionLength - | ||
values.projectDescription.length > | ||
0 && ( | ||
<Typography | ||
variant="caption" | ||
display="block" | ||
gutterBottom | ||
> | ||
Minimum{" "} | ||
{minProjectDescriptionLength - | ||
values.projectDescription.length}{" "} | ||
characters required | ||
</Typography> | ||
)} | ||
<Box mt={2}> | ||
<Grid container justifyContent="flex-end"> | ||
{isEditing ? ( | ||
<> | ||
<Button | ||
type="submit" | ||
variant="contained" | ||
disabled={!isValid || isSubmitting} | ||
className={styles.submitBtn} | ||
> | ||
SUBMIT | ||
</Button> | ||
<Button | ||
type="button" | ||
variant="contained" | ||
color="secondary" | ||
className={styles.actionBtn} | ||
onClick={() => setIsEditing(false)} | ||
> | ||
CANCEL | ||
</Button> | ||
</> | ||
) : null} | ||
{!isEditing && ( | ||
<Button | ||
type="button" | ||
variant="contained" | ||
color="primary" | ||
className={styles.actionBtn} | ||
onClick={() => setIsEditing(true)} | ||
> | ||
EDIT | ||
</Button> | ||
)} | ||
</Grid> | ||
</Box> | ||
</Form> | ||
)} | ||
</Formik> | ||
</div> | ||
)} | ||
</> | ||
); | ||
}; | ||
|
||
export default ProjectDescription; |
24 changes: 24 additions & 0 deletions
24
...shboard/frontend/src/components/teamDetail/ProjectDescription/ProjectDescriptionAlert.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import React from "react"; | ||
import AlertBox from "components/general/AlertBox/AlertBox"; | ||
import { teamSelector } from "slices/event/teamSlice"; | ||
import { useSelector } from "react-redux"; | ||
import { minProjectDescriptionLength } from "constants.js"; | ||
|
||
const ProjectDescriptionAlert = () => { | ||
const projectDescription = useSelector(teamSelector)?.project_description; | ||
|
||
if (projectDescription && projectDescription.length < minProjectDescriptionLength) { | ||
return ( | ||
<AlertBox | ||
data-testid="project-description-alert" | ||
title="Project Description Required" | ||
error="Please provide a more detailed project description." | ||
type="error" | ||
/> | ||
); | ||
} | ||
|
||
return null; | ||
}; | ||
|
||
export default ProjectDescriptionAlert; |
32 changes: 32 additions & 0 deletions
32
...hboard/frontend/src/components/teamDetail/ProjectDescription/ProjectDescriptionDetail.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import React from "react"; | ||
import { useSelector } from "react-redux"; | ||
import { | ||
projectDescriptionSelector, | ||
isTeamInfoLoadingSelector, | ||
} from "slices/event/teamDetailSlice"; | ||
import styles from "./ProjectDescription.module.scss"; | ||
import { LinearProgress, Paper, Typography } from "@material-ui/core"; | ||
|
||
const ProjectDescriptionDetail = () => { | ||
const projectDescription = useSelector(projectDescriptionSelector); | ||
const isTeamInfoLoading = useSelector(isTeamInfoLoadingSelector); | ||
|
||
return ( | ||
<div> | ||
{isTeamInfoLoading ? ( | ||
<LinearProgress data-testid="project-description-linear-progress" /> | ||
) : ( | ||
<> | ||
<Typography variant="h2" gutterBottom> | ||
Project Description | ||
</Typography> | ||
<Paper className={styles.projectDescriptionDetail}> | ||
<Typography variant="body1">{projectDescription}</Typography> | ||
</Paper> | ||
</> | ||
)} | ||
</div> | ||
); | ||
}; | ||
|
||
export default ProjectDescriptionDetail; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.