From 65e744ab148924b877fe87b446f097b0fc56027d Mon Sep 17 00:00:00 2001 From: Emmanuel Date: Fri, 30 Aug 2024 08:40:21 +0100 Subject: [PATCH] feat: migrate two files to typescript --- src/packages/model/Dataset.ts | 7 +++++++ src/packages/model/theme.ts | 5 +++++ .../datasets/{useThemes.js => useThemes.tsx} | 5 +++-- .../datasets/view/{menu.js => menu.tsx} | 18 ++++++++++++++++-- 4 files changed, 31 insertions(+), 4 deletions(-) create mode 100644 src/packages/model/theme.ts rename src/packages/modules-datasets/datasets/{useThemes.js => useThemes.tsx} (72%) rename src/packages/modules-datasets/datasets/view/{menu.js => menu.tsx} (78%) diff --git a/src/packages/model/Dataset.ts b/src/packages/model/Dataset.ts index b2fbc85d0..0c36c2120 100644 --- a/src/packages/model/Dataset.ts +++ b/src/packages/model/Dataset.ts @@ -1,5 +1,12 @@ +import { ValidationState } from '../components'; + export type Dataset = { id?: string; + catalogRecord: CatalogRecord; + validationState: ValidationState; +}; +export type CatalogRecord = { + contributor: string; }; export type Distribution = { id?: string; diff --git a/src/packages/model/theme.ts b/src/packages/model/theme.ts new file mode 100644 index 000000000..71ba15f31 --- /dev/null +++ b/src/packages/model/theme.ts @@ -0,0 +1,5 @@ +export type Theme = { + idConceptScheme: string; + label: string; + uri: string; +}; diff --git a/src/packages/modules-datasets/datasets/useThemes.js b/src/packages/modules-datasets/datasets/useThemes.tsx similarity index 72% rename from src/packages/modules-datasets/datasets/useThemes.js rename to src/packages/modules-datasets/datasets/useThemes.tsx index 8183f68d4..3343f67a0 100644 --- a/src/packages/modules-datasets/datasets/useThemes.js +++ b/src/packages/modules-datasets/datasets/useThemes.tsx @@ -1,12 +1,13 @@ import { useQuery } from '@tanstack/react-query'; -import { ThemesApi } from '../..//sdk'; +import { ThemesApi } from '../../sdk'; +import { Theme } from '../../model/theme'; export const useThemes = () => useQuery({ queryKey: ['themes'], queryFn: () => { return ThemesApi.getThemes().then((themes) => - themes.map((theme) => ({ + (themes as Theme[]).map((theme) => ({ value: theme.uri, label: ( <> diff --git a/src/packages/modules-datasets/datasets/view/menu.js b/src/packages/modules-datasets/datasets/view/menu.tsx similarity index 78% rename from src/packages/modules-datasets/datasets/view/menu.js rename to src/packages/modules-datasets/datasets/view/menu.tsx index 66acab67a..92ad6da04 100644 --- a/src/packages/modules-datasets/datasets/view/menu.js +++ b/src/packages/modules-datasets/datasets/view/menu.tsx @@ -10,8 +10,18 @@ import { ValidationButton } from '../../../components'; import { useGoBack } from '../../../utils/hooks/useGoBack'; import { ADMIN, DATASET_CONTRIBUTOR } from '../../../auth/roles'; import { usePermission } from '../../../redux/hooks/usePermission'; +import { Dataset } from '../../../model/Dataset'; -export const ViewMenu = ({ dataset, onPublish, onDelete }) => { +type ViewMenuTypes = { + dataset: Dataset; + onPublish: () => void; + onDelete: () => void; +}; +export const ViewMenu = ({ + dataset, + onPublish, + onDelete, +}: Readonly) => { const goBack = useGoBack(); const permission = usePermission(); @@ -26,7 +36,11 @@ export const ViewMenu = ({ dataset, onPublish, onDelete }) => { goBack('/datasets')} /> {(isAdmin || hasDatasetRightsBasedOnStamp) && ( - + )} {(isAdmin || (hasDatasetRightsBasedOnStamp &&