Skip to content

Commit

Permalink
returning to previous wallet type
Browse files Browse the repository at this point in the history
  • Loading branch information
tsukanova.p committed Nov 22, 2024
1 parent 0e8f089 commit ac9c13b
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 33 deletions.
33 changes: 17 additions & 16 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import { addWallet, setWallets } from './redux/walletsSlice';
import { bindCardPopupData, inviteFriendPopupData } from './mockData';
import { ReceivePg } from './one-way-pages/receive-page/ReceivePage';
import { Menu } from './components/menu/Menu';
import { Wallet } from './types';

function App() {
const dispatch = useDispatch<AppDispatch>();
Expand Down Expand Up @@ -57,11 +58,11 @@ function App() {
.catch(() => {
dispatch(setSignInError(true));
});
// .finally(() => {
// // заглушка пока бэк не работает
// dispatch(setSignInError(false));
// moveTo('/auth');
// });
// .finally(() => {
// // заглушка пока бэк не работает
// dispatch(setSignInError(false));
// moveTo('/auth');
// });
}

function handleAuthCodeSubmit(code: string) {
Expand All @@ -80,15 +81,15 @@ function App() {
setAuthError(true);
dispatch(logout());
});
// .finally(() => {
// setAuthError(false);
// dispatch(setTokens({ accessToken: '', refreshToken: '' }));
// if (passwordConfirmed) {
// moveTo('/psw-enter');
// } else {
// moveTo('/psw-create');
// }
// });
// .finally(() => {
// setAuthError(false);
// dispatch(setTokens({ accessToken: '', refreshToken: '' }));
// if (passwordConfirmed) {
// moveTo('/psw-enter');
// } else {
// moveTo('/psw-create');
// }
// });
}

// props to waypoint
Expand Down Expand Up @@ -152,7 +153,7 @@ function App() {
if (!portfolios) {
return true;
}
dispatch(setWallets(portfolios));
dispatch(setWallets(portfolios as Wallet[]));
return false;
})
.then((emptywallets: boolean) => {
Expand All @@ -165,7 +166,7 @@ function App() {
}
})
.catch((err) => {
console.log(err);
console.log(err.json());
});
}

Expand Down
2 changes: 1 addition & 1 deletion src/api/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class Request {
);
}

getWallets(portfolioId?: number): Promise<{ portfolios: { title: string; portfolioId: number; wallets: any[] }[] }> {
getWallets(portfolioId?: number): Promise<{ portfolios: Wallet[] }> {
const portflioUrlSuffix = portfolioId ? `?portfolioId=${portfolioId}` : '';

return fetch(`${this._baseUrl}/portfolio${portflioUrlSuffix}`, {
Expand Down
10 changes: 6 additions & 4 deletions src/redux/walletsSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const walletsSlice = createSlice({
initialState: initialState,
reducers: {
setWallets: (state, action: PayloadAction<Wallet[]>) => {
state.wallets = { ...action.payload };
state.wallets = action.payload;
},
addWallet: (state, action: PayloadAction<Wallet>) => {
state.wallets.push(action.payload);
Expand All @@ -32,6 +32,8 @@ const walletsSlice = createSlice({
state.choosenWallet = action.payload;
},
toggleChooseWallet(state, action: PayloadAction<boolean>) {
console.log(action.payload);

state.chooseWalletOpened = action.payload;
},
transaction(state, action: PayloadAction<{ card: Card; ammount: number }>) {
Expand All @@ -44,14 +46,14 @@ const walletsSlice = createSlice({
},
currencyBuy(state, action: PayloadAction<{ currencyAmmount: number; curIndex: number; wallet: Wallet }>) {
state.wallets.forEach((wallet) => {
if (wallet.portfolioId === action.payload.wallet.portfolioId) {
if (wallet.id === action.payload.wallet.id) {
switch (action.payload.curIndex) {
case 0: {
wallet.wallets[0].ammount -= action.payload.currencyAmmount;
wallet.currensies[0].ammount -= action.payload.currencyAmmount;
break;
}
case 1: {
wallet.wallets[1].ammount -= action.payload.currencyAmmount;
wallet.currensies[1].ammount -= action.payload.currencyAmmount;
break;
}
default: {
Expand Down
28 changes: 17 additions & 11 deletions src/types.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,23 @@
export type SubWallet = {
walletId: number;
address: string;
tokenId: number;
balance: string; //нужно парсить - parseFloat(a.balance.shift())
};

export type Wallet = {
title: string;
portfolioId: number;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
wallets: any[];
id: string;
name: string;
currensies: CurrenciesItem[];
};

// export type SubWallet = {
// walletId: number;
// address: string;
// tokenId: number;
// balance: string; //нужно парсить - parseFloat(a.balance.shift())
// };

// export type Wallet = {
// title: string;
// portfolioId: number;
// // eslint-disable-next-line @typescript-eslint/no-explicit-any
// wallets: any[];
// };

export type Portfolio = {
title: string;
portfolioId: number;
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.app.tsbuildinfo
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"root":["./src/app.tsx","./src/main.tsx","./src/mockdata.ts","./src/types.ts","./src/vite-env.d.ts","./src/api/api.ts","./src/api/auth.ts","./src/components/header/header.tsx","./src/components/icons/transactionapprovedicon copy.tsx","./src/components/icons/transactiondenyicon.tsx","./src/components/icons/backarrowicon.tsx","./src/components/icons/cancel.tsx","./src/components/icons/cryptocurency.tsx","./src/components/layout/layoutcomponent.tsx","./src/components/nav-bar-menu/navbarmenu.tsx","./src/components/nav-bar-menu/navbarmenuitem.tsx","./src/components/pop-up/popup.tsx","./src/components/protected-route/protected-route.ts","./src/components/wallet-view/walletview.tsx","./src/func-pages/buy-page/buycryptopage.tsx","./src/func-pages/exchange-page/exchange.tsx","./src/func-pages/exchange-page/choose-wallet/choosewallet.tsx","./src/func-pages/history-page/history.tsx","./src/func-pages/history-page/history-element/historyelement.tsx","./src/func-pages/main-page/mainpage.tsx","./src/one-way-pages/auth-page/authpage.tsx","./src/one-way-pages/bind-card-page/bindcardpage.tsx","./src/one-way-pages/create-psw-page/createpswpage.tsx","./src/one-way-pages/create-psw-page/pwdentrypage.tsx","./src/one-way-pages/hero-page/heropg.tsx","./src/one-way-pages/log-in-page/loginpage.tsx","./src/one-way-pages/receive-page/qrcodegenerator.tsx","./src/one-way-pages/receive-page/receivepage.tsx","./src/one-way-pages/share-app/shareapppage.tsx","./src/one-way-pages/sign-up-page/signuppage.tsx","./src/one-way-pages/tansaction-approvedorrejected-page/transactionpage.tsx","./src/one-way-pages/tansaction-approvedorrejected-page/currencyicons/btcicon.tsx","./src/one-way-pages/tansaction-approvedorrejected-page/currencyicons/etcicon.tsx","./src/one-way-pages/tansaction-approvedorrejected-page/currencyicons/rubleicon.tsx","./src/redux/authslice.ts","./src/redux/popupslice.ts","./src/redux/store.ts","./src/redux/walletsslice.ts"],"version":"5.6.3"}
{"root":["./src/app.tsx","./src/main.tsx","./src/mockdata.ts","./src/types.ts","./src/vite-env.d.ts","./src/api/api.ts","./src/api/auth.ts","./src/components/header/header.tsx","./src/components/icons/transactionapprovedicon copy.tsx","./src/components/icons/transactiondenyicon.tsx","./src/components/icons/backarrowicon.tsx","./src/components/icons/cancel.tsx","./src/components/icons/cryptocurency.tsx","./src/components/layout/layoutcomponent.tsx","./src/components/menu/menu.tsx","./src/components/nav-bar-menu/navbarmenu.tsx","./src/components/nav-bar-menu/navbarmenuitem.tsx","./src/components/pop-up/popup.tsx","./src/components/protected-route/protected-route.ts","./src/components/wallet-view/walletview.tsx","./src/func-pages/buy-page/buycryptopage.tsx","./src/func-pages/exchange-page/exchange.tsx","./src/func-pages/exchange-page/choose-wallet/choosewallet.tsx","./src/func-pages/history-page/history.tsx","./src/func-pages/history-page/history-element/historyelement.tsx","./src/func-pages/main-page/mainpage.tsx","./src/one-way-pages/auth-page/authpage.tsx","./src/one-way-pages/bind-card-page/bindcardpage.tsx","./src/one-way-pages/create-psw-page/createpswpage.tsx","./src/one-way-pages/create-psw-page/pwdentrypage.tsx","./src/one-way-pages/hero-page/heropg.tsx","./src/one-way-pages/log-in-page/loginpage.tsx","./src/one-way-pages/receive-page/qrcodegenerator.tsx","./src/one-way-pages/receive-page/receivepage.tsx","./src/one-way-pages/share-app/shareapppage.tsx","./src/one-way-pages/sign-up-page/signuppage.tsx","./src/one-way-pages/tansaction-approvedorrejected-page/transactionpage.tsx","./src/one-way-pages/tansaction-approvedorrejected-page/currencyicons/btcicon.tsx","./src/one-way-pages/tansaction-approvedorrejected-page/currencyicons/etcicon.tsx","./src/one-way-pages/tansaction-approvedorrejected-page/currencyicons/rubleicon.tsx","./src/redux/authslice.ts","./src/redux/popupslice.ts","./src/redux/store.ts","./src/redux/walletsslice.ts"],"version":"5.6.3"}

0 comments on commit ac9c13b

Please sign in to comment.