forked from asyncapi/website
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed remaining lint issues and added coderabbit suggestions
- Loading branch information
1 parent
810b6a8
commit 78af209
Showing
3 changed files
with
33 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,35 @@ | ||
export const loadYearData = (year: string) => { | ||
import type { ExpenseItem, ExpensesLinkItem } from '@/types/FinancialSummary/BarChartComponent'; | ||
import expenses2023 from '../config/finance/2023/Expenses.json'; | ||
import expensesLink2023 from '../config/finance/2023/ExpensesLink.json'; | ||
import expenses2024 from '../config/finance/2024/Expenses.json'; | ||
import expensesLink2024 from '../config/finance/2024/ExpensesLink.json'; | ||
|
||
interface YearData { | ||
expenses: { [key: string]: ExpenseItem[] }; | ||
links: ExpensesLinkItem[]; | ||
} | ||
|
||
const YEAR_DATA_MAP: { [key: string]: YearData } = { | ||
'2023': { | ||
expenses: expenses2023, | ||
links: expensesLink2023 | ||
}, | ||
'2024': { | ||
expenses: expenses2024, | ||
links: expensesLink2024 | ||
} | ||
}; | ||
|
||
export const loadYearData = (year: string): { expensesData: { [key: string]: ExpenseItem[] }, expensesLinkData: ExpensesLinkItem[] } => { | ||
try { | ||
const expensesData = require(`../config/finance/${year}/Expenses.json`); | ||
const expensesLinkData = require(`../config/finance/${year}/ExpensesLink.json`); | ||
const yearData = YEAR_DATA_MAP[year]; | ||
if (!yearData) { | ||
throw new Error(`No data available for year ${year}`); | ||
} | ||
const { expenses: expensesData, links: expensesLinkData } = yearData; | ||
return { expensesData, expensesLinkData }; | ||
} catch (error) { | ||
console.error(`Failed to load data for year ${year}:`, error); | ||
return { expensesData: {}, expensesLinkData: [] }; | ||
} | ||
}; | ||
}; |