Skip to content

Commit

Permalink
refactor: Rename analytics into insights
Browse files Browse the repository at this point in the history
  • Loading branch information
tklein1801 committed Apr 10, 2024
1 parent c4aefb0 commit 2f47bb8
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 19 deletions.
4 changes: 2 additions & 2 deletions src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import {BrowserRouter, Navigate, Route, Routes} from 'react-router-dom';
import {FullPageLoader} from '@/components/Loading';
import {DashboardLayout, DashboardView, BudgetView, StocksView, AnalyticsView} from './routes/Dashboard';
import {DashboardLayout, DashboardView, BudgetView, StocksView, InsightsView} from './routes/Dashboard';
import StockRoute from './routes/Stock.route';
import StocksRoute from './routes/Stocks.route';
import TransactionsRoute from './routes/Transactions.route';
Expand All @@ -26,7 +26,7 @@ const App = () => {
<Route index element={<DashboardView />} />
<Route path="budget" element={<BudgetView />} />
<Route path="stocks" element={<StocksView />} />
<Route path="analytics" element={<AnalyticsView navigateOnClose navigateTo="/dashboard" />} />
<Route path="insights" element={<InsightsView navigateOnClose navigateTo="/dashboard" />} />
<Route path="*" element={<Navigate to="/dashboard" />} />
</Route>
<Route path="/stocks">
Expand Down
11 changes: 3 additions & 8 deletions src/routes/Dashboard/DashboardLayout.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,7 @@ import {Outlet, useLocation, useNavigate} from 'react-router-dom';
import {withAuthLayout} from '@/components/Auth/Layout';
import {useAuthContext} from '@/components/Auth';
import {ContentGrid} from '@/components/Layout';
import {
type TDashboardView,
DashboardViewMapping,
DashboardViewDescriptionMapping,
DashboardViewIconMapping,
} from './index';
import {type TDashboardView, DashboardViewMapping, DashboardViewDescriptionMapping} from './index';
import {ActionPaper} from '@/components/Base';

export type TDashboardLayoutProps = React.PropsWithChildren<{
Expand Down Expand Up @@ -40,13 +35,13 @@ const DashboardLayout: React.FC<TDashboardLayoutProps> = ({children, useOutletIn
exclusive>
{Object.entries(DashboardViewMapping).map(([path, view]: [string, TDashboardView]) => (
<ToggleButton key={path} value={path}>
{React.isValidElement(DashboardViewIconMapping[view]) &&
{/* {React.isValidElement(DashboardViewIconMapping[view]) &&
// @ts-expect-error
React.cloneElement(DashboardViewIconMapping[view], {
sx: {
mr: 0.5,
},
})}
})} */}
{view.substring(0, 1).toUpperCase() + view.substring(1)}
</ToggleButton>
))}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ import {useFetchTransactions} from '@/components/Transaction';
import {useKeyPress} from '@/hooks/useKeyPress.hook.ts';
import {DownloadButton} from '@/components/Download';

export type TAnalyticsViewProps =
export type TInsightsViewProps =
| {navigateOnClose: true; navigateTo: string}
| ({navigateOnClose: false} & Pick<TFullScreenDialogProps, 'onClose'>);

export const AnalyticsView: React.FC<TAnalyticsViewProps> = props => {
export const InsightsView: React.FC<TInsightsViewProps> = props => {
const theme = useTheme();
const navigate = useNavigate();
const autocompleteRef = React.useRef<HTMLInputElement | null>(null);
Expand Down Expand Up @@ -126,7 +126,7 @@ export const AnalyticsView: React.FC<TAnalyticsViewProps> = props => {

return (
<FullScreenDialog
title={'Analytics'}
title={'Insights'}
open={true}
onClose={handleClose}
boxProps={{sx: {display: 'flex', flexDirection: 'column', flex: 1}}}>
Expand Down Expand Up @@ -265,4 +265,4 @@ export const AnalyticsView: React.FC<TAnalyticsViewProps> = props => {
);
};

export default AnalyticsView;
export default InsightsView;
4 changes: 2 additions & 2 deletions src/routes/Dashboard/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
export type TDashboardView = 'overview' | 'budget' | 'stocks' | 'analytics';
export type TDashboardView = 'overview' | 'budget' | 'stocks' | 'insights';

export * from './mappings';
export {default as DashboardLayout} from './DashboardLayout.component';
export {default as DashboardView} from './Dashboard.view';
export {default as BudgetView} from './Budget.view';
export {default as StocksView} from './Stocks.view';
export {default as AnalyticsView} from './Analytics.view';
export {default as InsightsView} from './Insights.view';
6 changes: 3 additions & 3 deletions src/routes/Dashboard/mappings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@ export const DashboardViewMapping: Record<string, TDashboardView> = {
['/dashboard']: 'overview',
['/dashboard/budget']: 'budget',
['/dashboard/stocks']: 'stocks',
['/dashboard/analytics']: 'analytics',
['/dashboard/insights']: 'insights',
};

export const DashboardViewDescriptionMapping: Record<TDashboardView, string | undefined> = {
['overview']: 'Overview',
['budget']: 'Budget',
['stocks']: 'Stocks',
['analytics']: 'Analytics',
['insights']: 'Insights',
};

export const DashboardViewIconMapping: Record<TDashboardView, React.ReactNode | undefined> = {
['overview']: <DashboardRounded />,
['budget']: <DonutSmallRounded />,
['stocks']: <TrendingUpRounded />,
['analytics']: <TrendingUpRounded />,
['insights']: <TrendingUpRounded />,
};

0 comments on commit 2f47bb8

Please sign in to comment.