From c8072898b53e02838f21ed9cdf384cdca85680f2 Mon Sep 17 00:00:00 2001 From: Hubert Koster Date: Tue, 9 May 2023 13:16:26 +0200 Subject: [PATCH 1/6] chore: migrating code --- .../Apiexplorer/LoginDialog/index.tsx | 3 +- .../RequestResponseRenderer/index.tsx | 4 +- .../__tests__/SubscribeRenderer.test.tsx | 28 +++ .../Apiexplorer/SubscribeRenderer/index.tsx | 4 +- .../__tests__/ApiExplorer.test.tsx | 198 ++++++++++-------- src/hooks/useDisableSendRequest/index.tsx | 18 ++ src/hooks/useSubscription/index.tsx | 4 +- src/hooks/useWs/index.tsx | 11 +- 8 files changed, 176 insertions(+), 94 deletions(-) create mode 100644 src/hooks/useDisableSendRequest/index.tsx diff --git a/src/features/Apiexplorer/LoginDialog/index.tsx b/src/features/Apiexplorer/LoginDialog/index.tsx index 56f6995be..48f14d9b6 100644 --- a/src/features/Apiexplorer/LoginDialog/index.tsx +++ b/src/features/Apiexplorer/LoginDialog/index.tsx @@ -1,7 +1,6 @@ import React, { useCallback } from 'react'; -import { Modal } from '@deriv/ui'; +import { Modal, Button } from '@deriv/ui'; import useLoginUrl from '@site/src/hooks/useLoginUrl'; -import { Button } from '@deriv/ui'; import styles from './LoginDialog.module.scss'; type TLoginDialog = { diff --git a/src/features/Apiexplorer/RequestResponseRenderer/index.tsx b/src/features/Apiexplorer/RequestResponseRenderer/index.tsx index 99001ce96..f325274d6 100644 --- a/src/features/Apiexplorer/RequestResponseRenderer/index.tsx +++ b/src/features/Apiexplorer/RequestResponseRenderer/index.tsx @@ -5,6 +5,7 @@ import useWS from '@site/src/hooks/useWs'; import useAuthContext from '@site/src/hooks/useAuthContext'; import PlaygroundSection from './PlaygroundSection'; import LoginDialog from '../LoginDialog'; +import useDisableSendRequest from '@site/src/hooks/useDisableSendRequest'; import styles from '../RequestJSONBox/RequestJSONBox.module.scss'; export interface IResponseRendererProps { @@ -19,6 +20,7 @@ function RequestResponseRenderer({ auth, }: IResponseRendererProps) { const { is_logged_in } = useAuthContext(); + const { disableSendRequest } = useDisableSendRequest(); const { data, is_loading, send, clear, error } = useWS(name); const [toggle_modal, setToggleModal] = useState(false); const [response_state, setResponseState] = useState(false); @@ -51,7 +53,7 @@ function RequestResponseRenderer({ return (
-