diff --git a/src/features/dashboard/components/Tabs/__tests__/tabs.test.tsx b/src/features/dashboard/components/Tabs/__tests__/tabs.test.tsx deleted file mode 100644 index 7e3fc0a2b..000000000 --- a/src/features/dashboard/components/Tabs/__tests__/tabs.test.tsx +++ /dev/null @@ -1,69 +0,0 @@ -import { TDashboardTab } from '@site/src/contexts/app-manager/app-manager.context'; -import useAppManager from '@site/src/hooks/useAppManager'; -import { render, cleanup, screen } from '@site/src/test-utils'; -import userEvent from '@testing-library/user-event'; -import React, { act } from 'react'; -import DashboardTabs from '..'; - -jest.mock('@site/src/hooks/useAppManager'); - -const mockUseAppManager = useAppManager as jest.MockedFunction< - () => Partial> ->; - -let mockCurrentTab: TDashboardTab = TDashboardTab.MANAGE_TOKENS; - -const mockUpdateCurrentTab = jest.fn().mockImplementation((newTab: TDashboardTab) => { - mockCurrentTab = newTab; -}); - -mockUseAppManager.mockImplementation(() => ({ - currentTab: mockCurrentTab, - updateCurrentTab: mockUpdateCurrentTab, -})); - -describe('Dashboard Tabs', () => { - beforeEach(() => { - render(); - }); - - afterEach(() => { - cleanup(); - mockCurrentTab = TDashboardTab.MANAGE_TOKENS; - jest.clearAllMocks(); - }); - - it('Should render all tabs properly', () => { - const tabs = screen.getAllByRole('tab'); - - expect(tabs).toHaveLength(4); - - const registerApplicationTab = screen.getByRole('tab', { name: /register application/i }); - const manageApplicationsTab = screen.getByRole('tab', { name: /manage tokens/i }); - const manageTokensTab = screen.getByRole('tab', { name: /manage applications/i }); - const registerTokenTab = screen.getByRole('tab', { name: /register tokens/i }); - - expect(registerApplicationTab).toBeInTheDocument(); - expect(registerApplicationTab).toBeVisible(); - - expect(manageApplicationsTab).toBeInTheDocument(); - expect(manageApplicationsTab).toBeVisible(); - - expect(manageTokensTab).toBeInTheDocument(); - expect(manageTokensTab).toBeVisible(); - - expect(registerTokenTab).toBeInTheDocument(); - expect(registerTokenTab).toBeVisible(); - }); - - it('Should change the current tab on tabs click', async () => { - const registerApplicationTab = screen.getByRole('tab', { name: /register application/i }); - - await act(async () => { - await userEvent.click(registerApplicationTab); - }); - - expect(mockUpdateCurrentTab).toBeCalled(); - expect(mockUpdateCurrentTab).toBeCalledWith(TDashboardTab.REGISTER_APP.toString()); - }); -}); diff --git a/src/features/dashboard/components/Tabs/index.ts b/src/features/dashboard/components/Tabs/index.ts deleted file mode 100644 index 96582c896..000000000 --- a/src/features/dashboard/components/Tabs/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -import Tabs from './tabs'; - -export default Tabs; diff --git a/src/features/dashboard/components/Tabs/tabs.module.scss b/src/features/dashboard/components/Tabs/tabs.module.scss deleted file mode 100644 index 56819b149..000000000 --- a/src/features/dashboard/components/Tabs/tabs.module.scss +++ /dev/null @@ -1,61 +0,0 @@ -@use 'src/styles/utility' as *; - -.app_dashboard { - margin-top: rem(5); -} - -.tabs_root { - display: flex; - flex-direction: column; - justify-content: center; -} - -.tabs_list { - display: flex; - justify-content: center; - align-items: center; - padding: rem(2); -} - -.tabs_trigger { - height: rem(4.5); - display: flex; - align-items: center; - justify-content: center; - font-size: rem(1.5); - line-height: 1; - user-select: none; - cursor: pointer; - border-bottom: 1px solid var(--ifm-color-emphasis-200); - - &:hover h3 { - color: var(--ifm-color-emphasis-800); - } - h3 { - color: var(--ifm-color-emphasis-500); - font-weight: 400; - transition: color 0.2s; - padding: 0 rem(2); - text-align: center; - } - - @media (max-width: 395px) { - height: rem(7.5); - } -} - -.tabs_trigger[data-state='active'] { - border-bottom: 2px solid var(--colors-coral500); - h3 { - color: var(--ifm-color-emphasis-800); - font-weight: bold; - } -} - -.tab_content { - display: flex; - justify-content: space-around; - align-items: center; - padding: rem(2) 5vw; - overflow-y: auto; -} diff --git a/src/features/dashboard/components/Tabs/tabs.tsx b/src/features/dashboard/components/Tabs/tabs.tsx deleted file mode 100644 index e207d7fa4..000000000 --- a/src/features/dashboard/components/Tabs/tabs.tsx +++ /dev/null @@ -1,94 +0,0 @@ -import React from 'react'; -import { Text } from '@deriv/ui'; -import * as Tabs from '@radix-ui/react-tabs'; -import { TDashboardTab } from '@site/src/contexts/app-manager/app-manager.context'; -import useAppManager from '@site/src/hooks/useAppManager'; -import AppManagement from '../../manage-apps'; -import ApiToken from '../../manage-tokens'; -import AppRegistration from '../../register-app'; -import TokenRegistration from '../../register-tokens'; -import styles from './tabs.module.scss'; -import Translate from '@docusaurus/Translate'; - -type TTab = { - id: number; - value: TDashboardTab; - label: React.ReactNode; - content: () => JSX.Element; -}; - -const tabs: TTab[] = [ - { - id: 0, - value: TDashboardTab.MANAGE_TOKENS, - label: Manage tokens, - content: ApiToken, - }, - { - id: 1, - value: TDashboardTab.REGISTER_APP, - label: Register application, - content: AppRegistration, - }, - { - id: 2, - value: TDashboardTab.MANAGE_APPS, - label: Manage applications, - content: AppManagement, - }, - { - id: 3, - value: TDashboardTab.REGISTER_TOKENS, - label: Register tokens, - content: TokenRegistration, - }, -]; - -const DashboardTabs = () => { - const { currentTab, updateCurrentTab } = useAppManager(); - - return ( -
-
- - Your apps - - - Register your app, get an app ID, and start using the Deriv API - -
- { - updateCurrentTab(tab as unknown as TDashboardTab); - }} - > - - {tabs.map((item: TTab) => ( - - - {item.label} - - - ))} - - <> - {tabs.map(({ id, value, content: Content }: TTab) => ( - -
- -
-
- ))} - -
-
- ); -}; - -export default DashboardTabs; diff --git a/src/features/dashboard/components/app-register-success-modal/__tests__/app-register-success-modal.test.tsx b/src/features/dashboard/components/app-register-success-modal/__tests__/app-register-success-modal.test.tsx index d97dbdc48..b839f1f92 100644 --- a/src/features/dashboard/components/app-register-success-modal/__tests__/app-register-success-modal.test.tsx +++ b/src/features/dashboard/components/app-register-success-modal/__tests__/app-register-success-modal.test.tsx @@ -55,10 +55,9 @@ describe('AppRegisterSuccessModal', () => { const configure_btn = await screen.findByText(/configure now/i); await userEvent.click(configure_btn); expect(mock_configure).toHaveBeenCalledTimes(1); - expect(mock_cancel).toHaveBeenCalledTimes(1); const maybe_later_btn = await screen.findByText(/maybe later/i); await userEvent.click(maybe_later_btn); - expect(mock_cancel).toHaveBeenCalledTimes(2); + expect(mock_cancel).toHaveBeenCalledTimes(1); }); }); diff --git a/src/features/dashboard/components/app-register-success-modal/app-register-success-modal.tsx b/src/features/dashboard/components/app-register-success-modal/app-register-success-modal.tsx index 296c83bcb..a559a1b1a 100644 --- a/src/features/dashboard/components/app-register-success-modal/app-register-success-modal.tsx +++ b/src/features/dashboard/components/app-register-success-modal/app-register-success-modal.tsx @@ -25,12 +25,9 @@ const AppRegisterSuccessModal = ({ { - onConfigure(); - onCancel(); - }} + primaryButtonCallback={() => onConfigure()} secondaryButtonLabel={translate({ message: 'Maybe later' })} - secondaryButtonCallback={onCancel} + secondaryButtonCallback={() => onCancel()} isMobile={deviceType !== 'desktop'} showHandleBar showSecondaryButton diff --git a/src/features/dashboard/components/app-register/app-register.tsx b/src/features/dashboard/components/app-register/app-register.tsx index 8cf78472f..f08c8f20b 100644 --- a/src/features/dashboard/components/app-register/app-register.tsx +++ b/src/features/dashboard/components/app-register/app-register.tsx @@ -1,13 +1,16 @@ -import React from 'react'; +import React, { useCallback, useEffect, useState } from 'react'; +import { useForm } from 'react-hook-form'; import Translate, { translate } from '@docusaurus/Translate'; +import { ApplicationObject } from '@deriv/api-types'; import { Button, Link, Text } from '@deriv-com/quill-ui'; -import { useForm } from 'react-hook-form'; import { yupResolver } from '@hookform/resolvers/yup'; import CustomCheckbox from '@site/src/components/CustomCheckbox'; import useDeviceType from '@site/src/hooks/useDeviceType'; +import useWS from '@site/src/hooks/useWs'; +import useAppManager from '@site/src/hooks/useAppManager'; +import { TDashboardTab } from '@site/src/contexts/app-manager/app-manager.context'; import { IBaseRegisterAppForm, - TAppRegisterProps, TRestrictionsComponentProps, TTermsAndConditionsProps, baseAppRegisterSchema, @@ -15,13 +18,15 @@ import { } from './types'; import './app-register.scss'; +import AppRegisterSuccessModal from '../app-register-success-modal'; + const TermsAndConditions: React.FC = ({ register }) => { return (