diff --git a/apps/digitaltwins/src/config/theme.ts b/apps/digitaltwins/src/config/theme.ts index 43f1ad8a..d12fbe3b 100644 --- a/apps/digitaltwins/src/config/theme.ts +++ b/apps/digitaltwins/src/config/theme.ts @@ -8,16 +8,16 @@ import grey from "@mui/material/colors/grey"; const customTheme = createTheme({ palette: { primary: { - light: "#E4F9FF", - main: "#38a7d4", - dark: "#1f97c8", + light: "#27a56a", + main: "#007663", + dark: "#036354", contrastText: "#fff", }, secondary: { - light: "#ff7961", - main: "#f44336", - dark: "#ba000d", - contrastText: "#000", + light: "#00add9", + main: "#004b85", + dark: "#00365f", + contrastText: "#fff", }, }, typography: { diff --git a/apps/ohsmart/src/config/form.ts b/apps/ohsmart/src/config/form.ts index 10862e2f..874c695a 100644 --- a/apps/ohsmart/src/config/form.ts +++ b/apps/ohsmart/src/config/form.ts @@ -49,7 +49,7 @@ const form: FormConfig = { embargoDateMin: 2, // days in the future embargoDateMax: 18250, displayProcesses: false, - maxSize: 9985798963, // max file size that can be uploaded in bytes + maxSize: 10000000000, // max file size that can be uploaded in bytes }, }; diff --git a/packages/deposit/src/deposit/Deposit.tsx b/packages/deposit/src/deposit/Deposit.tsx index 5e6f53ad..36186d3c 100644 --- a/packages/deposit/src/deposit/Deposit.tsx +++ b/packages/deposit/src/deposit/Deposit.tsx @@ -46,7 +46,7 @@ import { } from "@dans-framework/utils"; import type { Page } from "@dans-framework/pages"; import { useAuth } from "react-oidc-context"; -import { useFetchSavedMetadataQuery } from "./depositApi"; +import { useFetchSavedMetadataQuery } from "../features/submit/submitApi"; import { useValidateAllKeysQuery, getFormActions, diff --git a/packages/deposit/src/deposit/depositApi.ts b/packages/deposit/src/deposit/depositApi.ts deleted file mode 100644 index 4d98ac81..00000000 --- a/packages/deposit/src/deposit/depositApi.ts +++ /dev/null @@ -1,38 +0,0 @@ -import { createApi, fetchBaseQuery } from "@reduxjs/toolkit/query/react"; -import type { SavedFormResponse } from "../types/Metadata"; - -// Function for retrieving saved forms -export const depositApi = createApi({ - reducerPath: "savedDeposit", - baseQuery: fetchBaseQuery({ - baseUrl: `${import.meta.env.VITE_PACKAGING_TARGET}/dataset/`, - }), - refetchOnMountOrArgChange: true, - endpoints: (build) => ({ - fetchSavedMetadata: build.query({ - query: (id) => ({ - url: id, - headers: { Accept: "application/json" }, - }), - transformResponse: (response: SavedFormResponse) => { - // mark previously submitted files - const modifiedResponse = { - ...response, - md: { - ...response.md, - "file-metadata": - response.md["file-metadata"] ? - response.md["file-metadata"].map((f) => ({ - ...f, - submittedFile: true, - })) - : [], - }, - }; - return modifiedResponse; - }, - }), - }), -}); - -export const { useFetchSavedMetadataQuery } = depositApi; diff --git a/packages/deposit/src/features/submit/submitApi.ts b/packages/deposit/src/features/submit/submitApi.ts index 1c1b48d1..ad94d840 100644 --- a/packages/deposit/src/features/submit/submitApi.ts +++ b/packages/deposit/src/features/submit/submitApi.ts @@ -8,12 +8,14 @@ import moment from "moment"; import { enqueueSnackbar } from "notistack"; import i18n from "../../languages/i18n"; import { formatFormData } from "./submitHelpers"; +import type { SavedFormResponse } from "../../types/Metadata"; export const submitApi = createApi({ reducerPath: "submitApi", baseQuery: fetchBaseQuery({ - baseUrl: `${import.meta.env.VITE_PACKAGING_TARGET}/inbox/`, + baseUrl: `${import.meta.env.VITE_PACKAGING_TARGET}`, }), + tagTypes: ["Forms"], endpoints: (build) => ({ submitData: build.mutation({ query: ({ user, actionType, id, metadata, config, files }) => { @@ -55,12 +57,13 @@ export const submitApi = createApi({ : `dataset/${actionType === "save" ? "DRAFT" : "PUBLISH"}`; return ({ - url: submitUrl, + url: `inbox/${submitUrl}`, method: "POST", headers: headers, body: data, }) }, + invalidatesTags: (_res, _err, arg ) => [{ type: "Forms", id: arg.id }], transformResponse: (response, _meta, arg) => { store.dispatch(setMetadataSubmitStatus( arg.actionType === "save" ? "saved" : "submitted", @@ -89,7 +92,34 @@ export const submitApi = createApi({ }); }, }), + fetchSavedMetadata: build.query({ + query: (id) => ({ + url: `dataset/${id}`, + headers: { Accept: "application/json" }, + }), + providesTags: (_res, _err, id) => [{ type: "Forms", id }], + transformResponse: (response: SavedFormResponse) => { + // mark previously submitted files + const modifiedResponse = { + ...response, + md: { + ...response.md, + "file-metadata": + response.md["file-metadata"] ? + response.md["file-metadata"].map((f) => ({ + ...f, + submittedFile: true, + })) + : [], + }, + }; + return modifiedResponse; + }, + }), }), }); -export const { useSubmitDataMutation } = submitApi; +export const { + useSubmitDataMutation, + useFetchSavedMetadataQuery +} = submitApi; diff --git a/packages/deposit/src/redux/store.ts b/packages/deposit/src/redux/store.ts index af15140d..4ddc871a 100644 --- a/packages/deposit/src/redux/store.ts +++ b/packages/deposit/src/redux/store.ts @@ -3,7 +3,6 @@ import metadataReducer from "../features/metadata/metadataSlice"; import filesReducer from "../features/files/filesSlice"; import submitReducer from "../features/submit/submitSlice"; import depositReducer from "../deposit/depositSlice"; -import { depositApi } from "../deposit/depositApi"; import { orcidApi } from "../features/metadata/api/orcid"; import { rorApi } from "../features/metadata/api/ror"; import { gettyApi } from "../features/metadata/api/getty"; @@ -37,7 +36,6 @@ export const store = configureStore({ [dansUtilityApi.reducerPath]: dansUtilityApi.reducer, [rdaApi.reducerPath]: rdaApi.reducer, [languagesApi.reducerPath]: languagesApi.reducer, - [depositApi.reducerPath]: depositApi.reducer, [validateKeyApi.reducerPath]: validateKeyApi.reducer, submit: submitReducer, deposit: depositReducer, @@ -57,7 +55,6 @@ export const store = configureStore({ .concat(dansUtilityApi.middleware) .concat(rdaApi.middleware) .concat(languagesApi.middleware) - .concat(depositApi.middleware) .concat(validateKeyApi.middleware) .concat(errorLogger), }); diff --git a/packages/file-mapper/src/features/FileMapper.tsx b/packages/file-mapper/src/features/FileMapper.tsx index 9d9c92fc..58b2795b 100644 --- a/packages/file-mapper/src/features/FileMapper.tsx +++ b/packages/file-mapper/src/features/FileMapper.tsx @@ -10,7 +10,7 @@ import Step from '@mui/material/Step'; import StepLabel from '@mui/material/StepLabel'; import { useTranslation } from "react-i18next"; import { Step1, Step2, Step3 } from './Steps'; -import { getActiveStep, setActiveStep, getFile, getSavedMap, getMapping } from './fileMapperSlice'; +import { getActiveStep, setActiveStep, getFile, getSavedMap, getMapping, getFileError } from './fileMapperSlice'; import { useSubmitMapMutation } from './fileMapperApi'; import { useAppSelector, useAppDispatch } from "../redux/hooks"; import CircularProgress from '@mui/material/CircularProgress'; @@ -32,6 +32,7 @@ const FileMapper = ({setMappedForm, page}: { const file = useAppSelector(getFile); const savedMap = useAppSelector(getSavedMap); const mapping = useAppSelector(getMapping); + const fileError = useAppSelector(getFileError); const [ submitMap, { isLoading, data } ] = useSubmitMapMutation(); // set page title @@ -99,15 +100,15 @@ const FileMapper = ({setMappedForm, page}: { disabled={activeStep === 0} onClick={handleBack} sx={{ mr: 1 }} - variant="outlined" + variant="contained" > {t("buttonBack")}