diff --git a/src/components/AllocationAddForm.js b/src/components/AllocationAddForm.js index f88809ab..b1c792f3 100644 --- a/src/components/AllocationAddForm.js +++ b/src/components/AllocationAddForm.js @@ -61,6 +61,7 @@ const AllocationAddForm = (props) => { } = props const [allocationTypes, setAllocationTypes] = useState([1, 0]) + const [allocationSelection, setAllocationSelection] = useState([1, 0]) const [contributorAllocations, setContributorAllocations] = useState(null) const [contributorRates, setContributorRates] = useState(null) const [displayError, setDisplayError] = useState(false) @@ -84,6 +85,14 @@ const AllocationAddForm = (props) => { setAllocationTypes([...allocationTypesState]) } + const addAllocationOrLinkPayment = (props) => { + const { allocationSelection, selection } = props + const selectionState = allocationSelection + fill(selectionState, 0) + selectionState[selection] = 1 + setAllocationSelection([...selectionState]) + } + const handleAlertClose = (event, reason) => { if (reason === 'clickaway') { return @@ -427,7 +436,37 @@ const AllocationAddForm = (props) => { > - {`Add Allocation`} + {project && + `Add Allocation` + } + {client && !selectedProject && + + + + + } @@ -457,6 +496,7 @@ const AllocationAddForm = (props) => { setNewAllocation={setNewAllocation} setContributor={setSelectedContributor} setProject={setSelectedProject} + allocationSelection={allocationSelection} /> ) : ( { project, setContributor, setProject, - setNewAllocation + setNewAllocation, + allocationSelection } = props const { @@ -174,99 +175,109 @@ const AllocationClientSpecifics = (props) => { return ( - - - - - - - - - - - {`${paymentAmount}`} - - - - - {`${payment.date_paid - ? moment.utc(payment.date_paid, 'x').format('MM/DD/YYYY') - : '' - }`} - {`${ - !payment.date_paid && payment.date_incurred - ? 'Warning: This payment has not been paid' - : '' + {allocationSelection[0] + ? ( + + + + + + + + + + + {`${paymentAmount}`} + + + + + {`${payment.date_paid + ? moment.utc(payment.date_paid, 'x').format('MM/DD/YYYY') + : '' + }`} + {`${ + !payment.date_paid && payment.date_incurred + ? 'Warning: This payment has not been paid' + : '' - }`} - - - - - - + }`} + + + + + + - - - - - - - - - - {selectedProject ? selectedProject.name : 'No selected'} - - - - - {`${githubProjectHandle}`} - - - - {openProjectsList - ? - : - } - - - - - {listProjects({ - projects, - selectedProject: selectedProject - })} - - - - - - - - - {selectedContributor ? selectedContributor.name : 'No selected'} - - - - - {`${githubContributorHandle}`} - - - - {openContributorsList - ? - : - } - - - - - {listContributors(contributors)} - - - + + + + + + + + + + {selectedProject ? selectedProject.name : 'No selected'} + + + + + {`${githubProjectHandle}`} + + + + {openProjectsList + ? + : + } + + + + + {listProjects({ + projects, + selectedProject: selectedProject + })} + + + + + + + + + {selectedContributor ? selectedContributor.name : 'No selected'} + + + + + {`${githubContributorHandle}`} + + + + {openContributorsList + ? + : + } + + + + + {listContributors(contributors)} + + + - + + ) : ( + + + 'test' + + + ) + } )