Skip to content

Commit

Permalink
feat(client): add AccountSwitcher and update chart data handling
Browse files Browse the repository at this point in the history
  • Loading branch information
xDeFc0nx committed Jan 27, 2025
1 parent c9bf010 commit 1b2663c
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion client/src/components/transaction/addTransaction.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import {
SelectTrigger,
SelectValue,
} from '@/components/ui/select';
import { AccountSwitcher } from '../sidebar/account-switcher';

const formSchema = z.object({
Type: z.enum(['Income', 'Expense']),
Expand All @@ -42,7 +43,7 @@ const formSchema = z.object({

export const AddTransaction = () => {
const { socket, isReady } = useWebSocket();
const { setTransactions, activeAccount, setAccounts, setActiveAccount } =
const { setTransactions, activeAccount, setAccounts, setActiveAccount, setChartOverview, dateRange } =
useUserData();

const form = useForm<z.infer<typeof formSchema>>({
Expand Down Expand Up @@ -110,13 +111,19 @@ export const AddTransaction = () => {
: prev,
);
}
if(response.chartData){
setChartOverview(response.chartData)
}

};


socket.onMessage(balanceHandler);
setTimeout(() => {
socket.send('getAccountIncome', { AccountID: currentAccountId });
socket.send('getAccountExpense', { AccountID: currentAccountId });
socket.send('getAccountBalance', { AccountID: currentAccountId });
socket.send('getCharts', {AccountID: currentAccountId, DataRange: dateRange})
}, 100);
return;
}
Expand Down

0 comments on commit 1b2663c

Please sign in to comment.