From af705a303419f79ab940b7424685676f17e9f45a Mon Sep 17 00:00:00 2001 From: Starfall Production Date: Sat, 19 Jun 2021 17:25:35 +0700 Subject: [PATCH] Fix minor issues --- package.json | 4 +++- src/components/OverallChart.tsx | 14 +++++--------- src/states/MoneyState.ts | 6 +++++- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/package.json b/package.json index bd95449..b023be7 100644 --- a/package.json +++ b/package.json @@ -30,7 +30,9 @@ { "name": "@electron-forge/maker-zip", "platforms": [ - "darwin" + "darwin", + "mac", + "linux" ] }, { diff --git a/src/components/OverallChart.tsx b/src/components/OverallChart.tsx index 22e5ebd..a2dd2ae 100644 --- a/src/components/OverallChart.tsx +++ b/src/components/OverallChart.tsx @@ -10,7 +10,7 @@ import { VictoryGroup, VictoryZoomContainer, VictoryBrushContainer, - VictoryAxis + VictoryAxis, } from 'victory'; import { Money } from '../models/Money'; @@ -25,14 +25,10 @@ type OverallChartProps = { value: Money[] } -interface Domain { - -} - function OverallChart({ value }: OverallChartProps) { const styles = useStyles(); - const [selectedDomain, setSelectedDomain] = useState([]); - const [zoomDomain, setZoomDomain] = useState([]); + const [selectedDomain, setSelectedDomain] = useState(); + const [zoomDomain, setZoomDomain] = useState(); const handleZoom = (domain: any) => { setSelectedDomain(domain); @@ -55,8 +51,8 @@ function OverallChart({ value }: OverallChartProps) { }); let tick: Date[] = []; - let minYear = data[0].x.getFullYear(); - const maxYear = data[data.length-1].x.getFullYear(); + let minYear = data.length > 0 ? data[0].x.getFullYear() : 0; + const maxYear = data.length > 0 ? data[data.length-1].x.getFullYear() : 0; while(minYear <= maxYear) { tick.push(new Date(minYear, 1, 1)); minYear += 1; diff --git a/src/states/MoneyState.ts b/src/states/MoneyState.ts index 5209f35..c583736 100644 --- a/src/states/MoneyState.ts +++ b/src/states/MoneyState.ts @@ -141,7 +141,11 @@ const income = selector({ key: 'incomeSelector', get: ({get}) => { const value = get(moneyOverall); - return value[value.length-1].type === "increase" ? value[value.length-1].value : 0 ; + + if(value.length > 0) + return value[value.length-1].type === "increase" ? value[value.length-1].value : 0 ; + else + return 0; } })