Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ahmed/dapi 721/fix UI break account type filter token table #143

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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