Skip to content

Commit

Permalink
Merge pull request #143 from ahmed-deriv/ahmed/DAPI-721/fix--UI-break…
Browse files Browse the repository at this point in the history
…-account-type-filter-token-table

Ahmed/dapi 721/fix  UI break account type filter token table
  • Loading branch information
sandeep-deriv authored Oct 8, 2024
2 parents 198be64 + 66be4a4 commit 06fdd98
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 18 deletions.
2 changes: 1 addition & 1 deletion src/components/AccountSwitcher/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import CurrencyIcon from '../CurrencyIcon';
import styles from './account_switcher.module.scss';

interface AccountSwitcherProps {
onChange: (accountName: string) => void;
onChange: (accountName?: string) => void;
}

const AccountSwitcher = ({ onChange }: AccountSwitcherProps) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { HTMLAttributes, useState } from 'react';
import React, { useEffect, useState } from 'react';
import { Column } from 'react-table';
import { Button, Heading, Text } from '@deriv-com/quill-ui';
import { LabelPairedCirclePlusMdRegularIcon } from '@deriv/quill-icons';
Expand Down Expand Up @@ -61,19 +61,20 @@ const tableColumns: TTokenColumn[] = [
},
];

const ApiTokenTable = (props: HTMLAttributes<HTMLDivElement>) => {
const ApiTokenTable = () => {
const { tokens, isLoadingTokens } = useApiToken();
const [isAccountChange, setAccountChange] = useState(false);
const { deviceType } = useDeviceType();
const is_desktop = deviceType === 'desktop';
const { updateCurrentTab } = useAppManager();
const [loading, setLoading] = useState(false);

const handleChange = (accountName: string) => {
setLoading(true);
setTimeout(() => {
setLoading(false);
}, 2000);
};
const onChange = () => {
setAccountChange(true);
}

useEffect(() => {
setAccountChange(false);
}, [tokens]);

const renderTable = () => {
return is_desktop ? (
Expand Down Expand Up @@ -114,17 +115,12 @@ const ApiTokenTable = (props: HTMLAttributes<HTMLDivElement>) => {
</Button>
</div>
<div className={styles.account_switcher}>
<AccountSwitcher onChange={handleChange} />
<AccountSwitcher onChange={onChange}/>
</div>
</div>

{loading ? (
<Spinner />
) : isLoadingTokens ? (
<Spinner />
) : tokens?.length ? (
renderTable()
) : null}
{isAccountChange || isLoadingTokens ? ( <Spinner /> )
: tokens.length > 0 && ( renderTable() )}
</div>
);
};
Expand Down

0 comments on commit 06fdd98

Please sign in to comment.