Skip to content

Commit

Permalink
refactor: Change lib v2 code to TS
Browse files Browse the repository at this point in the history
  • Loading branch information
yusuf-musleh committed Jun 25, 2024
1 parent 49b7142 commit 5d4c369
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,19 @@ 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),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 ? (
Expand Down Expand Up @@ -98,7 +98,7 @@ const LibrariesV2Tab = ({
</div>

{ hasV2Libraries
? data.results.map(({
? data?.results.map(({
id, org, slug, title,
}) => (
<CardItem
Expand All @@ -124,12 +124,12 @@ const LibrariesV2Tab = ({
)}

{
data?.numPages > 1
(data?.numPages || 0) > 1
&& (
<Pagination
className="d-flex justify-content-center"
paginationLabel="pagination navigation"
pageCount={data.numPages}
pageCount={data?.numPages}
currentPage={currentPage}
onPageSelect={handlePageSelect}
/>
Expand Down

0 comments on commit 5d4c369

Please sign in to comment.