Skip to content

Commit

Permalink
remove weekly option from revenue chart
Browse files Browse the repository at this point in the history
  • Loading branch information
mtekmir committed Dec 4, 2021
1 parent 704dc89 commit c7b1713
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 36 deletions.
35 changes: 9 additions & 26 deletions src/pages/dashboard/components/chart/Chart.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
import React from 'react'
import {
ResponsiveContainer,
AreaChart,
Area,
XAxis,
YAxis,
CartesianGrid,
Tooltip,
} from 'recharts'
import { ResponsiveContainer, AreaChart, Area, XAxis, YAxis, CartesianGrid, Tooltip } from 'recharts'
import { Paper, IconButton, Typography, Divider, ListItem } from '@material-ui/core'
import MoreVertIcon from '@material-ui/icons/MoreVert'

Expand All @@ -30,14 +22,11 @@ const Chart: React.FC<ChartProps> = ({ revenueData, fetchRevenueData, appliedFil

const disabledOptions = getDisabledOptions(appliedFilters.startDate, appliedFilters.endDate)

const {
handleClick,
handleClose,
open,
anchorEl,
displayOption,
onDisplayOptionClick,
} = useChartState(fetchRevenueData, disabledOptions, appliedFilters)
const { handleClick, handleClose, open, anchorEl, displayOption, onDisplayOptionClick } = useChartState(
fetchRevenueData,
disabledOptions,
appliedFilters
)

const labelStyle = {
color: '#696969',
Expand All @@ -50,18 +39,12 @@ const Chart: React.FC<ChartProps> = ({ revenueData, fetchRevenueData, appliedFil
<IconButton onClick={handleClick} className={classes.iconButton}>
<MoreVertIcon />
</IconButton>
<CustomPopover
open={open}
classes={{ paper: classes.popoverPaper }}
anchorEl={anchorEl}
onClose={handleClose}>
<CustomPopover open={open} classes={{ paper: classes.popoverPaper }} anchorEl={anchorEl} onClose={handleClose}>
<Paper className={classes.popoverPaper}>
<Typography className={classes.displayOptionsTitle}>
Choose a display type for date
</Typography>
<Typography className={classes.displayOptionsTitle}>Choose a display type for date</Typography>
<Divider />
<div>
{['daily', 'weekly', 'monthly'].map(option => (
{['daily', 'monthly'].map(option => (
<ListItem
className={classes.displayOptionsItem}
disabled={disabledOptions[option]}
Expand Down
16 changes: 6 additions & 10 deletions src/pages/stockTransfers/newTransfer/useNewTransferState.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,27 +10,23 @@ export const useNewTransferState = () => {
const { addNotification } = useContext(NotificationsContext)
const [products, setProducts] = useState<ProductToTransfer[]>([])
const { error, value: outlets } = useGetRequest<Outlet[]>('/outlets')
const [selectedOrigin, setSelectedOrigin] = useState<number>(0)
const [selectedDestination, setSelectedDestination] = useState<number>(0)
const [selectedOrigin, setSelectedOrigin] = useState<string>('0')
const [selectedDestination, setSelectedDestination] = useState<string>('0')

const addProduct = (newP: ProductToTransfer) => {
const existing = products.find(p => p.id === newP.id)

if (existing) {
setProducts(pp =>
pp.map(p =>
p.id === existing.id ? { ...existing, qtyToTransfer: existing.qtyToTransfer + 1 } : p
)
pp.map(p => (p.id === existing.id ? { ...existing, qtyToTransfer: existing.qtyToTransfer + 1 } : p))
)
} else {
setProducts(pp => [...pp, { ...newP, qtyToTransfer: 1 }])
}
}

const changeQtyToTransfer = (id: string) => (change: number) => {
setProducts(
products.map(p => (p.id === id ? { ...p, qtyToTransfer: p.qtyToTransfer + change } : p))
)
setProducts(products.map(p => (p.id === id ? { ...p, qtyToTransfer: p.qtyToTransfer + change } : p)))
}

const searchProducts = async (query: string): Promise<ProductToTransfer[]> => {
Expand Down Expand Up @@ -70,9 +66,9 @@ export const useNewTransferState = () => {
const changeOutlet = ({ target: { value, name } }: React.ChangeEvent<HTMLInputElement>) => {
switch (name) {
case 'origin':
return setSelectedOrigin(parseInt(value))
return setSelectedOrigin(value)
case 'destination':
return setSelectedDestination(parseInt(value))
return setSelectedDestination(value)
}
}

Expand Down

0 comments on commit c7b1713

Please sign in to comment.