Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 41 additions & 1 deletion src/components/AllocationAddForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand Down Expand Up @@ -427,7 +436,37 @@ const AllocationAddForm = (props) => {
>
<Box m={5}>
<DialogTitle>
{`Add Allocation`}
{project &&
`Add Allocation`
}
{client && !selectedProject &&
<ButtonGroup color='primary' aria-label='outlined primary button group'>
<Button
variant={`${allocationSelection[0] ? 'contained' : 'outlined'}`}
color='primary'
onClick={() => (
addAllocationOrLinkPayment({
selection: 0,
allocationSelection
})
)}
>
{'Create New Allocation'}
</Button>
<Button
variant={`${allocationSelection[1] ? 'contained' : 'outlined'}`}
color='primary'
onClick={() => (
addAllocationOrLinkPayment({
selection: 1,
allocationSelection
})
)}
>
{'Link Existing Payment'}
</Button>
</ButtonGroup>
}
</DialogTitle>
<Grid container spacing={5} justifyContent='center'>
<Grid item xs={12}>
Expand Down Expand Up @@ -457,6 +496,7 @@ const AllocationAddForm = (props) => {
setNewAllocation={setNewAllocation}
setContributor={setSelectedContributor}
setProject={setSelectedProject}
allocationSelection={allocationSelection}
/>
) : (
<AllocationProposeSpecifics
Expand Down
193 changes: 102 additions & 91 deletions src/components/AllocationClientSpecifics.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ const AllocationClientSpecifics = (props) => {
project,
setContributor,
setProject,
setNewAllocation
setNewAllocation,
allocationSelection
} = props

const {
Expand Down Expand Up @@ -174,99 +175,109 @@ const AllocationClientSpecifics = (props) => {

return (
<Box className='AllocationClientSpecifics'>
<Grid container justifyContent='center'>
<Grid item xs={12}>
<List component='nav'>
<ListItem>
<Grid container>
<Grid item xs={2} md={3}>
<PaymentIcon color='primary'/>
</Grid>
<Grid item xs={10} md={3}>
<Typography>
{`${paymentAmount}`}
</Typography>
</Grid>
<Grid item xs={12} md={6} align='center'>
<Typography variant='caption' color='secondary'>
{`${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]
? (
<Grid container justifyContent='center'>
<Grid item xs={12}>
<List component='nav'>
<ListItem>
<Grid container>
<Grid item xs={2} md={3}>
<PaymentIcon color='primary'/>
</Grid>
<Grid item xs={10} md={3}>
<Typography>
{`${paymentAmount}`}
</Typography>
</Grid>
<Grid item xs={12} md={6} align='center'>
<Typography variant='caption' color='secondary'>
{`${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'
: ''

}`}
</Typography>
</Grid>
</Grid>
</ListItem>
</List>
</Grid>
}`}
</Typography>
</Grid>
</Grid>
</ListItem>
</List>
</Grid>

<Grid item xs={12}>
<List component='nav'>
<ListItem button onClick={handleClickProjectsList}>
<Grid container>
<Grid item xs={2} md={3}>
<AssessmentIcon color='primary'/>
</Grid>
<Grid item xs={4} md={3}>
<Typography>
{selectedProject ? selectedProject.name : 'No selected'}
</Typography>
</Grid>
<Grid item xs={4} md={3} className='responsive-align'>
<Typography variant='caption' color='secondary'>
{`${githubProjectHandle}`}
</Typography>
</Grid>
<Grid item xs={2} md={3} align='right'>
{openProjectsList
? <ExpandLess />
: <ExpandMore />
}
</Grid>
</Grid>
</ListItem>
<Collapse in={openProjectsList} timeout='auto' unmountOnExit>
{listProjects({
projects,
selectedProject: selectedProject
})}
</Collapse>
<ListItem button onClick={handleClickContributorsList}>
<Grid container>
<Grid item xs={2} md={3}>
<PeopleIcon color='primary'/>
</Grid>
<Grid item xs={4} md={3}>
<Typography>
{selectedContributor ? selectedContributor.name : 'No selected'}
</Typography>
</Grid>
<Grid item xs={4} md={3} className='responsive-align'>
<Typography variant='caption' color='secondary'>
{`${githubContributorHandle}`}
</Typography>
</Grid>
<Grid item xs={2} md={3} align='right'>
{openContributorsList
? <ExpandLess />
: <ExpandMore />
}
</Grid>
</Grid>
</ListItem>
<Collapse in={openContributorsList} timeout='auto' unmountOnExit>
{listContributors(contributors)}
</Collapse>
</List>
</Grid>
<Grid item xs={12}>
<List component='nav'>
<ListItem button onClick={handleClickProjectsList}>
<Grid container>
<Grid item xs={2} md={3}>
<AssessmentIcon color='primary'/>
</Grid>
<Grid item xs={4} md={3}>
<Typography>
{selectedProject ? selectedProject.name : 'No selected'}
</Typography>
</Grid>
<Grid item xs={4} md={3} className='responsive-align'>
<Typography variant='caption' color='secondary'>
{`${githubProjectHandle}`}
</Typography>
</Grid>
<Grid item xs={2} md={3} align='right'>
{openProjectsList
? <ExpandLess />
: <ExpandMore />
}
</Grid>
</Grid>
</ListItem>
<Collapse in={openProjectsList} timeout='auto' unmountOnExit>
{listProjects({
projects,
selectedProject: selectedProject
})}
</Collapse>
<ListItem button onClick={handleClickContributorsList}>
<Grid container>
<Grid item xs={2} md={3}>
<PeopleIcon color='primary'/>
</Grid>
<Grid item xs={4} md={3}>
<Typography>
{selectedContributor ? selectedContributor.name : 'No selected'}
</Typography>
</Grid>
<Grid item xs={4} md={3} className='responsive-align'>
<Typography variant='caption' color='secondary'>
{`${githubContributorHandle}`}
</Typography>
</Grid>
<Grid item xs={2} md={3} align='right'>
{openContributorsList
? <ExpandLess />
: <ExpandMore />
}
</Grid>
</Grid>
</ListItem>
<Collapse in={openContributorsList} timeout='auto' unmountOnExit>
{listContributors(contributors)}
</Collapse>
</List>
</Grid>

</Grid>
</Grid>
) : (
<Grid container justifyContent='center'>
<Grid item xs={12}>
'test'
</Grid>
</Grid>
)
}
</Box>
)

Expand Down