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

[TRAH] Aizad/TRAH-2268/DemoRealAccountSwitcher #12635

Merged
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
c205ef2
feat: create real demo switch account on tradershub
aizad-deriv Dec 29, 2023
23a1176
fix: added first_real_accounts and demo_loginid inside useTradingAcco…
aizad-deriv Dec 29, 2023
b8176ab
fix: resolve comments
aizad-deriv Jan 2, 2024
b5afdd1
chore: added open and closing animations when toggle
aizad-deriv Jan 2, 2024
239c656
fix: resolve comments
aizad-deriv Jan 2, 2024
b8e8081
fix: remove invalid classname
aizad-deriv Jan 2, 2024
e29d482
Merge branch 'master' of github.com:aizad-deriv/deriv-app into aizad/…
aizad-deriv Jan 4, 2024
8c0c632
fix: remove headless and replace it with default tailwind
aizad-deriv Jan 4, 2024
6bda486
feat: create real demo switch account on tradershub
aizad-deriv Dec 29, 2023
c03ff5e
fix: added first_real_accounts and demo_loginid inside useTradingAcco…
aizad-deriv Dec 29, 2023
9dc9487
fix: resolve comments
aizad-deriv Jan 2, 2024
263004d
chore: added open and closing animations when toggle
aizad-deriv Jan 2, 2024
3e150cb
fix: resolve comments
aizad-deriv Jan 2, 2024
2455fb6
fix: remove invalid classname
aizad-deriv Jan 2, 2024
8e6548a
fix: remove headless and replace it with default tailwind
aizad-deriv Jan 4, 2024
eb7f98d
fix: update code
aizad-deriv Jan 4, 2024
9eb5442
chore: update code
aizad-deriv Jan 4, 2024
028672a
fix: update code
aizad-deriv Jan 4, 2024
0f04bf6
fix: remove ButtonGroup export inside of ./components
aizad-deriv Jan 4, 2024
8f4374f
fix: resolve build fail issue
aizad-deriv Jan 4, 2024
a9ca615
fix: resolve sonar cloud issue
aizad-deriv Jan 4, 2024
c8c29ed
chore: updated code
aizad-deriv Jan 4, 2024
74564ef
fix: add type to account
aizad-deriv Jan 4, 2024
0b2c402
Delete packages/tradershub/package-lock.json
aizad-deriv Jan 5, 2024
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
6 changes: 5 additions & 1 deletion packages/api/src/hooks/useTradingAccountsList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@ const useTradingAccountsList = () => {

// Add additional information to each trading account.
const modified_accounts = useMemo(() => {
return filtered_accounts?.map(trading => ({ ...trading }));
return filtered_accounts?.map(trading => ({
...trading,
first_real_account: filtered_accounts?.find(account => account.account_type === 'real')?.loginid[0],
aizad-deriv marked this conversation as resolved.
Show resolved Hide resolved
aizad-deriv marked this conversation as resolved.
Show resolved Hide resolved
demo_loginid: filtered_accounts?.find(account => account.account_type === 'demo')?.loginid,
}));
}, [filtered_accounts]);

return {
Expand Down
3 changes: 2 additions & 1 deletion packages/tradershub/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,13 @@
},
"dependencies": {
"@deriv/api": "^1.0.0",
"@deriv/library": "^1.0.0",
"@deriv/integration": "^1.0.0",
"@deriv/library": "^1.0.0",
"@deriv/quill-design": "^1.3.2",
"@deriv/quill-icons": "^1.0.10",
"@deriv/react-joyride": "^2.6.2",
"@deriv/utils": "^1.0.0",
"@headlessui/react": "^1.7.17",
aizad-deriv marked this conversation as resolved.
Show resolved Hide resolved
"@tanstack/react-table": "^8.10.3",
"@zxcvbn-ts/core": "^3.0.4",
"@zxcvbn-ts/language-common": "^3.0.4",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
// TODO: Create a Generic component for this once the designed is finalized.
import React, { useState } from 'react';
aizad-deriv marked this conversation as resolved.
Show resolved Hide resolved
import { qtMerge, Text } from '@deriv/quill-design';
import { LabelPairedChevronDownSmRegularIcon } from '@deriv/quill-icons';
import { Listbox, Transition } from '@headlessui/react';

const accountTypes = [
{ label: 'Demo', value: 'demo' },
{ label: 'Real', value: 'real' },
];

const DemoRealSwitcher = () => {
const [selected, setSelected] = useState(accountTypes[0]);
const { label, value } = selected;

return (
<div className='w-auto'>
<Listbox as='div' onChange={setSelected} value={selected}>
{({ open }) => (
<div className='relative mt-1'>
aizad-deriv marked this conversation as resolved.
Show resolved Hide resolved
<Listbox.Button
as='button'
className={`cursor-pointer relative w-full py-[3px] px-400 border-75 rounded-200 flex gap-x-400 items-center ${
aizad-deriv marked this conversation as resolved.
Show resolved Hide resolved
value === 'demo' ? 'border-status-light-information' : 'border-status-light-success'
}`}
>
<Text
bold
className={
value === 'demo' ? 'text-status-light-information' : 'text-status-light-success'
}
size='sm'
>
{label}
</Text>
<LabelPairedChevronDownSmRegularIcon
className={qtMerge(
value === 'demo' ? 'fill-status-light-information' : 'fill-status-light-success',
open
? 'transform -rotate-180 transition duration-200 ease-in-out'
: 'transition duration-200 ease-in-out'
)}
/>
</Listbox.Button>
<Transition leave='transition ease-in duration-100' leaveFrom='opacity-100' leaveTo='opacity-0'>
<Listbox.Options
as='div'
className='absolute mt-200 max-h-3000 w-full rounded-200 bg-system-light-primary-background shadow-210'
>
{accountTypes?.map(account => (
<Listbox.Option
as='div'
className='cursor-pointer bg-system-light-primary-background hover:bg-system-light-hover-background'
key={account.label}
value={account}
>
{({ selected }) => (
<Text
bold={selected}
className={`px-800 py-300 text-center ${
selected && 'bg-system-light-active-background'
}`}
size='sm'
>
{account.label}
</Text>
)}
</Listbox.Option>
))}
</Listbox.Options>
</Transition>
</div>
)}
</Listbox>
</div>
);
};

export default DemoRealSwitcher;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default as DemoRealSwitcher } from './DemoRealSwitcher';
1 change: 1 addition & 0 deletions packages/tradershub/src/components/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
export * from './ActionScreen';
export * from './ContentSwitcher';
export * from './CurrencySwitcher';
export * from './DemoRealSwitcher';
export * from './Dialog';
export * from './GetADerivAccountBanner';
export * from './Modal';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
import React, { FC } from 'react';
import { Button, Heading, Text } from '@deriv/quill-design';
import { OptionsAndMultipliersSection, StaticLink } from '../../components';
import { DemoRealSwitcher, OptionsAndMultipliersSection, StaticLink } from '../../components';
import { CTraderList } from '../../features/cfd/components/CTraderList';
import { OtherCFDPlatformsList } from '../../features/cfd/components/OtherCFDPlatformsList';

const TradersHubRoute: FC = () => {
return (
<div className='flex flex-col gap-1200'>
<div className='flex items-center justify-between align-start gap-100'>
<Heading.H3>Trader&apos;s Hub</Heading.H3>
<div className='flex flex-row gap-600'>
<Heading.H3>Trader&apos;s Hub</Heading.H3>
<DemoRealSwitcher />
</div>
<div className='flex flex-col items-end justify-end'>
<Text size='sm'>Total assets</Text>
<Heading.H3 className='text-status-light-information'>10,000.00 USD</Heading.H3>
Expand Down
Loading