From 3270a642910ea1b49edb9b3f5260d632f50a5667 Mon Sep 17 00:00:00 2001 From: Brijesh Date: Mon, 27 May 2024 14:55:24 -0700 Subject: [PATCH 1/5] extensiopn plan creation UI changes --- src/api/plan.js | 29 +++-- src/components/rangeUsePlanPage/ActionBtns.js | 1 + .../futurePlans/FuturePlanActions.js | 103 ++++++++++++++++++ .../futurePlans/FuturePlansDropdown.js | 27 +++++ .../futurePlans/FuturePlansDropdownList.js | 85 +++++++++++++++ .../rangeUsePlanPage/pageForAH/index.js | 3 +- .../CreateExtensionPlan.js | 22 ++++ .../selectRangeUsePlanPage/ExtensionColumn.js | 11 +- .../selectRangeUsePlanPage/PlanActions.js | 7 ++ .../selectRangeUsePlanPage/PlanRow.js | 7 +- src/constants/api.js | 8 +- 11 files changed, 284 insertions(+), 19 deletions(-) create mode 100644 src/components/rangeUsePlanPage/futurePlans/FuturePlanActions.js create mode 100644 src/components/rangeUsePlanPage/futurePlans/FuturePlansDropdown.js create mode 100644 src/components/rangeUsePlanPage/futurePlans/FuturePlansDropdownList.js create mode 100644 src/components/selectRangeUsePlanPage/CreateExtensionPlan.js diff --git a/src/api/plan.js b/src/api/plan.js index f49659d5..c4beeee7 100644 --- a/src/api/plan.js +++ b/src/api/plan.js @@ -4,12 +4,12 @@ import { getAuthHeaderConfig, findStatusWithCode, isUserAgrologist, - canUserAddAttachments -} from '../utils' -import * as API from '../constants/api' -import RUPSchema from '../components/rangeUsePlanPage/schema' -import { getNetworkStatus } from '../utils/helper/network' -import { deleteFromQueue } from './delete' + canUserAddAttachments, +} from '../utils'; +import * as API from '../constants/api'; +import RUPSchema from '../components/rangeUsePlanPage/schema'; +import { getNetworkStatus } from '../utils/helper/network'; +import { deleteFromQueue } from './delete'; import { saveGrazingSchedules, saveInvasivePlantChecklist, @@ -109,13 +109,13 @@ export const savePlan = async (plan, user = {}) => { }), ); - await saveGrazingSchedules(planId, grazingSchedules, newPastures) - await saveInvasivePlantChecklist(planId, invasivePlantChecklist) - await saveManagementConsiderations(planId, managementConsiderations) - await saveMinisterIssues(planId, ministerIssues, newPastures) - await saveAdditionalRequirements(planId, additionalRequirements) + await saveGrazingSchedules(planId, grazingSchedules, newPastures); + await saveInvasivePlantChecklist(planId, invasivePlantChecklist); + await saveManagementConsiderations(planId, managementConsiderations); + await saveMinisterIssues(planId, ministerIssues, newPastures); + await saveAdditionalRequirements(planId, additionalRequirements); if (isUserAgrologist(user) && canUserAddAttachments(plan, user)) { - await saveAttachments(planId, files) + await saveAttachments(planId, files); } return planId; @@ -247,6 +247,11 @@ export const updateStatus = async ({ planId, note, statusId }) => { ); }; +export const createExtensionPlan = async (planId) => { + return (await axios.put(API.EXTENSION_PLAN(planId), getAuthHeaderConfig())) + .data.extensionPlan; +}; + export const updateConfirmation = async ({ user, planId, diff --git a/src/components/rangeUsePlanPage/ActionBtns.js b/src/components/rangeUsePlanPage/ActionBtns.js index 1c1c6f6b..ec7a0438 100644 --- a/src/components/rangeUsePlanPage/ActionBtns.js +++ b/src/components/rangeUsePlanPage/ActionBtns.js @@ -123,6 +123,7 @@ const ActionBtns = ({ ...permissionsOptions, }; + console.log(permissions); return ( <>
diff --git a/src/components/rangeUsePlanPage/futurePlans/FuturePlanActions.js b/src/components/rangeUsePlanPage/futurePlans/FuturePlanActions.js new file mode 100644 index 00000000..263cb544 --- /dev/null +++ b/src/components/rangeUsePlanPage/futurePlans/FuturePlanActions.js @@ -0,0 +1,103 @@ +import React, { useEffect } from 'react'; +import ClickAwayListener from '@material-ui/core/ClickAwayListener'; +import Grow from '@material-ui/core/Grow'; +import Paper from '@material-ui/core/Paper'; +import Popper from '@material-ui/core/Popper'; +import MenuItem from '@material-ui/core/MenuItem'; +import MenuList from '@material-ui/core/MenuList'; +import { IconButton } from '@material-ui/core'; +import { MoreVert } from '@material-ui/icons'; +import EditIcon from '@material-ui/icons/Edit'; +import ViewIcon from '@material-ui/icons/Visibility'; +import { Link } from 'react-router-dom'; +import { RANGE_USE_PLAN } from '../../../constants/routes'; +import { EDIT, VIEW } from '../../../constants/strings'; + +export default function FuturePlanActions({ planId, canEdit, currentPage }) { + const [open, setOpen] = React.useState(false); + const anchorRef = React.useRef(null); + + const handleClose = (event) => { + if (anchorRef.current && anchorRef.current.contains(event.target)) { + return; + } + setOpen(false); + }; + + function handleListKeyDown(event) { + if (event.key === 'Tab') { + event.preventDefault(); + setOpen(false); + } + } + const prevOpen = React.useRef(open); + useEffect(() => { + if (prevOpen.current === true && open === false) { + anchorRef.current.focus(); + } + prevOpen.current = open; + }, [open]); + + return ( +
+ setOpen(true)} + onMouseLeave={() => setOpen(false)} + > + + + setOpen(true)} + onMouseLeave={() => setOpen(false)} + style={{ zIndex: 1 }} + > + {({ TransitionProps, placement }) => ( + + + + + {planId && ( + : } + > + {canEdit ? EDIT : VIEW} + + )} + + + + + )} + +
+ ); +} diff --git a/src/components/rangeUsePlanPage/futurePlans/FuturePlansDropdown.js b/src/components/rangeUsePlanPage/futurePlans/FuturePlansDropdown.js new file mode 100644 index 00000000..4c143c9c --- /dev/null +++ b/src/components/rangeUsePlanPage/futurePlans/FuturePlansDropdown.js @@ -0,0 +1,27 @@ +import React from 'react'; +import useSWR from 'swr'; +import * as API from '../../../constants/api'; +import { axios, getAuthHeaderConfig } from '../../../utils'; +import FuturePlansDropdownList from './FuturePlansDropdownList'; + +const FuturePlansDropdown = ({ planId, open }) => { + const endpoint = API.GET_EXTENSION_PLAN(planId); + + const { data, error, isValidating } = useSWR( + () => (open ? endpoint : null), + (key) => + axios + .get(key, { + ...getAuthHeaderConfig(), + }) + .then((res) => res.data), + ); + const futurePlans = data || []; + if (error) return
Error: {JSON.stringify(error.message)}
; + if (isValidating) { + return

Loading futurePlan data...

; + } + return ; +}; + +export default FuturePlansDropdown; diff --git a/src/components/rangeUsePlanPage/futurePlans/FuturePlansDropdownList.js b/src/components/rangeUsePlanPage/futurePlans/FuturePlansDropdownList.js new file mode 100644 index 00000000..923c4931 --- /dev/null +++ b/src/components/rangeUsePlanPage/futurePlans/FuturePlansDropdownList.js @@ -0,0 +1,85 @@ +import React from 'react'; +import Box from '@material-ui/core/Box'; +import Collapse from '@material-ui/core/Collapse'; +import Table from '@material-ui/core/Table'; +import TableBody from '@material-ui/core/TableBody'; +import TableCell from '@material-ui/core/TableCell'; +import TableHead from '@material-ui/core/TableHead'; +import TableRow from '@material-ui/core/TableRow'; +import Typography from '@material-ui/core/Typography'; +import { formatDateFromServer } from '../pdf/helper'; +import { Status } from '../../common'; +// import moment from 'moment'; +// import classnames from 'classnames'; +// import Status from '../../common/Status'; +import { useUser } from '../../../providers/UserProvider'; + +const FuturePlansDropdownList = ({ futurePlans, open }) => { + const user = useUser(); + + const futurePlanOptions = futurePlans.map((v) => ({ + key: v.futurePlan, + value: v, + text: `v${v.futurePlan}`, + futurePlan: v, + })); + + return ( + + + + + + Extension plan + + + + + + Plan Start Date + + Plan End Date + + Status + + + + + + + {futurePlanOptions.map((option, index) => { + return ( + <> + + + {formatDateFromServer( + option.futurePlan.planStartDate, + )} + + + {formatDateFromServer(option.futurePlan.planEndDate)} + + + {option.futurePlan ? ( + + ) : ( + - + )} + + + + ); + })} + +
+
+
+
+
+ ); +}; + +export default FuturePlansDropdownList; diff --git a/src/components/rangeUsePlanPage/pageForAH/index.js b/src/components/rangeUsePlanPage/pageForAH/index.js index 9d200c37..6bcb5990 100644 --- a/src/components/rangeUsePlanPage/pageForAH/index.js +++ b/src/components/rangeUsePlanPage/pageForAH/index.js @@ -20,6 +20,7 @@ import PlanForm from '../PlanForm'; import { createAmendment, savePlan } from '../../../api'; import { canUserEditThisPlan, isPlanAmendment } from '../../../utils'; import NetworkStatus from '../../common/NetworkStatus'; +import permissions from '../../../constants/permissions'; // Agreement Holder page class PageForAH extends Component { @@ -172,7 +173,7 @@ class PageForAH extends Component { const { isSavingAsDraft, isSubmitting, isCreatingAmendment } = this.state; const { openConfirmationModal, plan, user, clientAgreements } = this.props; const { confirmations, status } = plan; - + console.log(permissions + '****************************'); return ( { + const history = useHistory(); + return ( + { + e.stopPropagation(); + const extensionPlan = await createExtensionPlan(planId); + history.push(`${RANGE_USE_PLAN}/${extensionPlan.id}`); + }} + > + Create Extension Plan + + ); +}; + +export default CreateExtensionPlan; diff --git a/src/components/selectRangeUsePlanPage/ExtensionColumn.js b/src/components/selectRangeUsePlanPage/ExtensionColumn.js index 87ca0e0e..5d8a4dbd 100644 --- a/src/components/selectRangeUsePlanPage/ExtensionColumn.js +++ b/src/components/selectRangeUsePlanPage/ExtensionColumn.js @@ -302,11 +302,14 @@ export default function ExtensionColumn({ user, currentPage, agreement }) { } else { if ( agreement.plan?.planExtensionRequests.filter((request) => { - return request.userId === user.id && request.requestedExtension; - }).length === 0 + return ( + request.userId === user.id && + request.requestedExtension === true + ); + }).length !== 0 ) - return <>Rejected; - return <>Requested; + return <>Requested; + return <>-; } case PLAN_EXTENSION_STATUS.AGREEMENT_HOLDER_REJECTED: return
Agreement Holder Rejected
; diff --git a/src/components/selectRangeUsePlanPage/PlanActions.js b/src/components/selectRangeUsePlanPage/PlanActions.js index 76997bcc..5703051f 100644 --- a/src/components/selectRangeUsePlanPage/PlanActions.js +++ b/src/components/selectRangeUsePlanPage/PlanActions.js @@ -97,6 +97,13 @@ export default function PlanActions({ {canCreatePlan && !planId && ( )} + {[ + PLAN_EXTENSION_STATUS.AGREEMENT_HOLDER_REJECTED, + PLAN_EXTENSION_STATUS.STAFF_REJECTED, + PLAN_EXTENSION_STATUS.DISTRICT_MANAGER_REJECTED, + ].includes(agreement.plan?.extensionStatus) && ( + + )} diff --git a/src/components/selectRangeUsePlanPage/PlanRow.js b/src/components/selectRangeUsePlanPage/PlanRow.js index 24772200..f2c4b5c4 100644 --- a/src/components/selectRangeUsePlanPage/PlanRow.js +++ b/src/components/selectRangeUsePlanPage/PlanRow.js @@ -17,11 +17,13 @@ import VersionsDropdown from '../rangeUsePlanPage/versionsList/VersionsDropdown' import { useStyles } from './SortableAgreementTable'; import ExtensionColumn from './ExtensionColumn'; import PlanActions from './PlanActions'; +import FuturePlansDropdown from '../rangeUsePlanPage/futurePlans/FuturePlansDropdown'; function PlanRow({ agreement, user, currentPage }) { const classes = useStyles(); const [open, setOpen] = useState(false); const canEdit = canUserEditThisPlan({ ...agreement.plan }, user); + console.log('--->' + JSON.stringify(agreement.plan)); return ( <> @@ -113,7 +115,10 @@ function PlanRow({ agreement, user, currentPage }) { {agreement.plan?.id && ( - + <> + + + )} ); diff --git a/src/constants/api.js b/src/constants/api.js index af3f3697..a4e75897 100644 --- a/src/constants/api.js +++ b/src/constants/api.js @@ -84,7 +84,7 @@ export const UPDATE_USER_PROFILE = '/v1/user/me'; export const UPDATE_USER_ID_OF_ZONE = (zoneId) => `/v1/zone/${zoneId}/user`; export const CREATE_USER_CLIENT_LINK = (userId) => `/v1/user/${userId}/client`; export const DELETE_USER_CLIENT_LINK = (userId, clientId) => -`/v1/user/${userId}/client/${clientId}`; + `/v1/user/${userId}/client/${clientId}`; export const MERGE_ACCOUNTS = (userId) => `/v1/user/${userId}/merge`; export const ASSIGN_ROLE = (userId) => `/v1/user/${userId}/assignRole`; export const ASSIGN_DISTRICT = (userId) => `/v1/user/${userId}/assignDistrict`; @@ -104,12 +104,18 @@ export const EXTEND_PLAN = (planId, endDate) => export const REQUEST_EXTENSION = (planId) => `/v1/plan/${planId}/extension/request`; export const APPROVE_VOTE = (planId) => `/v1/plan/${planId}/extension/approve`; +export const GET_EXTENSION_PLAN = (planId) => `/v1/plan/${planId}/extension`; +export const EXTENSION_PLAN = (planId) => + `/v1/plan/${planId}/extension/createExtensionPlan`; export const REJECT_VOTE = (planId) => `/v1/plan/${planId}/extension/reject`; export const UPDATE_CONFIRMATION = (planId, confirmationId) => `/v1/plan/${planId}/confirmation/${confirmationId}`; export const DISCARD_AMENDMENT = (planId) => `v1/plan/${planId}/discard-amendment`; +export const GET_RUP_FUTURE_PLAN = (planId, version) => + `/v1/plan/${planId}/version/${version}`; + export const CREATE_RUP_VERSION = (planId) => `/v1/plan/${planId}/version`; export const GET_RUP_VERSIONS = (planId) => `/v1/plan/${planId}/version`; export const GET_RUP_VERSION = (planId, version) => From c19d9794a579a02933ab06864847c2e35a07ae4c Mon Sep 17 00:00:00 2001 From: Brijesh Date: Tue, 28 May 2024 19:35:19 -0700 Subject: [PATCH 2/5] rebased on dev --- .../selectRangeUsePlanPage/PlanActions.js | 16 +++++++++------- src/components/selectRangeUsePlanPage/PlanRow.js | 1 - 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/components/selectRangeUsePlanPage/PlanActions.js b/src/components/selectRangeUsePlanPage/PlanActions.js index 5703051f..d4f5f858 100644 --- a/src/components/selectRangeUsePlanPage/PlanActions.js +++ b/src/components/selectRangeUsePlanPage/PlanActions.js @@ -1,18 +1,20 @@ -import React from 'react'; +import { Button } from '@material-ui/core'; import ClickAwayListener from '@material-ui/core/ClickAwayListener'; import Grow from '@material-ui/core/Grow'; -import Paper from '@material-ui/core/Paper'; -import Popper from '@material-ui/core/Popper'; import MenuItem from '@material-ui/core/MenuItem'; import MenuList from '@material-ui/core/MenuList'; -import { Button } from '@material-ui/core'; -import { RANGE_USE_PLAN } from '../../constants/routes'; -import * as strings from '../../constants/strings'; +import Paper from '@material-ui/core/Paper'; +import Popper from '@material-ui/core/Popper'; import EditIcon from '@material-ui/icons/Edit'; +import KeyboardArrowDown from '@material-ui/icons/KeyboardArrowDown'; import ViewIcon from '@material-ui/icons/Visibility'; +import React from 'react'; import { Link } from 'react-router-dom'; +import { RANGE_USE_PLAN } from '../../constants/routes'; +import * as strings from '../../constants/strings'; +import { PLAN_EXTENSION_STATUS } from '../../constants/variables'; +import CreateExtensionPlan from './CreateExtensionPlan'; import NewPlanMenuItem from './NewPlanMenuItem'; -import KeyboardArrowDown from '@material-ui/icons/KeyboardArrowDown'; export default function PlanActions({ agreement, diff --git a/src/components/selectRangeUsePlanPage/PlanRow.js b/src/components/selectRangeUsePlanPage/PlanRow.js index f2c4b5c4..6fccceaa 100644 --- a/src/components/selectRangeUsePlanPage/PlanRow.js +++ b/src/components/selectRangeUsePlanPage/PlanRow.js @@ -23,7 +23,6 @@ function PlanRow({ agreement, user, currentPage }) { const classes = useStyles(); const [open, setOpen] = useState(false); const canEdit = canUserEditThisPlan({ ...agreement.plan }, user); - console.log('--->' + JSON.stringify(agreement.plan)); return ( <> From 1a9783f6ee1c3978932967dd82ab8dfb4e8514d8 Mon Sep 17 00:00:00 2001 From: Brijesh Date: Fri, 31 May 2024 11:52:37 -0700 Subject: [PATCH 3/5] Replacement plan UI changes and improvements --- src/api/plan.js | 6 +- src/components/rangeUsePlanPage/PlanForm.js | 31 +++--- .../futurePlans/FuturePlanActions.js | 103 ------------------ .../futurePlans/FuturePlansDropdown.js | 27 ----- .../futurePlans/FuturePlansDropdownList.js | 85 --------------- .../CreateExtensionPlan.js | 22 ---- .../CreateReplacementPlan.js | 23 ++++ .../selectRangeUsePlanPage/ExtensionColumn.js | 6 + .../selectRangeUsePlanPage/PlanActions.js | 49 +++------ .../selectRangeUsePlanPage/PlanRow.js | 2 - .../ViewPlanMenuItem.js | 25 +++++ src/constants/api.js | 7 +- src/constants/variables.js | 5 +- 13 files changed, 100 insertions(+), 291 deletions(-) delete mode 100644 src/components/rangeUsePlanPage/futurePlans/FuturePlanActions.js delete mode 100644 src/components/rangeUsePlanPage/futurePlans/FuturePlansDropdown.js delete mode 100644 src/components/rangeUsePlanPage/futurePlans/FuturePlansDropdownList.js delete mode 100644 src/components/selectRangeUsePlanPage/CreateExtensionPlan.js create mode 100644 src/components/selectRangeUsePlanPage/CreateReplacementPlan.js create mode 100644 src/components/selectRangeUsePlanPage/ViewPlanMenuItem.js diff --git a/src/api/plan.js b/src/api/plan.js index c4beeee7..d5fac2fa 100644 --- a/src/api/plan.js +++ b/src/api/plan.js @@ -247,9 +247,9 @@ export const updateStatus = async ({ planId, note, statusId }) => { ); }; -export const createExtensionPlan = async (planId) => { - return (await axios.put(API.EXTENSION_PLAN(planId), getAuthHeaderConfig())) - .data.extensionPlan; +export const createReplacementPlan = async (planId) => { + return (await axios.put(API.REPLACEMENT_PLAN(planId), getAuthHeaderConfig())) + .data.replacementPlan; }; export const updateConfirmation = async ({ diff --git a/src/components/rangeUsePlanPage/PlanForm.js b/src/components/rangeUsePlanPage/PlanForm.js index 1b176a56..f50b1e5b 100644 --- a/src/components/rangeUsePlanPage/PlanForm.js +++ b/src/components/rangeUsePlanPage/PlanForm.js @@ -15,7 +15,12 @@ import { Attachments, AttachmentsHeader } from './attachments'; import EditableProvider from '../../providers/EditableProvider'; import { isUUID } from 'uuid-v4'; import { useUser } from '../../providers/UserProvider'; -import { canUserAttachMaps, canUserAddAttachments, canUserConsiderManagement, canUserAddAdditionalReqs } from '../../utils'; +import { + canUserAttachMaps, + canUserAddAttachments, + canUserConsiderManagement, + canUserAddAdditionalReqs, +} from '../../utils'; const PlanForm = ({ plan, @@ -98,26 +103,26 @@ const PlanForm = ({ + - - + )} diff --git a/src/components/rangeUsePlanPage/futurePlans/FuturePlanActions.js b/src/components/rangeUsePlanPage/futurePlans/FuturePlanActions.js deleted file mode 100644 index 263cb544..00000000 --- a/src/components/rangeUsePlanPage/futurePlans/FuturePlanActions.js +++ /dev/null @@ -1,103 +0,0 @@ -import React, { useEffect } from 'react'; -import ClickAwayListener from '@material-ui/core/ClickAwayListener'; -import Grow from '@material-ui/core/Grow'; -import Paper from '@material-ui/core/Paper'; -import Popper from '@material-ui/core/Popper'; -import MenuItem from '@material-ui/core/MenuItem'; -import MenuList from '@material-ui/core/MenuList'; -import { IconButton } from '@material-ui/core'; -import { MoreVert } from '@material-ui/icons'; -import EditIcon from '@material-ui/icons/Edit'; -import ViewIcon from '@material-ui/icons/Visibility'; -import { Link } from 'react-router-dom'; -import { RANGE_USE_PLAN } from '../../../constants/routes'; -import { EDIT, VIEW } from '../../../constants/strings'; - -export default function FuturePlanActions({ planId, canEdit, currentPage }) { - const [open, setOpen] = React.useState(false); - const anchorRef = React.useRef(null); - - const handleClose = (event) => { - if (anchorRef.current && anchorRef.current.contains(event.target)) { - return; - } - setOpen(false); - }; - - function handleListKeyDown(event) { - if (event.key === 'Tab') { - event.preventDefault(); - setOpen(false); - } - } - const prevOpen = React.useRef(open); - useEffect(() => { - if (prevOpen.current === true && open === false) { - anchorRef.current.focus(); - } - prevOpen.current = open; - }, [open]); - - return ( -
- setOpen(true)} - onMouseLeave={() => setOpen(false)} - > - - - setOpen(true)} - onMouseLeave={() => setOpen(false)} - style={{ zIndex: 1 }} - > - {({ TransitionProps, placement }) => ( - - - - - {planId && ( - : } - > - {canEdit ? EDIT : VIEW} - - )} - - - - - )} - -
- ); -} diff --git a/src/components/rangeUsePlanPage/futurePlans/FuturePlansDropdown.js b/src/components/rangeUsePlanPage/futurePlans/FuturePlansDropdown.js deleted file mode 100644 index 4c143c9c..00000000 --- a/src/components/rangeUsePlanPage/futurePlans/FuturePlansDropdown.js +++ /dev/null @@ -1,27 +0,0 @@ -import React from 'react'; -import useSWR from 'swr'; -import * as API from '../../../constants/api'; -import { axios, getAuthHeaderConfig } from '../../../utils'; -import FuturePlansDropdownList from './FuturePlansDropdownList'; - -const FuturePlansDropdown = ({ planId, open }) => { - const endpoint = API.GET_EXTENSION_PLAN(planId); - - const { data, error, isValidating } = useSWR( - () => (open ? endpoint : null), - (key) => - axios - .get(key, { - ...getAuthHeaderConfig(), - }) - .then((res) => res.data), - ); - const futurePlans = data || []; - if (error) return
Error: {JSON.stringify(error.message)}
; - if (isValidating) { - return

Loading futurePlan data...

; - } - return ; -}; - -export default FuturePlansDropdown; diff --git a/src/components/rangeUsePlanPage/futurePlans/FuturePlansDropdownList.js b/src/components/rangeUsePlanPage/futurePlans/FuturePlansDropdownList.js deleted file mode 100644 index 923c4931..00000000 --- a/src/components/rangeUsePlanPage/futurePlans/FuturePlansDropdownList.js +++ /dev/null @@ -1,85 +0,0 @@ -import React from 'react'; -import Box from '@material-ui/core/Box'; -import Collapse from '@material-ui/core/Collapse'; -import Table from '@material-ui/core/Table'; -import TableBody from '@material-ui/core/TableBody'; -import TableCell from '@material-ui/core/TableCell'; -import TableHead from '@material-ui/core/TableHead'; -import TableRow from '@material-ui/core/TableRow'; -import Typography from '@material-ui/core/Typography'; -import { formatDateFromServer } from '../pdf/helper'; -import { Status } from '../../common'; -// import moment from 'moment'; -// import classnames from 'classnames'; -// import Status from '../../common/Status'; -import { useUser } from '../../../providers/UserProvider'; - -const FuturePlansDropdownList = ({ futurePlans, open }) => { - const user = useUser(); - - const futurePlanOptions = futurePlans.map((v) => ({ - key: v.futurePlan, - value: v, - text: `v${v.futurePlan}`, - futurePlan: v, - })); - - return ( - - - - - - Extension plan - - - - - - Plan Start Date - - Plan End Date - - Status - - - - - - - {futurePlanOptions.map((option, index) => { - return ( - <> - - - {formatDateFromServer( - option.futurePlan.planStartDate, - )} - - - {formatDateFromServer(option.futurePlan.planEndDate)} - - - {option.futurePlan ? ( - - ) : ( - - - )} - - - - ); - })} - -
-
-
-
-
- ); -}; - -export default FuturePlansDropdownList; diff --git a/src/components/selectRangeUsePlanPage/CreateExtensionPlan.js b/src/components/selectRangeUsePlanPage/CreateExtensionPlan.js deleted file mode 100644 index 6af5406a..00000000 --- a/src/components/selectRangeUsePlanPage/CreateExtensionPlan.js +++ /dev/null @@ -1,22 +0,0 @@ -import { useHistory } from 'react-router-dom'; -import React from 'react'; -import { MenuItem } from '@material-ui/core'; -import { createExtensionPlan } from '../../api'; -import { RANGE_USE_PLAN } from '../../constants/routes'; - -const CreateExtensionPlan = ({ planId }) => { - const history = useHistory(); - return ( - { - e.stopPropagation(); - const extensionPlan = await createExtensionPlan(planId); - history.push(`${RANGE_USE_PLAN}/${extensionPlan.id}`); - }} - > - Create Extension Plan - - ); -}; - -export default CreateExtensionPlan; diff --git a/src/components/selectRangeUsePlanPage/CreateReplacementPlan.js b/src/components/selectRangeUsePlanPage/CreateReplacementPlan.js new file mode 100644 index 00000000..6f835b9c --- /dev/null +++ b/src/components/selectRangeUsePlanPage/CreateReplacementPlan.js @@ -0,0 +1,23 @@ +import { useHistory } from 'react-router-dom'; +import React from 'react'; +import { MenuItem } from '@material-ui/core'; +import { createReplacementPlan } from '../../api'; +import { RANGE_USE_PLAN } from '../../constants/routes'; + +const CreateReplacementPlan = ({ planId }) => { + const history = useHistory(); + return ( + { + e.stopPropagation(); + const replacementPlan = await createReplacementPlan(planId); + console.log(replacementPlan); + history.push(`${RANGE_USE_PLAN}/${replacementPlan.id}`); + }} + > + Create Replacement Plan + + ); +}; + +export default CreateReplacementPlan; diff --git a/src/components/selectRangeUsePlanPage/ExtensionColumn.js b/src/components/selectRangeUsePlanPage/ExtensionColumn.js index 5d8a4dbd..9a929d1e 100644 --- a/src/components/selectRangeUsePlanPage/ExtensionColumn.js +++ b/src/components/selectRangeUsePlanPage/ExtensionColumn.js @@ -147,6 +147,8 @@ export default function ExtensionColumn({ user, currentPage, agreement }) { return
Staff Rejected
; case PLAN_EXTENSION_STATUS.DISTRICT_MANAGER_REJECTED: return
District Manager Rejected
; + case PLAN_EXTENSION_STATUS.REPLACEMENT_PLAN_CREATED: + return
Replacement Plan Created
; case PLAN_EXTENSION_STATUS.AWAITING_EXTENSION: if ( agreement.plan?.extensionReceivedVotes === @@ -253,6 +255,8 @@ export default function ExtensionColumn({ user, currentPage, agreement }) { return
District Manager Rejected
; case PLAN_EXTENSION_STATUS.AWAITING_EXTENSION: return
Awaiting Extension
; + case PLAN_EXTENSION_STATUS.REPLACEMENT_PLAN_CREATED: + return
Replacement Plan Created
; case PLAN_EXTENSION_STATUS.EXTENDED: return (
@@ -319,6 +323,8 @@ export default function ExtensionColumn({ user, currentPage, agreement }) { return
District Manager Rejected
; case PLAN_EXTENSION_STATUS.AWAITING_EXTENSION: return
Awaiting Extension
; + case PLAN_EXTENSION_STATUS.REPLACEMENT_PLAN_CREATED: + return
Replacement Plan Created
; case PLAN_EXTENSION_STATUS.EXTENDED: return (
diff --git a/src/components/selectRangeUsePlanPage/PlanActions.js b/src/components/selectRangeUsePlanPage/PlanActions.js index d4f5f858..df4859d5 100644 --- a/src/components/selectRangeUsePlanPage/PlanActions.js +++ b/src/components/selectRangeUsePlanPage/PlanActions.js @@ -1,20 +1,16 @@ import { Button } from '@material-ui/core'; import ClickAwayListener from '@material-ui/core/ClickAwayListener'; import Grow from '@material-ui/core/Grow'; -import MenuItem from '@material-ui/core/MenuItem'; import MenuList from '@material-ui/core/MenuList'; import Paper from '@material-ui/core/Paper'; import Popper from '@material-ui/core/Popper'; -import EditIcon from '@material-ui/icons/Edit'; import KeyboardArrowDown from '@material-ui/icons/KeyboardArrowDown'; -import ViewIcon from '@material-ui/icons/Visibility'; import React from 'react'; -import { Link } from 'react-router-dom'; -import { RANGE_USE_PLAN } from '../../constants/routes'; import * as strings from '../../constants/strings'; import { PLAN_EXTENSION_STATUS } from '../../constants/variables'; -import CreateExtensionPlan from './CreateExtensionPlan'; +import CreateReplacementPlan from './CreateReplacementPlan'; import NewPlanMenuItem from './NewPlanMenuItem'; +import ViewPlanMenuItem from './ViewPlanMenuItem'; export default function PlanActions({ agreement, @@ -37,7 +33,6 @@ export default function PlanActions({ setOpen(false); }; - return (