Skip to content

Commit

Permalink
feat(earnings main filter): displaay organisations in filter
Browse files Browse the repository at this point in the history
  • Loading branch information
Mloweedgar committed Jan 18, 2022
1 parent 3904860 commit bcae8ab
Showing 1 changed file with 58 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import React, { useState } from 'react';
import React, { useEffect, useState } from 'react';
import PropTypes from 'prop-types';
import Grid from '@material-ui/core/Grid';
import Drawer from '@material-ui/core/Drawer';
import TextField from '@material-ui/core/TextField';
import Select from '@material-ui/core/Select';
import InputLabel from '@material-ui/core/InputLabel';
import MenuItem from '@material-ui/core/MenuItem';
import api from '../../../api/treeTrackerApi';

import Button from '@material-ui/core/Button';
import Typography from '@material-ui/core/Typography';
Expand All @@ -30,6 +31,7 @@ const PAYMENT_STATUS = ['calculated', 'cancelled', 'paid', 'all'];
*/
function EarningsTableMainFilter(props) {
const [mainFilter, setMainFilter] = useState({});
const [organisations, setOrganisations] = useState([]);
const { isMainFilterOpen, setIsMainFilterOpen, filter, setFilter } = props;

const classes = useStyles();
Expand Down Expand Up @@ -67,6 +69,12 @@ function EarningsTableMainFilter(props) {
setIsMainFilterOpen(false);
};

useEffect(() => {
api.getOrganizations().then((res) => {
setOrganisations(res);
});
}, [mainFilter]);

return (
<Drawer
anchor="right"
Expand Down Expand Up @@ -100,11 +108,9 @@ function EarningsTableMainFilter(props) {
variant="outlined"
className={classes.earningsFilterSelectFormControl}
>
<InputLabel id="demo-simple-select-outlined-label">
Payment Status
</InputLabel>
<InputLabel id="earnings_status">Payment Status</InputLabel>
<Select
labelId="demo-simple-select-outlined-label"
labelId="earnings_status"
id="earnings_status"
name="earnings_status"
label="Payment Status"
Expand All @@ -120,6 +126,53 @@ function EarningsTableMainFilter(props) {
</Select>
</FormControl>

<FormControl
variant="outlined"
className={classes.earningsFilterSelectFormControl}
>
<InputLabel id="organisation_id">Organisation</InputLabel>
<Select
labelId="organisation_id"
id="organisation_id"
name="organisation_id"
label="Organisation"
onChange={handleOnFormControlChange}
>
{organisations.map((organisation, i) => (
<MenuItem
key={`${organisation.id}_${i}`}
value={organisation.id}
>
<span style={{ textTransform: 'capitalize' }}>
{organisation.name}
</span>
</MenuItem>
))}
</Select>
</FormControl>

<FormControl
variant="outlined"
className={classes.earningsFilterSelectFormControl}
>
<InputLabel id="contract_type_id">Contract Type</InputLabel>
<Select
labelId="contract_type_id"
id="contract_type_id"
name="contract_type_id"
label="Contract Type"
onChange={handleOnFormControlChange}
>
{PAYMENT_STATUS.map((paymentStatus, i) => (
<MenuItem key={`${paymentStatus}_${i}`} value={paymentStatus}>
<span style={{ textTransform: 'capitalize' }}>
{paymentStatus}
</span>
</MenuItem>
))}
</Select>
</FormControl>

<FormControl
variant="outlined"
className={classes.earningsFilterSelectFormControl}
Expand Down

0 comments on commit bcae8ab

Please sign in to comment.