From d3a7d556f19b57b4d71cad1bfeb628ee1d11b9d3 Mon Sep 17 00:00:00 2001 From: Kaiyooon Date: Sat, 21 May 2022 21:37:00 -0500 Subject: [PATCH 01/13] Create PR for #126 From f6a4b62d514248dd128d7676f021d7ab9ceae31b Mon Sep 17 00:00:00 2001 From: Kei Asakawa Date: Sun, 22 May 2022 15:53:28 -0700 Subject: [PATCH 02/13] Updates to Submit Survey Popup --- .../MonitorLog/ReviewSubmitTabPopup.jsx | 91 +++++++++++++++++++ src/pages/MonitorLogPage.jsx | 10 +- yarn.lock | 51 ++--------- 3 files changed, 105 insertions(+), 47 deletions(-) create mode 100644 src/components/MonitorLog/ReviewSubmitTabPopup.jsx diff --git a/src/components/MonitorLog/ReviewSubmitTabPopup.jsx b/src/components/MonitorLog/ReviewSubmitTabPopup.jsx new file mode 100644 index 00000000..a9271c0a --- /dev/null +++ b/src/components/MonitorLog/ReviewSubmitTabPopup.jsx @@ -0,0 +1,91 @@ +import { + Modal, + ModalOverlay, + ModalContent, + ModalHeader, + ModalBody, + ModalFooter, + useDisclosure, + Button, +} from '@chakra-ui/react'; +import PropTypes from 'prop-types'; +import { FiCheck } from 'react-icons/fi'; +import { React, useState, useEffect } from 'react'; + +const SubmitSurvey = ({ setModalStep, onClose, submit }) => { + console.log('entered'); + return ( + <> + Are you sure you want to submit your survey log? + + + + + + ); +}; + +const Submitted = ({ onClose }) => { + return ( + <> + Congratulations! You’ve submitted your monitor log for review. + + + + + ); +}; + +function ReturnPopup({ submitForm }) { + const [modalStep, setModalStep] = useState('submitSurvey'); + const { isOpen, onOpen, onClose } = useDisclosure(); + + useEffect(() => { + setModalStep('reminderSelect'); + }); + + const modalContent = { + submitSurvey: ( + + ), + submitted: , + }; + + console.log('Entered Popup'); + return ( + <> + + + + + {modalContent[modalStep]} + + + ); +} + +SubmitSurvey.propTypes = { + setModalStep: PropTypes.func.isRequired, + onClose: PropTypes.func.isRequired, + submit: PropTypes.func.isRequired, +}; + +Submitted.propTypes = { + onClose: PropTypes.func.isRequired, +}; + +ReturnPopup.propTypes = { + submitForm: PropTypes.func.isRequired, +}; + +export default ReturnPopup; diff --git a/src/pages/MonitorLogPage.jsx b/src/pages/MonitorLogPage.jsx index 6841c1f3..82c8ab59 100644 --- a/src/pages/MonitorLogPage.jsx +++ b/src/pages/MonitorLogPage.jsx @@ -37,6 +37,7 @@ import HumanActivity from '../components/MonitorLog/HumanActivityTab'; import ListedSpeciesTab from '../components/MonitorLog/ListedSpeciesTab'; import PredatorsTab from '../components/MonitorLog/PredatorsTab'; import ReviewSubmitTab from '../components/MonitorLog/ReviewSubmitTab'; +import ReviewSubmitTabPopup from '../components/MonitorLog/ReviewSubmitTabPopup'; const MonitorTabButton = props => { // eslint-disable-next-line react/prop-types @@ -330,10 +331,11 @@ const MonitorLogPage = ({ mode }) => { )} {activeTab === totalTabs - 1 && ( - + // + )} diff --git a/yarn.lock b/yarn.lock index a0ad2c27..8fe01453 100644 --- a/yarn.lock +++ b/yarn.lock @@ -119,7 +119,7 @@ convert-source-map "^1.7.0" debug "^4.1.0" gensync "^1.0.0-beta.2" - json5 "^2.1.2" + json5 "^2.2.1" semver "^6.3.0" "@babel/generator@^7.12.1", "@babel/generator@^7.12.11", "@babel/generator@^7.12.5", "@babel/generator@^7.17.12": @@ -131,15 +131,6 @@ "@jridgewell/gen-mapping" "^0.3.0" jsesc "^2.5.1" -"@babel/generator@^7.17.3": - version "7.17.10" - resolved "https://registry.yarnpkg.com/@babel/generator/-/generator-7.17.10.tgz#c281fa35b0c349bbe9d02916f4ae08fc85ed7189" - integrity sha512-46MJZZo9y3o4kmhBVc7zW7i8dtR1oIK/sdO5NcfcZRhTGYi+KKJRtHNgsU6c4VUcJmUNV/LQdebD/9Dlv4K+Tg== - dependencies: - "@babel/types" "^7.17.10" - "@jridgewell/gen-mapping" "^0.1.0" - jsesc "^2.5.1" - "@babel/helper-annotate-as-pure@^7.16.7": version "7.16.7" resolved "https://registry.yarnpkg.com/@babel/helper-annotate-as-pure/-/helper-annotate-as-pure-7.16.7.tgz#bb2339a7534a9c128e3102024c60760a3a7f3862" @@ -172,8 +163,8 @@ dependencies: "@babel/helper-annotate-as-pure" "^7.16.7" "@babel/helper-environment-visitor" "^7.16.7" - "@babel/helper-function-name" "^7.16.7" - "@babel/helper-member-expression-to-functions" "^7.16.7" + "@babel/helper-function-name" "^7.17.9" + "@babel/helper-member-expression-to-functions" "^7.17.7" "@babel/helper-optimise-call-expression" "^7.16.7" "@babel/helper-replace-supers" "^7.16.7" "@babel/helper-split-export-declaration" "^7.16.7" @@ -228,7 +219,7 @@ dependencies: "@babel/types" "^7.16.7" -"@babel/helper-function-name@^7.16.7": +"@babel/helper-function-name@^7.16.7", "@babel/helper-function-name@^7.17.9": version "7.17.9" resolved "https://registry.yarnpkg.com/@babel/helper-function-name/-/helper-function-name-7.17.9.tgz#136fcd54bc1da82fcb47565cf16fd8e444b1ff12" integrity sha512-7cRisGlVtiVqZ0MW0/yFB4atgpGLWEHUVYnb448hZK4x+vih0YO5UoS11XIYtZYqHd0dIPMdUSv8q5K4LdMnIg== @@ -243,7 +234,7 @@ dependencies: "@babel/types" "^7.16.7" -"@babel/helper-member-expression-to-functions@^7.16.7", "@babel/helper-member-expression-to-functions@^7.17.7": +"@babel/helper-member-expression-to-functions@^7.16.7": version "7.17.7" resolved "https://registry.yarnpkg.com/@babel/helper-member-expression-to-functions/-/helper-member-expression-to-functions-7.17.7.tgz#a34013b57d8542a8c4ff8ba3f747c02452a4d8c4" integrity sha512-thxXgnQ8qQ11W2wVUObIqDL4p148VMxkt5T/qpN5k2fboRyzFGFmKsTGViquyM5QHKUy48OZoca8kw4ajaDPyw== @@ -1183,7 +1174,7 @@ "@babel/code-frame" "^7.16.7" "@babel/generator" "^7.17.12" "@babel/helper-environment-visitor" "^7.16.7" - "@babel/helper-function-name" "^7.16.7" + "@babel/helper-function-name" "^7.17.9" "@babel/helper-hoist-variables" "^7.16.7" "@babel/helper-split-export-declaration" "^7.16.7" "@babel/parser" "^7.17.12" @@ -1199,14 +1190,6 @@ "@babel/helper-validator-identifier" "^7.16.7" to-fast-properties "^2.0.0" -"@babel/types@^7.17.10": - version "7.17.10" - resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.17.10.tgz#d35d7b4467e439fcf06d195f8100e0fea7fc82c4" - integrity sha512-9O26jG0mBYfGkUYCYZRnBwbVLd1UZOICEr2Em6InB6jVfsAv1GKgwXHmrSg+WFWDmeKTA6vyTZiN8tCSM5Oo3A== - dependencies: - "@babel/helper-validator-identifier" "^7.16.7" - to-fast-properties "^2.0.0" - "@base2/pretty-print-object@1.0.1": version "1.0.1" resolved "https://registry.yarnpkg.com/@base2/pretty-print-object/-/pretty-print-object-1.0.1.tgz#371ba8be66d556812dc7fb169ebc3c08378f69d4" @@ -1976,7 +1959,7 @@ "@emotion/utils" "0.11.3" csstype "^2.5.7" -"@emotion/serialize@^1.0.2": +"@emotion/serialize@^1.0.2", "@emotion/serialize@^1.0.3": version "1.0.3" resolved "https://registry.yarnpkg.com/@emotion/serialize/-/serialize-1.0.3.tgz#99e2060c26c6292469fb30db41f4690e1c8fea63" integrity sha512-2mSSvgLfyV3q+iVh3YWgNlUc2a9ZlDU7DjuP5MjK3AXRR0dYigCrP99aeFtaB2L/hjfEZdSThn5dsZ0ufqbvsA== @@ -2722,11 +2705,6 @@ resolved "https://registry.yarnpkg.com/@jridgewell/set-array/-/set-array-1.1.1.tgz#36a6acc93987adcf0ba50c66908bd0b70de8afea" integrity sha512-Ct5MqZkLGEXTVmQYbGtx9SVqD2fqwvdubdps5D3djjAkgkKwT918VNOz65pEHFaYTeWcukmJmH5SwsA9Tn2ObQ== -"@jridgewell/set-array@^1.0.0": - version "1.1.1" - resolved "https://registry.yarnpkg.com/@jridgewell/set-array/-/set-array-1.1.1.tgz#36a6acc93987adcf0ba50c66908bd0b70de8afea" - integrity sha512-Ct5MqZkLGEXTVmQYbGtx9SVqD2fqwvdubdps5D3djjAkgkKwT918VNOz65pEHFaYTeWcukmJmH5SwsA9Tn2ObQ== - "@jridgewell/sourcemap-codec@^1.4.10": version "1.4.13" resolved "https://registry.yarnpkg.com/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.13.tgz#b6461fb0c2964356c469e115f504c95ad97ab88c" @@ -10959,7 +10937,7 @@ json5@^1.0.1: dependencies: minimist "^1.2.0" -json5@^2.1.2, json5@^2.1.3, json5@^2.2.1: +json5@^2.1.2, json5@^2.1.3: version "2.2.1" resolved "https://registry.yarnpkg.com/json5/-/json5-2.2.1.tgz#655d50ed1e6f95ad1a3caababd2b0efda10b395c" integrity sha512-1hqLFMSrGHRHxav9q9gNjJ5EXznIxGVO09xQRrwplcS8qs28pZ8s8hupZAmqDwZUmVZ2Qb2jnyPOWcDH8m8dlA== @@ -16204,11 +16182,6 @@ tslib@^2.0.0, tslib@^2.0.1, tslib@^2.0.3, tslib@^2.1.0, tslib@^2.3.0, tslib@^2.4 resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.4.0.tgz#7cecaa7f073ce680a05847aa77be941098f36dc3" integrity sha512-d6xOpEDfsi2CZVlPQzGeux8XMwLT9hssAsaPYExaQMuYskwb+x1x7J371tWlbBdWHroy99KnVB6qIkUbs5X3UQ== -tslib@^2.4.0: - version "2.4.0" - resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.4.0.tgz#7cecaa7f073ce680a05847aa77be941098f36dc3" - integrity sha512-d6xOpEDfsi2CZVlPQzGeux8XMwLT9hssAsaPYExaQMuYskwb+x1x7J371tWlbBdWHroy99KnVB6qIkUbs5X3UQ== - tsutils@^3.17.1, tsutils@^3.21.0: version "3.21.0" resolved "https://registry.yarnpkg.com/tsutils/-/tsutils-3.21.0.tgz#b48717d394cea6c1e096983eed58e9d61715b623" @@ -16563,14 +16536,6 @@ use-dark-mode@2.3.1: "@use-it/event-listener" "^0.1.2" use-persisted-state "^0.3.0" -use-dark-mode@2.3.1: - version "2.3.1" - resolved "https://registry.yarnpkg.com/use-dark-mode/-/use-dark-mode-2.3.1.tgz#d506349c7b7e09e9977cb8a6ab4470896aa3779a" - integrity sha512-hmcdJR96tTustRQdaQwe6jMrZHnmPqXBxgy4jaQ4gsfhwajsCpjECuq9prgDe9XxMx/f9r96o2/md6O4Lwhwjg== - dependencies: - "@use-it/event-listener" "^0.1.2" - use-persisted-state "^0.3.0" - use-force-update@^1.0.7: version "1.0.8" resolved "https://registry.yarnpkg.com/use-force-update/-/use-force-update-1.0.8.tgz#14483faa4571673f070080f8233057b43b266ace" From 82a66d4e12176736270618aa3245036d5d479f92 Mon Sep 17 00:00:00 2001 From: Chris Tian Date: Mon, 23 May 2022 18:08:58 -0700 Subject: [PATCH 03/13] fix predators and human activity --- src/components/MonitorLog/GeneralInfoTab.jsx | 2 +- .../MonitorLog/HumanActivityTab.jsx | 25 ++++++++++++++----- src/components/MonitorLog/PredatorsTab.jsx | 11 +++++--- .../MonitorLog/ReviewSubmitTabPopup.jsx | 6 ++--- src/pages/AdminPage.jsx | 12 --------- src/pages/MonitorLogPage.jsx | 6 +++-- 6 files changed, 34 insertions(+), 28 deletions(-) diff --git a/src/components/MonitorLog/GeneralInfoTab.jsx b/src/components/MonitorLog/GeneralInfoTab.jsx index 43a201bb..13c0a824 100644 --- a/src/components/MonitorLog/GeneralInfoTab.jsx +++ b/src/components/MonitorLog/GeneralInfoTab.jsx @@ -210,7 +210,7 @@ function GeneralInfoTab({ assignedSegments, monitorPartners, isDisabled, showHea {/* Added Partners will be notified when this monitor log is submitted for review. */} { +const HumanActivityField = ({ + activityName, + activityDesc, + activityNum, + activityId, + isDisabled, +}) => { const { setValue, getValues } = useFormContext(); + const formKey = `${FORM_PREFIX}[${activityNum}]`; + + useEffect(() => { + setValue(formKey, { activity: activityId, count: getValues(formKey)?.count || 0 }); + }, []); return ( @@ -62,8 +73,8 @@ const HumanActivityField = ({ activityName, activityDesc, activityId, isDisabled setValue(FORM_PREFIX + activityId, val)} - defaultValue={getValues(FORM_PREFIX + activityId) || 0} + onChange={(_, val) => setValue(formKey, { activity: activityId, count: val })} + defaultValue={getValues(formKey)?.count || 0} > @@ -79,6 +90,7 @@ const HumanActivityField = ({ activityName, activityDesc, activityId, isDisabled HumanActivityField.propTypes = { activityName: PropTypes.string.isRequired, activityDesc: PropTypes.string.isRequired, + activityNum: PropTypes.number.isRequired, activityId: PropTypes.string.isRequired, isDisabled: PropTypes.bool.isRequired, }; @@ -98,10 +110,11 @@ const HumanActivityTab = ({ showHeader, isDisabled }) => { spacingX="64px" spacingY={{ md: '68px', base: '30px' }} > - {HUMAN_ACTIVITIES.map(([name, desc, value]) => ( + {HUMAN_ACTIVITIES.map(([name, desc, value], idx) => ( { const { setValue, getValues } = useFormContext(); + const formKey = `${FORM_PREFIX}[${predatorIndex}]`; + + React.useEffect(() => { + setValue(formKey, { species: predatorId, count: getValues(formKey)?.count || 0 }); + }, []); return ( @@ -32,10 +37,8 @@ const PredatorField = ({ predatorName, predatorId, isDisabled, predatorIndex }) - setValue(`${FORM_PREFIX}[${predatorIndex}]`, { species: predatorId, count: val }) - } - defaultValue={getValues(`${FORM_PREFIX}[${predatorIndex}]`)?.count || 0} + onChange={(_, val) => setValue(formKey, { species: predatorId, count: val })} + defaultValue={getValues(formKey)?.count || 0} > diff --git a/src/components/MonitorLog/ReviewSubmitTabPopup.jsx b/src/components/MonitorLog/ReviewSubmitTabPopup.jsx index a9271c0a..87a69f8d 100644 --- a/src/components/MonitorLog/ReviewSubmitTabPopup.jsx +++ b/src/components/MonitorLog/ReviewSubmitTabPopup.jsx @@ -47,9 +47,9 @@ function ReturnPopup({ submitForm }) { const [modalStep, setModalStep] = useState('submitSurvey'); const { isOpen, onOpen, onClose } = useDisclosure(); - useEffect(() => { - setModalStep('reminderSelect'); - }); + // useEffect(() => { + // setModalStep('reminderSelect'); + // }); const modalContent = { submitSurvey: ( diff --git a/src/pages/AdminPage.jsx b/src/pages/AdminPage.jsx index ff52e05d..699d4f7a 100644 --- a/src/pages/AdminPage.jsx +++ b/src/pages/AdminPage.jsx @@ -106,18 +106,6 @@ const AdminPage = () => { SEGMENT, VOLUNTEER(S), and APPROVAL STATUS. - {/*
-          {JSON.stringify(
-            {
-              segmentFilter,
-              dateFilter,
-              approvalFilter,
-              searchFilter,
-            },
-            null,
-            2,
-          )}
-        
*/} { h="16" zIndex="banner" > - +