Skip to content

Commit

Permalink
Merge pull request #262 from farabi-deriv/farabi/feq-2693/fix-localis…
Browse files Browse the repository at this point in the history
…ation-with-account-switcher-tabs

Farabi/feq-2693/fix-localisation-with-account-switcher-tabs
  • Loading branch information
shayan-deriv authored Oct 15, 2024
2 parents 78ed22d + 3afa7f5 commit ed00699
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
13 changes: 9 additions & 4 deletions src/components/AppLayout/AccountSwitcher/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,18 @@ type AccountSwitcherProps = {
buttonClassName?: string;
children?: ReactElement<TabTitleProps>[];
isDisabled?: boolean;
tabsLabels?: {
demo: string;
real: string;
};
};

export const AccountSwitcher = ({
children,
activeAccount,
isDisabled = false,
buttonClassName,
tabsLabels,
}: AccountSwitcherProps) => {
const [isOpen, setIsOpen] = useState(false);
const ref = useRef(null);
Expand Down Expand Up @@ -87,8 +92,8 @@ export const AccountSwitcher = ({
<Tabs
activeTab={
activeAccount.isVirtual
? "Demo"
: "Real"
? tabsLabels?.demo ?? "Demo"
: tabsLabels?.real ?? "Real"
}
variant="secondary"
>
Expand All @@ -110,8 +115,8 @@ export const AccountSwitcher = ({
<Tabs
activeTab={
activeAccount.isVirtual
? "Demo"
: "Real"
? tabsLabels?.demo ?? "Demo"
: tabsLabels?.real ?? "Real"
}
variant="secondary"
>
Expand Down
11 changes: 8 additions & 3 deletions stories/AccountSwitcher.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,12 @@ export const Default: Story = {
isActive: false,
},
children: [], // Add an empty array for the children property
tabsLabels: {
demo: "Demo",
real: "Real",
},
},
render: () => {
render: (args) => {
return (
<div style={{ width: "800px", height: "500px" }}>
<Header>
Expand All @@ -116,8 +120,9 @@ export const Default: Story = {
isActive: true,
}
}
tabsLabels={args.tabsLabels}
>
<AccountSwitcher.Tab title="Real">
<AccountSwitcher.Tab title={args.tabsLabels?.real ?? "Real"}>
<AccountSwitcher.AccountsPanel
isOpen
title="EU Accounts"
Expand Down Expand Up @@ -172,7 +177,7 @@ export const Default: Story = {
this is a footer
</AccountSwitcher.Footer>
</AccountSwitcher.Tab>
<AccountSwitcher.Tab title="Demo">
<AccountSwitcher.Tab title={args.tabsLabels?.demo ?? "Demo"}>
test 2
</AccountSwitcher.Tab>
</AccountSwitcher>
Expand Down

0 comments on commit ed00699

Please sign in to comment.