|
1 | | -import React, { createContext, useContext, useEffect, useState } from 'react' |
2 | | -import { InputLabel, MenuItem, Select } from '@mui/material' |
| 1 | +import { createContext, useEffect, useState } from 'react' |
3 | 2 | import FormControl from '@mui/material/FormControl' |
| 3 | +import InputLabel from '@mui/material/InputLabel' |
4 | 4 | import Typography from '@mui/material/Typography' |
| 5 | +import MenuItem from '@mui/material/MenuItem' |
| 6 | +import Select from '@mui/material/Select' |
5 | 7 |
|
| 8 | +import { YearData, AverageStoredData } from 'constants/modules/average/types' |
6 | 9 | import AverageData from 'constants/modules/average/AverageData' |
7 | | -import { YearData } from 'constants/modules/average/types' |
8 | | -import Year from './Year' |
9 | | - |
10 | | -const importData = (): { averageData: YearData[]; currentYear: number; currentSector?: number } => { |
11 | | - let data: any = localStorage.getItem('average_data') |
12 | | - if (data === null) { |
13 | | - data = { |
14 | | - averageData: AverageData, |
15 | | - currentYear: 0, |
16 | | - currentSector: undefined, |
17 | | - } |
18 | | - } else { |
19 | | - data = JSON.parse(data) |
| 10 | +import Year from 'app/components/hub/average/Year' |
| 11 | + |
| 12 | +const importData = (): AverageStoredData => { |
| 13 | + const storedData: string | null = localStorage.getItem('average_data') |
| 14 | + |
| 15 | + if (storedData !== null) { |
| 16 | + return JSON.parse(storedData) |
20 | 17 | } |
21 | 18 |
|
22 | | - return data |
| 19 | + return { |
| 20 | + averageData: AverageData, |
| 21 | + currentYear: 0, |
| 22 | + currentSector: undefined, |
| 23 | + } |
23 | 24 | } |
24 | 25 |
|
25 | 26 | const saveData = (averageData: YearData[], currentYear: number, currentSector?: number) => { |
|
0 commit comments