From 86f93711c5ef407b83dadeb47f415955e6ba1ecc Mon Sep 17 00:00:00 2001 From: Yusuf Musleh Date: Sun, 23 Jun 2024 17:23:31 +0300 Subject: [PATCH] refactor: Change lib v2 code to TS --- src/studio-home/data/{apiHooks.js => apiHooks.ts} | 12 +++++++++++- .../libraries-v2-tab/{index.jsx => index.tsx} | 8 ++++---- 2 files changed, 15 insertions(+), 5 deletions(-) rename src/studio-home/data/{apiHooks.js => apiHooks.ts} (60%) rename src/studio-home/tabs-section/libraries-v2-tab/{index.jsx => index.tsx} (96%) diff --git a/src/studio-home/data/apiHooks.js b/src/studio-home/data/apiHooks.ts similarity index 60% rename from src/studio-home/data/apiHooks.js rename to src/studio-home/data/apiHooks.ts index 92575bf717..d9461aa705 100644 --- a/src/studio-home/data/apiHooks.js +++ b/src/studio-home/data/apiHooks.ts @@ -2,10 +2,20 @@ import { useQuery } from '@tanstack/react-query'; import { getStudioHomeLibrariesV2 } from './api'; + +interface CustomParams { + type?: string, + page?: number, + pageSize?: number, + pagination?: boolean, + order?: string, + saerch?: string, +} + /** * Builds the query to fetch list of V2 Libraries */ -const useListStudioHomeV2Libraries = (customParams) => ( +const useListStudioHomeV2Libraries = (customParams: CustomParams) => ( useQuery({ queryKey: ['listV2Libraries', customParams], queryFn: () => getStudioHomeLibrariesV2(customParams), diff --git a/src/studio-home/tabs-section/libraries-v2-tab/index.jsx b/src/studio-home/tabs-section/libraries-v2-tab/index.tsx similarity index 96% rename from src/studio-home/tabs-section/libraries-v2-tab/index.jsx rename to src/studio-home/tabs-section/libraries-v2-tab/index.tsx index 7f57e74528..ab84652d12 100644 --- a/src/studio-home/tabs-section/libraries-v2-tab/index.jsx +++ b/src/studio-home/tabs-section/libraries-v2-tab/index.tsx @@ -62,7 +62,7 @@ const LibrariesV2Tab = ({ : `${window.location.origin}${getPath(getConfig().PUBLIC_PATH)}library/${id}` ); - const hasV2Libraries = data?.results?.length > 0; + const hasV2Libraries = (data?.results?.length || 0) > 0; return ( isError ? ( @@ -98,7 +98,7 @@ const LibrariesV2Tab = ({ { hasV2Libraries - ? data.results.map(({ + ? data?.results.map(({ id, org, slug, title, }) => ( 1 + (data?.numPages || 0) > 1 && (