diff --git a/src/api/plan.js b/src/api/plan.js index f49659d5..d5fac2fa 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 createReplacementPlan = async (planId) => { + return (await axios.put(API.REPLACEMENT_PLAN(planId), getAuthHeaderConfig())) + .data.replacementPlan; +}; + export const updateConfirmation = async ({ user, planId, diff --git a/src/components/common/Banner.js b/src/components/common/Banner.js index 51e33eb4..e158bf3d 100644 --- a/src/components/common/Banner.js +++ b/src/components/common/Banner.js @@ -14,15 +14,26 @@ const defaultProps = { noDefaultHeight: false, }; -const Banner = ({ header, content, style, noDefaultHeight, contentLine2 }) => ( +const Banner = ({ + header, + content, + style, + noDefaultHeight, + contentLine2, + isReplacementPlan, +}) => (
-

{header}

+

+ {header} + {isReplacementPlan ? ' (Replacement Plan)' : ''} +

{content}
{contentLine2 && ( <> diff --git a/src/components/emailTemplatePage/index.js b/src/components/emailTemplatePage/index.js index ddd9f1a9..aac177a1 100644 --- a/src/components/emailTemplatePage/index.js +++ b/src/components/emailTemplatePage/index.js @@ -110,7 +110,6 @@ const EmailTemplatePage = () => { setSelectedTemplate({ @@ -124,7 +123,6 @@ const EmailTemplatePage = () => { { setSelectedTemplate({ 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/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/manageAgentsPage/index.js b/src/components/rangeUsePlanPage/manageAgentsPage/index.js index b11e4304..688dc6e6 100644 --- a/src/components/rangeUsePlanPage/manageAgentsPage/index.js +++ b/src/components/rangeUsePlanPage/manageAgentsPage/index.js @@ -150,7 +150,6 @@ const ManageAgentsPage = ({ match }) => { {...params} label="Select user" variant="outlined" - fullWidth className={classes.autocomplete} /> )} diff --git a/src/components/rangeUsePlanPage/pageForAH/index.js b/src/components/rangeUsePlanPage/pageForAH/index.js index 9d200c37..814b2205 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 ( - +
diff --git a/src/components/rangeUsePlanPage/pageForStaff/index.js b/src/components/rangeUsePlanPage/pageForStaff/index.js index b7632e66..7b3d23ab 100644 --- a/src/components/rangeUsePlanPage/pageForStaff/index.js +++ b/src/components/rangeUsePlanPage/pageForStaff/index.js @@ -254,7 +254,12 @@ class PageForStaff extends Component { content={strings.SUBMIT_PLAN_CONFIRM_CONTENT} /> - +
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 87ca0e0e..e78a4859 100644 --- a/src/components/selectRangeUsePlanPage/ExtensionColumn.js +++ b/src/components/selectRangeUsePlanPage/ExtensionColumn.js @@ -147,6 +147,10 @@ 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.REPLACEMENT_PLAN_ACTIVE: + return
Active Replacement Plan
; case PLAN_EXTENSION_STATUS.AWAITING_EXTENSION: if ( agreement.plan?.extensionReceivedVotes === @@ -205,6 +209,7 @@ export default function ExtensionColumn({ user, currentPage, agreement }) { const renderExtensionForStaff = (user, agreement) => { if (isUserStaff(user)) { + console.log(agreement.plan?.extensionStatus); switch (agreement.plan?.extensionStatus) { case PLAN_EXTENSION_STATUS.AWAITING_VOTES: if ( @@ -253,6 +258,10 @@ 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.REPLACEMENT_PLAN_ACTIVE: + return
Active Replacement Plan
; case PLAN_EXTENSION_STATUS.EXTENDED: return (
@@ -302,11 +311,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
; @@ -316,6 +328,10 @@ 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.REPLACEMENT_PLAN_ACTIVE: + return
Active Replacement Plan
; case PLAN_EXTENSION_STATUS.EXTENDED: return (
diff --git a/src/components/selectRangeUsePlanPage/NewPlanButton.js b/src/components/selectRangeUsePlanPage/NewPlanButton.js index 32ad757b..c0bd462c 100644 --- a/src/components/selectRangeUsePlanPage/NewPlanButton.js +++ b/src/components/selectRangeUsePlanPage/NewPlanButton.js @@ -25,7 +25,6 @@ const NewPlanButton = ({ agreement }) => { return (