From 6c64d3bad0e2c1049cdf4a5c05e2f65c7667f42e Mon Sep 17 00:00:00 2001 From: Akash Shaw Date: Wed, 27 Mar 2024 22:15:49 +0530 Subject: [PATCH 1/2] chore: added default account number atom and gave the accounts atom type --- packages/recoil/src/atoms/account.tsx | 9 ++++++++- yarn.lock | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/packages/recoil/src/atoms/account.tsx b/packages/recoil/src/atoms/account.tsx index b8578ea9..ee0e4f37 100644 --- a/packages/recoil/src/atoms/account.tsx +++ b/packages/recoil/src/atoms/account.tsx @@ -1,3 +1,4 @@ +import { AccountType } from "@paybox/common"; import { atom } from "recoil"; export const accountAtom = atom({ @@ -5,7 +6,13 @@ export const accountAtom = atom({ key: "accountAtom", }); -export const accountsAtom = atom({ +export const accountsAtom = atom({ default: [], key: "accountsAtom", }); + +//TODO: set this to the default account number by +export const defaultAccountNumberAtom = atom({ + default: 1, + key: "defaultAccountNumberAtom", +}); \ No newline at end of file diff --git a/yarn.lock b/yarn.lock index 79d3bb43..e58d70ae 100644 --- a/yarn.lock +++ b/yarn.lock @@ -16900,7 +16900,7 @@ real-require@^0.1.0: recoil@^0.7.7: version "0.7.7" - resolved "https://registry.npmjs.org/recoil/-/recoil-0.7.7.tgz" + resolved "https://registry.yarnpkg.com/recoil/-/recoil-0.7.7.tgz#c5f2c843224384c9c09e4a62c060fb4c1454dc8e" integrity sha512-8Og5KPQW9LwC577Vc7Ug2P0vQshkv1y3zG3tSSkWMqkWSwHmE+by06L8JtnGocjW6gcCvfwB3YtrJG6/tWivNQ== dependencies: hamt_plus "1.0.2" From 69c75c1c8e0b387d9d492878ff404b2179ca1691 Mon Sep 17 00:00:00 2001 From: Akash Shaw Date: Wed, 27 Mar 2024 22:16:57 +0530 Subject: [PATCH 2/2] chore: adding the new account to account atom --- .../account/components/account-switcher.tsx | 8 +++--- .../app/account/components/accountLayout.tsx | 6 ++++- .../create/components/account-create-form.tsx | 25 ++++++++++++++++--- apps/web/app/account/create/page.tsx | 8 +++--- apps/web/package.json | 20 +++------------ 5 files changed, 37 insertions(+), 30 deletions(-) diff --git a/apps/web/app/account/components/account-switcher.tsx b/apps/web/app/account/components/account-switcher.tsx index e2b90ae2..2daea8c3 100644 --- a/apps/web/app/account/components/account-switcher.tsx +++ b/apps/web/app/account/components/account-switcher.tsx @@ -11,24 +11,22 @@ import { SelectValue, } from "@/components/ui/select" import { Wallet } from 'lucide-react'; +import { accountsAtom } from "@paybox/recoil"; +import { useRecoilValue } from "recoil"; interface AccountSwitcherProps { isCollapsed: boolean - accounts: { - id: string, - name: string, - }[], selectedAccount: string, setSelectedAccount: (accountId: string) => void } export function AccountSwitcher({ isCollapsed, - accounts, selectedAccount, setSelectedAccount }: AccountSwitcherProps) { + const accounts = useRecoilValue(accountsAtom); return (