From 1defca50658accb9fcf6bdcb9cdf6d499660fc3c Mon Sep 17 00:00:00 2001 From: Josephine Han Date: Mon, 18 Mar 2024 18:50:16 -0700 Subject: [PATCH 1/5] remove popup on the close button --- client/src/components/ProjectForm.js | 45 +++++++++++++++------------- 1 file changed, 24 insertions(+), 21 deletions(-) diff --git a/client/src/components/ProjectForm.js b/client/src/components/ProjectForm.js index fb8da054..1e3bd9bd 100644 --- a/client/src/components/ProjectForm.js +++ b/client/src/components/ProjectForm.js @@ -64,7 +64,7 @@ export default function ProjectForm({ formData, projectToEdit, isEdit, - setFormData + setFormData, }) { const history = useHistory(); @@ -74,11 +74,11 @@ export default function ProjectForm({ const [editMode, setEditMode] = useState(false); const { auth } = useAuth(); const [isModalOpen, setIsModalOpen] = useState(false); - const handleOpen = () => setIsModalOpen(true) - const handleClose = () => setIsModalOpen(false) + const handleOpen = () => setIsModalOpen(true); + const handleClose = () => setIsModalOpen(false); const checkFields = () => { - history.push("/projects") - } + history.push('/projects'); + }; /** * React Hook Forms @@ -95,7 +95,7 @@ export default function ProjectForm({ handleSubmit, reset, formState: { errors }, - control + control, } = useForm({ mode: 'all', // Holds the current project data in state. @@ -104,7 +104,7 @@ export default function ProjectForm({ }, }); - const { dirtyFields } = useFormState({control}) + const { dirtyFields } = useFormState({ control }); // ----------------- Submit requests ----------------- @@ -134,8 +134,6 @@ export default function ProjectForm({ setEditMode(false); }; - - // ----------------- Handles and Toggles ----------------- // Handles the location radio button change. @@ -233,14 +231,12 @@ export default function ProjectForm({ title={editMode ? 'Editing Project' : 'Project Information'} badge={isEdit ? editIcon() : addIcon()} > -
{ isEdit ? submitEditProject(data) : submitNewProject(data); })} > - {arr.map((input) => ( ))} - + @@ -268,7 +264,9 @@ export default function ProjectForm({ @@ -279,7 +277,12 @@ export default function ProjectForm({ 0 ? handleOpen: checkFields} + onClick={ + isEdit + ? checkFields + : // Object.keys(dirtyFields).length > 0 ? + handleOpen + } > Close From f6b4860922ce6a6b7f8caf689e00ea27ce2c5a48 Mon Sep 17 00:00:00 2001 From: Josephine Han Date: Mon, 18 Mar 2024 20:15:45 -0700 Subject: [PATCH 2/5] popup removed for close button after no edit is made --- client/src/components/ProjectForm.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/client/src/components/ProjectForm.js b/client/src/components/ProjectForm.js index 1e3bd9bd..bd57d242 100644 --- a/client/src/components/ProjectForm.js +++ b/client/src/components/ProjectForm.js @@ -278,10 +278,13 @@ export default function ProjectForm({ variant="contained" cursor="pointer" onClick={ - isEdit + !editMode || Object.keys(dirtyFields).length === 0 ? checkFields - : // Object.keys(dirtyFields).length > 0 ? - handleOpen + : handleOpen + + // Object.keys(dirtyFields).length > 0 ? handleOpen : checkFields + // dirtyFields === 0 ? checkFields : handleOpen + // isEdit ? handleOpen : checkFields } > Close From 6df013869886c05b7de406f567f4e395da97d505 Mon Sep 17 00:00:00 2001 From: Josephine Han Date: Mon, 1 Apr 2024 18:55:44 -0700 Subject: [PATCH 3/5] removed prettier back to original styling --- backend/package.json | 3 -- client/src/components/ProjectForm.js | 46 ++++++++++++---------------- 2 files changed, 20 insertions(+), 29 deletions(-) diff --git a/backend/package.json b/backend/package.json index 5fe900b1..3f748e7b 100644 --- a/backend/package.json +++ b/backend/package.json @@ -4,8 +4,6 @@ "description": "VRMS Backend", "main": "server.js", "scripts": { - "lint": "eslint .", - "format": "prettier --check .", "test": "jest", "test:watch": "jest --watch", "start": "node server.js", @@ -31,7 +29,6 @@ "eslint-plugin-react": "^7.20.6", "jest": "^26.4.0", "nodemon": "^2.0.2", - "prettier": "^2.1.1", "pretty-quick": "^3.0.2", "supertest": "^4.0.2", "why-is-node-running": "^2.2.0" diff --git a/client/src/components/ProjectForm.js b/client/src/components/ProjectForm.js index bd57d242..55f33e94 100644 --- a/client/src/components/ProjectForm.js +++ b/client/src/components/ProjectForm.js @@ -64,7 +64,7 @@ export default function ProjectForm({ formData, projectToEdit, isEdit, - setFormData, + setFormData }) { const history = useHistory(); @@ -74,11 +74,11 @@ export default function ProjectForm({ const [editMode, setEditMode] = useState(false); const { auth } = useAuth(); const [isModalOpen, setIsModalOpen] = useState(false); - const handleOpen = () => setIsModalOpen(true); - const handleClose = () => setIsModalOpen(false); + const handleOpen = () => setIsModalOpen(true) + const handleClose = () => setIsModalOpen(false) const checkFields = () => { - history.push('/projects'); - }; + history.push("/projects") + } /** * React Hook Forms @@ -95,7 +95,7 @@ export default function ProjectForm({ handleSubmit, reset, formState: { errors }, - control, + control } = useForm({ mode: 'all', // Holds the current project data in state. @@ -104,7 +104,7 @@ export default function ProjectForm({ }, }); - const { dirtyFields } = useFormState({ control }); + const { dirtyFields } = useFormState({ control }) // ----------------- Submit requests ----------------- @@ -134,6 +134,8 @@ export default function ProjectForm({ setEditMode(false); }; + + // ----------------- Handles and Toggles ----------------- // Handles the location radio button change. @@ -231,12 +233,14 @@ export default function ProjectForm({ title={editMode ? 'Editing Project' : 'Project Information'} badge={isEdit ? editIcon() : addIcon()} > +
{ isEdit ? submitEditProject(data) : submitNewProject(data); })} > + {arr.map((input) => ( ))} + open={isModalOpen} + onClose={handleClose} + destination={'/projects'} + aria-labelledby="modal-modal-title" + aria-describedby="modal-modal-description" + handleClose={handleClose} + /> @@ -264,9 +268,7 @@ export default function ProjectForm({ @@ -277,15 +279,7 @@ export default function ProjectForm({ 0 ? handleOpen : checkFields - // dirtyFields === 0 ? checkFields : handleOpen - // isEdit ? handleOpen : checkFields - } + onClick={!editMode || Object.keys(dirtyFields).length === 0 ? checkFields: handleOpen} > Close From 3d840a755df902cb836b3fea7f142ddab7ea1c14 Mon Sep 17 00:00:00 2001 From: Josephine Han Date: Mon, 1 Apr 2024 18:57:33 -0700 Subject: [PATCH 4/5] undo prettier --- client/src/components/ProjectForm.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/src/components/ProjectForm.js b/client/src/components/ProjectForm.js index 55f33e94..34df40c8 100644 --- a/client/src/components/ProjectForm.js +++ b/client/src/components/ProjectForm.js @@ -104,7 +104,7 @@ export default function ProjectForm({ }, }); - const { dirtyFields } = useFormState({ control }) + const { dirtyFields } = useFormState({control}) // ----------------- Submit requests ----------------- From 919a0df72bd272ac7d48b914240d9c8f4c60ba44 Mon Sep 17 00:00:00 2001 From: Josephine Han Date: Mon, 1 Apr 2024 19:10:08 -0700 Subject: [PATCH 5/5] readded packages --- backend/package.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/backend/package.json b/backend/package.json index 3f748e7b..5fe900b1 100644 --- a/backend/package.json +++ b/backend/package.json @@ -4,6 +4,8 @@ "description": "VRMS Backend", "main": "server.js", "scripts": { + "lint": "eslint .", + "format": "prettier --check .", "test": "jest", "test:watch": "jest --watch", "start": "node server.js", @@ -29,6 +31,7 @@ "eslint-plugin-react": "^7.20.6", "jest": "^26.4.0", "nodemon": "^2.0.2", + "prettier": "^2.1.1", "pretty-quick": "^3.0.2", "supertest": "^4.0.2", "why-is-node-running": "^2.2.0"