{/*repeat for each feed link*/}
{feeds.length > 0 &&
-// @ts-expect-error TS(7006): Parameter 'feed' implicitly has an 'any' type.
feeds.map((feed, key) => (
{feed.type}
diff --git a/src/components/events/partials/ModalTabsAndPages/SeriesDetailsStatisticTab.tsx b/src/components/events/partials/ModalTabsAndPages/SeriesDetailsStatisticTab.tsx
index 7b85ab80d4..13a4d9970b 100644
--- a/src/components/events/partials/ModalTabsAndPages/SeriesDetailsStatisticTab.tsx
+++ b/src/components/events/partials/ModalTabsAndPages/SeriesDetailsStatisticTab.tsx
@@ -9,10 +9,11 @@ import TimeSeriesStatistics from "../../../shared/TimeSeriesStatistics";
import { useAppDispatch, useAppSelector } from "../../../../store";
const SeriesDetailsStatisticTab = ({
-// @ts-expect-error TS(7031): Binding element 'seriesId' implicitly has an 'any'... Remove this comment to see the full error message
seriesId,
-// @ts-expect-error TS(7031): Binding element 'header' implicitly has an 'any' t... Remove this comment to see the full error message
header,
+}: {
+ seriesId: string,
+ header: string,
}) => {
const { t } = useTranslation();
const dispatch = useAppDispatch();
@@ -26,8 +27,7 @@ const SeriesDetailsStatisticTab = ({
}
/* generates file name for download-link for a statistic */
-// @ts-expect-error TS(7006): Parameter 'statsTitle' implicitly has an 'any' typ... Remove this comment to see the full error message
- const statisticsCsvFileName = (statsTitle) => {
+ const statisticsCsvFileName = (statsTitle: string) => {
const sanitizedStatsTitle = statsTitle
.replace(/[^0-9a-z]/gi, "_")
.toLowerCase();
@@ -57,7 +57,6 @@ const SeriesDetailsStatisticTab = ({
/* visualization of statistic for time series data */
{
const { t } = useTranslation();
@@ -27,13 +27,11 @@ const SeriesDetailsThemeTab = ({
const user = useAppSelector(state => getUserInformation(state));
-// @ts-expect-error TS(7006): Parameter 'values' implicitly has an 'any' type.
- const handleSubmit = (values) => {
+ const handleSubmit = (values: { theme: string }) => {
dispatch(updateSeriesTheme({id: seriesId, values: values}));
};
-// @ts-expect-error TS(7006): Parameter 'formik' implicitly has an 'any' type.
- const checkValidity = (formik) => {
+ const checkValidity = (formik: FormikProps<{theme: string }>) => {
if (formik.dirty && formik.isValid) {
// check if user provided values differ from initial ones
return !_.isEqual(formik.values, formik.initialValues);
@@ -103,8 +101,7 @@ const SeriesDetailsThemeTab = ({
{t("SAVE")}
formik.resetForm({ values: "" })}
+ onClick={() => formik.resetForm()}
className="cancel"
>
{t("CANCEL")}
diff --git a/src/components/events/partials/ModalTabsAndPages/StartTaskSummaryPage.tsx b/src/components/events/partials/ModalTabsAndPages/StartTaskSummaryPage.tsx
index 9ea6a1d88a..0d37296569 100644
--- a/src/components/events/partials/ModalTabsAndPages/StartTaskSummaryPage.tsx
+++ b/src/components/events/partials/ModalTabsAndPages/StartTaskSummaryPage.tsx
@@ -4,6 +4,8 @@ import WizardNavigationButtons from "../../../shared/wizard/WizardNavigationButt
import { getWorkflowDef } from "../../../../selectors/workflowSelectors";
import { useAppSelector } from "../../../../store";
import { FormikProps } from "formik";
+import { Event } from "../../../../slices/eventSlice";
+
/**
* This component renders the summary page of the start task bulk action
@@ -42,7 +44,6 @@ const StartTaskSummaryPage = ({
{t("BULK_ACTIONS.SCHEDULE_TASK.SUMMARY.EVENTS_SUMMARY", {
numberOfEvents: formik.values.events.filter(
-// @ts-expect-error TS(7006): Parameter 'e' implicitly has an 'any' type.
(e) => e.selected === true
).length,
})}
diff --git a/src/components/events/partials/ModalTabsAndPages/StartTaskWorkflowPage.tsx b/src/components/events/partials/ModalTabsAndPages/StartTaskWorkflowPage.tsx
index 18baa203d9..1f713b2a0b 100644
--- a/src/components/events/partials/ModalTabsAndPages/StartTaskWorkflowPage.tsx
+++ b/src/components/events/partials/ModalTabsAndPages/StartTaskWorkflowPage.tsx
@@ -46,8 +46,7 @@ const StartTaskWorkflowPage = ({
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [workflowDef]);
- // @ts-expect-error TS(7006): Parameter 'value' implicitly has an 'any' type.
- const setDefaultValues = (value) => {
+ const setDefaultValues = (value: string) => {
let workflowId = value;
// fill values with default configuration of chosen workflow
let defaultConfiguration = setDefaultConfig(workflowDef, workflowId);
diff --git a/src/components/events/partials/SeriesActionsCell.tsx b/src/components/events/partials/SeriesActionsCell.tsx
index dda3a0a815..5f5faa628c 100644
--- a/src/components/events/partials/SeriesActionsCell.tsx
+++ b/src/components/events/partials/SeriesActionsCell.tsx
@@ -52,8 +52,7 @@ const SeriesActionsCell = ({
setDeleteConfirmation(true);
};
-// @ts-expect-error TS(7006): Parameter 'id' implicitly has an 'any' type.
- const deletingSeries = (id) => {
+ const deletingSeries = (id: string) => {
dispatch(deleteSeries(id));
};
diff --git a/src/components/events/partials/SeriesTitleCell.tsx b/src/components/events/partials/SeriesTitleCell.tsx
index ee423ae64d..27eeede05a 100644
--- a/src/components/events/partials/SeriesTitleCell.tsx
+++ b/src/components/events/partials/SeriesTitleCell.tsx
@@ -18,8 +18,7 @@ const SeriesTitleCell = ({
const { t } = useTranslation();
const dispatch = useAppDispatch();
-// @ts-expect-error TS(7006): Parameter 'seriesId' implicitly has an 'any' type.
- const redirectToEvents = async (seriesId) => {
+ const redirectToEvents = async (seriesId: string) => {
// redirect to tables
await dispatch(loadEventsIntoTable());
diff --git a/src/components/events/partials/modals/DeleteEventsModal.tsx b/src/components/events/partials/modals/DeleteEventsModal.tsx
index 249d73d45f..550655a42c 100644
--- a/src/components/events/partials/modals/DeleteEventsModal.tsx
+++ b/src/components/events/partials/modals/DeleteEventsModal.tsx
@@ -38,8 +38,7 @@ const DeleteEventsModal = ({
};
// Select or deselect all rows in table
-// @ts-expect-error TS(7006): Parameter 'e' implicitly has an 'any' type.
- const onChangeAllSelected = (e) => {
+ const onChangeAllSelected = (e: React.ChangeEvent) => {
const selected = e.target.checked;
setAllChecked(selected);
let changedSelection = selectedEvents.map((event) => {
diff --git a/src/components/events/partials/modals/DeleteSeriesModal.tsx b/src/components/events/partials/modals/DeleteSeriesModal.tsx
index 45286e9060..1aaa578666 100644
--- a/src/components/events/partials/modals/DeleteSeriesModal.tsx
+++ b/src/components/events/partials/modals/DeleteSeriesModal.tsx
@@ -68,8 +68,7 @@ const DeleteSeriesModal = ({
};
// Select or deselect all rows in table
-// @ts-expect-error TS(7006): Parameter 'e' implicitly has an 'any' type.
- const onChangeAllSelected = (e) => {
+ const onChangeAllSelected = (e: React.ChangeEvent) => {
const selected = e.target.checked;
setAllChecked(selected);
let changedSelection = selectedSeries.map((series) => {
diff --git a/src/components/events/partials/modals/EditMetadataEventsModal.tsx b/src/components/events/partials/modals/EditMetadataEventsModal.tsx
index 735d539d30..0817109dde 100644
--- a/src/components/events/partials/modals/EditMetadataEventsModal.tsx
+++ b/src/components/events/partials/modals/EditMetadataEventsModal.tsx
@@ -45,8 +45,8 @@ const EditMetadataEventsModal = ({
mergedMetadata: []
});
const [loading, setLoading] = useState(true);
- const [fatalError, setFatalError] = useState({});
- const [fetchedValues, setFetchedValues] = useState(null);
+ const [fatalError, setFatalError] = useState(undefined);
+ const [fetchedValues, setFetchedValues] = useState<{ [key: string]: string | string[] }>({});
const user = useAppSelector(state => getUserInformation(state));
@@ -61,19 +61,16 @@ const EditMetadataEventsModal = ({
async function fetchData() {
setLoading(true);
-// @ts-expect-error TS(7034): Variable 'eventIds' implicitly has type 'any[]' in... Remove this comment to see the full error message
- let eventIds = [];
+ let eventIds: string[] = [];
selectedEvents.forEach((event) => isEvent(event) && eventIds.push(event.id));
// Get merged metadata from backend
-// @ts-expect-error TS(7005): Variable 'eventIds' implicitly has an 'any[]' type... Remove this comment to see the full error message
// const responseMetadataFields = await dispatch(postEditMetadata(eventIds))
await dispatch(postEditMetadata(eventIds))
.then(unwrapResult)
.then((result) => {
// Set initial values and save metadata field infos in state
- let initialValues = getInitialValues(result);
-// @ts-expect-error TS(2345): Argument of type '{}' is not assignable to paramet... Remove this comment to see the full error message
+ let initialValues = getInitialValues(result.mergedMetadata);
setFetchedValues(initialValues);
setMetadataFields({
merged: result.merged,
@@ -92,15 +89,13 @@ const EditMetadataEventsModal = ({
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
-// @ts-expect-error TS(7006): Parameter 'values' implicitly has an 'any' type.
- const handleSubmit = (values) => {
+ const handleSubmit = (values: { [key: string]: unknown }) => {
const response = dispatch(updateBulkMetadata({metadataFields, values}));
console.info(response);
close();
};
-// @ts-expect-error TS(7006): Parameter 'e' implicitly has an 'any' type.
- const onChangeSelected = (e, fieldId) => {
+ const onChangeSelected = (e: React.ChangeEvent, fieldId: string) => {
let selected = e.target.checked;
let fields = metadataFields;
fields.mergedMetadata = metadataFields.mergedMetadata.map((field) => {
@@ -118,13 +113,11 @@ const EditMetadataEventsModal = ({
};
// Check if value of metadata field is changed
-// @ts-expect-error TS(7006): Parameter 'field' implicitly has an 'any' type.
- const isTouchedOrSelected = (field, formikValues) => {
+ const isTouchedOrSelected = (field: MetadataFieldSelected, formikValues: { [key: string]: string | string[] }) => {
if (field.selected) {
return true;
}
-// @ts-expect-error TS(2531): Object is possibly 'null'.
if (fetchedValues[field.id] !== formikValues[field.id]) {
let fields = metadataFields;
fields.mergedMetadata = metadataFields.mergedMetadata.map((f) => {
@@ -166,16 +159,14 @@ const EditMetadataEventsModal = ({
)}
{/* Fatal error view */}
-{/* @ts-expect-error TS(2339): Property 'fatalError' does not exist on type '{}'. */}
- {!!fatalError.fatalError && (
+ {!!fatalError && (
{t("BULK_ACTIONS.EDIT_EVENTS_METADATA.FATAL_ERROR", {
-// @ts-expect-error TS(2339): Property 'fatalError' does not exist on type '{}'.
- fatalError: fatalError.fatalError,
+ fatalError: fatalError,
})}
@@ -186,10 +177,8 @@ const EditMetadataEventsModal = ({
{/* todo: Request Errors View and Update Errors View (not quite sure what this is used for) */}
-{/* @ts-expect-error TS(2339): Property 'fatalError' does not exist on type '{}'. */}
- {!loading && fatalError.fatalError === undefined && (
+ {!loading && fatalError === undefined && (
handleSubmit(values)}
>
@@ -338,13 +327,10 @@ const EditMetadataEventsModal = ({
);
};
-// @ts-expect-error TS(7006): Parameter 'metadataFields' implicitly has an 'any'... Remove this comment to see the full error message
-const getInitialValues = (metadataFields) => {
+const getInitialValues = (metadataFields: MetadataFieldSelected[]) => {
// Transform metadata fields provided by backend (saved in redux)
- let initialValues = {};
-// @ts-expect-error TS(7006): Parameter 'field' implicitly has an 'any' type.
- metadataFields.mergedMetadata.forEach((field) => {
-// @ts-expect-error TS(7053): Element implicitly has an 'any' type because expre... Remove this comment to see the full error message
+ let initialValues: { [key: string]: string | string[] } = {};
+ metadataFields.forEach((field) => {
initialValues[field.id] = field.value;
});
diff --git a/src/components/events/partials/modals/EditScheduledEventsModal.tsx b/src/components/events/partials/modals/EditScheduledEventsModal.tsx
index 4519036802..d64dd069aa 100644
--- a/src/components/events/partials/modals/EditScheduledEventsModal.tsx
+++ b/src/components/events/partials/modals/EditScheduledEventsModal.tsx
@@ -16,28 +16,27 @@ import {
} from "../../../../utils/bulkActionUtils";
import { useAppDispatch, useAppSelector } from "../../../../store";
import {
- checkForSchedulingConflicts,
+ EditedEvents,
updateScheduledEventsBulk,
+ Conflict,
} from "../../../../slices/eventSlice";
import { fetchRecordings } from "../../../../slices/recordingSlice";
import { useHotkeys } from "react-hotkeys-hook";
import { availableHotkeys } from "../../../../configs/hotkeysConfig";
+import { Event } from "../../../../slices/eventSlice";
/**
* This component manages the pages of the edit scheduled bulk action
*/
const EditScheduledEventsModal = ({
-// @ts-expect-error TS(7031): Binding element 'close' implicitly has an 'any' ty... Remove this comment to see the full error message
close,
+}: {
+ close: () => void
}) => {
const { t } = useTranslation();
const dispatch = useAppDispatch();
const inputDevices = useAppSelector(state => getRecordings(state));
- // TODO: Get rid of the wrappers when modernizing redux is done
- const checkForSchedulingConflictsWrapper = async(events: any) => {
- return dispatch(checkForSchedulingConflicts(events));
- }
const initialValues = initialFormValuesEditScheduledEvents;
@@ -52,7 +51,7 @@ const EditScheduledEventsModal = ({
} = usePageFunctions(0, initialValues);
// for edit page: conflicts with other events
- const [conflicts, setConflicts] = useState([]);
+ const [conflicts, setConflicts] = useState([]);
const user = useAppSelector(state => getUserInformation(state));
@@ -84,23 +83,24 @@ const EditScheduledEventsModal = ({
},
];
-// @ts-expect-error TS(7006): Parameter 'values' implicitly has an 'any' type.
- const validateFormik = (values) => {
- const errors = {};
+ const validateFormik = (values: {
+ events: Event[],
+ editedEvents: EditedEvents[],
+ }) => {
+ const errors: {
+ events?: string,
+ editedEvents?: string,
+ } = {};
if (!checkValidityUpdateScheduleEventSelection(values, user)) {
-// @ts-expect-error TS(2339): Property 'events' does not exist on type '{}'.
errors.events = "Not all events editable!";
}
if (steps[page].name !== "general") {
return checkSchedulingConflicts(
values,
setConflicts,
- checkForSchedulingConflictsWrapper,
dispatch
).then((result) => {
- const errors = {};
if (!result) {
-// @ts-expect-error TS(2339): Property 'editedEvents' does not exist on type '{}... Remove this comment to see the full error message
errors.editedEvents = "Scheduling conflicts exist!";
}
return errors;
@@ -110,8 +110,11 @@ const EditScheduledEventsModal = ({
}
};
-// @ts-expect-error TS(7006): Parameter 'values' implicitly has an 'any' type.
- const handleSubmit = (values) => {
+ const handleSubmit = (values: {
+ events: Event[];
+ editedEvents: EditedEvents[];
+ changedEvents: string[];
+ }) => {
// Only update events if there are changes
if (values.changedEvents.length > 0) {
const response = dispatch(updateScheduledEventsBulk(values));
diff --git a/src/components/events/partials/modals/EmbeddingCodeModal.tsx b/src/components/events/partials/modals/EmbeddingCodeModal.tsx
index 6da6ab4641..271d96fe65 100644
--- a/src/components/events/partials/modals/EmbeddingCodeModal.tsx
+++ b/src/components/events/partials/modals/EmbeddingCodeModal.tsx
@@ -8,9 +8,12 @@ import { availableHotkeys } from "../../../../configs/hotkeysConfig";
* This component renders the embedding code modal
*/
const EmbeddingCodeModal = ({
- close,
- eventId
-}: any) => {
+ close,
+ eventId,
+}: {
+ close: () => void
+ eventId: string
+}) => {
const { t } = useTranslation();
const [textAreaContent, setTextAreaContent] = useState("");
@@ -40,18 +43,22 @@ const EmbeddingCodeModal = ({
};
const copy = () => {
- let copyText = document.getElementById("social_embed-textarea");
-// @ts-expect-error TS(2531): Object is possibly 'null'.
- copyText.select();
- document.execCommand("copy");
+ let copyText = document.getElementById("social_embed-textarea") as HTMLTextAreaElement;
+ if (copyText) {
+ copyText.select();
+ document.execCommand("copy");
- setCopySuccess(true);
+ setCopySuccess(true);
+ }
};
-// @ts-expect-error TS(7006): Parameter 'e' implicitly has an 'any' type.
- const updateTextArea = (e) => {
+ const updateTextArea = (e: React.MouseEvent) => {
// chosen frame size
- let frameSize = e.target ? e.target.textContent : e.toElement.textContent;
+ let frameSize = e.currentTarget.textContent;
+
+ if (!frameSize) {
+ return;
+ }
// buttons containing possible frame sizes
let embedSizeButtons = document.getElementsByClassName("embedSizeButton");
diff --git a/src/components/events/partials/modals/EventDetails.tsx b/src/components/events/partials/modals/EventDetails.tsx
index 9dd050f5eb..19d5ed136b 100644
--- a/src/components/events/partials/modals/EventDetails.tsx
+++ b/src/components/events/partials/modals/EventDetails.tsx
@@ -83,14 +83,6 @@ const EventDetails = ({
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
- // TODO: Get rid of the wrappers when modernizing redux is done
- const updateMetadataWrapper = (id: any, values: any) => {
- dispatch(updateMetadata({eventId: id, values}));
- }
- const updateExtendedMetadataWrapper = (id: any, values: any, catalog: any) => {
- dispatch(updateExtendedMetadata({eventId: id, values, catalog}));
- }
-
const page = useAppSelector(state => getModalPage(state));
const workflowTabHierarchy = useAppSelector(state => getModalWorkflowTabHierarchy(state));
const user = useAppSelector(state => getUserInformation(state));
@@ -233,7 +225,7 @@ const EventDetails = ({
metadataFields={metadata}
resourceId={eventId}
header={tabs[page].bodyHeaderTranslation ?? ""}
- updateResource={updateMetadataWrapper}
+ updateResource={updateMetadata}
editAccessRole="ROLE_UI_EVENTS_DETAILS_METADATA_EDIT"
/>
)}
@@ -241,7 +233,7 @@ const EventDetails = ({
)}
diff --git a/src/components/events/partials/modals/SeriesDetails.tsx b/src/components/events/partials/modals/SeriesDetails.tsx
index 3806492fff..4669f7f32d 100644
--- a/src/components/events/partials/modals/SeriesDetails.tsx
+++ b/src/components/events/partials/modals/SeriesDetails.tsx
@@ -28,12 +28,13 @@ import {
* This component manages the tabs of the series details modal
*/
const SeriesDetails = ({
-// @ts-expect-error TS(7031): Binding element 'seriesId' implicitly has an 'any'... Remove this comment to see the full error message
seriesId,
-// @ts-expect-error TS(7031): Binding element 'policyChanged' implicitly has an ... Remove this comment to see the full error message
policyChanged,
-// @ts-expect-error TS(7031): Binding element 'setPolicyChanged' implicitly has ... Remove this comment to see the full error message
setPolicyChanged,
+}: {
+ seriesId: string
+ policyChanged: boolean
+ setPolicyChanged: (policyChanged: boolean) => void
}) => {
const { t } = useTranslation();
const dispatch = useAppDispatch();
@@ -45,14 +46,6 @@ const SeriesDetails = ({
const themeNames = useAppSelector(state => getSeriesDetailsThemeNames(state));
const hasStatistics = useAppSelector(state => seriesHasStatistics(state));
- // TODO: Get rid of the wrappers when modernizing redux is done
- const updateSeriesMetadataWrapper = (id: any, values: any) => {
- dispatch(updateSeriesMetadata({id, values}));
- }
- const updateExtendedSeriesMetadataWrapper = (id: any, values: any, catalog: any) => {
- dispatch(updateExtendedSeriesMetadata({id, values, catalog}));
- }
-
useEffect(() => {
dispatch(fetchSeriesStatistics(seriesId));
// eslint-disable-next-line react-hooks/exhaustive-deps
@@ -96,8 +89,7 @@ const SeriesDetails = ({
},
];
-// @ts-expect-error TS(7006): Parameter 'tabNr' implicitly has an 'any' type.
- const openTab = (tabNr) => {
+ const openTab = (tabNr: number) => {
setPage(tabNr);
};
@@ -144,7 +136,7 @@ const SeriesDetails = ({
metadataFields={metadataFields}
resourceId={seriesId}
header={tabs[page].tabNameTranslation}
- updateResource={updateSeriesMetadataWrapper}
+ updateResource={updateSeriesMetadata}
editAccessRole="ROLE_UI_SERIES_DETAILS_METADATA_EDIT"
/>
)}
@@ -152,7 +144,7 @@ const SeriesDetails = ({
)}
diff --git a/src/components/events/partials/modals/SeriesDetailsModal.tsx b/src/components/events/partials/modals/SeriesDetailsModal.tsx
index d855284e28..d89621f03a 100644
--- a/src/components/events/partials/modals/SeriesDetailsModal.tsx
+++ b/src/components/events/partials/modals/SeriesDetailsModal.tsx
@@ -8,10 +8,14 @@ import { availableHotkeys } from "../../../../configs/hotkeysConfig";
* This component renders the modal for displaying series details
*/
const SeriesDetailsModal = ({
- handleClose,
- seriesTitle,
- seriesId
-}: any) => {
+ handleClose,
+ seriesTitle,
+ seriesId
+}: {
+ handleClose: () => void
+ seriesTitle: string
+ seriesId: string
+}) => {
const { t } = useTranslation();
// tracks, whether the policies are different to the initial value
@@ -50,7 +54,6 @@ const SeriesDetailsModal = ({
setPolicyChanged(value)}
/>
diff --git a/src/components/events/partials/modals/StartTaskModal.tsx b/src/components/events/partials/modals/StartTaskModal.tsx
index 4a24daf61b..ce559f1a30 100644
--- a/src/components/events/partials/modals/StartTaskModal.tsx
+++ b/src/components/events/partials/modals/StartTaskModal.tsx
@@ -13,18 +13,15 @@ import { checkValidityStartTaskEventSelection } from "../../../../utils/bulkActi
import { useHotkeys } from "react-hotkeys-hook";
import { availableHotkeys } from "../../../../configs/hotkeysConfig";
import { useAppDispatch } from "../../../../store";
-import { connect } from "react-redux";
+import { Event } from "../../../../slices/eventSlice";
/**
* This component manages the pages of the task start bulk action
*/
const StartTaskModal = ({
close,
- postTasks,
}: {
close: () => void,
- // @ts-expect-error
- postTasks,
}) => {
const { t } = useTranslation();
const dispatch = useAppDispatch();
@@ -63,11 +60,15 @@ const StartTaskModal = ({
},
];
-// @ts-expect-error TS(7006): Parameter 'values' implicitly has an 'any' type.
- const validateFormik = (values) => {
- const errors = {};
+ const validateFormik = (values: {
+ events: Event[],
+ workflow: string,
+ }) => {
+ const errors: {
+ events?: string,
+ workflow?: string,
+ } = {};
if (!checkValidityStartTaskEventSelection(values)) {
-// @ts-expect-error TS(2339): Property 'events' does not exist on type '{}'.
errors.events = "Not on all events task startable!";
}
if (
@@ -77,14 +78,12 @@ const StartTaskModal = ({
values.workflow !== ""
)
) {
-// @ts-expect-error TS(2339): Property 'worflow' does not exist on type '{}'.
errors.workflow = "Workflow not selected!";
}
return errors;
};
-// @ts-expect-error TS(7006): Parameter 'values' implicitly has an 'any' type.
- const handleSubmit = (values) => {
+ const handleSubmit = (values: typeof initialValues) => {
postTasks(values);
dispatch(changeAllSelected(false));
close();
@@ -155,10 +154,4 @@ const StartTaskModal = ({
);
};
-// @ts-expect-error TS(7006): Parameter 'dispatch' implicitly has an 'any' type.
-const mapDispatchToState = (dispatch) => ({
-// @ts-expect-error TS(7006): Parameter 'values' implicitly has an 'any' type.
- postTasks: (values) => dispatch(postTasks(values)),
-});
-
-export default connect(null, mapDispatchToState)(StartTaskModal);
+export default StartTaskModal;
diff --git a/src/components/events/partials/wizards/NewEventSummary.tsx b/src/components/events/partials/wizards/NewEventSummary.tsx
index 4c00f10635..48276f2ac5 100644
--- a/src/components/events/partials/wizards/NewEventSummary.tsx
+++ b/src/components/events/partials/wizards/NewEventSummary.tsx
@@ -97,6 +97,7 @@ const NewEventSummary = ({
{/*Summary metadata*/}
@@ -105,7 +106,9 @@ const NewEventSummary = ({
{!metaDataExtendedHidden ? (
diff --git a/src/components/events/partials/wizards/NewEventWizard.tsx b/src/components/events/partials/wizards/NewEventWizard.tsx
index 15568e7246..0c1fdd25f3 100644
--- a/src/components/events/partials/wizards/NewEventWizard.tsx
+++ b/src/components/events/partials/wizards/NewEventWizard.tsx
@@ -197,8 +197,11 @@ const NewEventWizard: React.FC<{
)}
{page === 5 && (
({
{/*Summary metadata*/}
@@ -55,7 +56,9 @@ const NewSeriesSummary = ({
{!metaDataExtendedHidden ? (
diff --git a/src/components/events/partials/wizards/NewSeriesWizard.tsx b/src/components/events/partials/wizards/NewSeriesWizard.tsx
index 976f4ec90a..ddcc4a8287 100644
--- a/src/components/events/partials/wizards/NewSeriesWizard.tsx
+++ b/src/components/events/partials/wizards/NewSeriesWizard.tsx
@@ -173,8 +173,11 @@ const NewSeriesWizard: React.FC<{
)}
{page === 2 && (
({
-{/* @ts-expect-error TS(7006): Parameter 'f' implicitly has an 'any' type. */}
{field.fieldset?.map((f, keys) => renderInputByType(f, keys, formik))}
)}
diff --git a/src/components/events/partials/wizards/summaryTables/AccessSummaryTable.tsx b/src/components/events/partials/wizards/summaryTables/AccessSummaryTable.tsx
index baeaea5253..7147f6769d 100644
--- a/src/components/events/partials/wizards/summaryTables/AccessSummaryTable.tsx
+++ b/src/components/events/partials/wizards/summaryTables/AccessSummaryTable.tsx
@@ -1,13 +1,17 @@
import React from "react";
import { useTranslation } from "react-i18next";
+import { TransformedAcl } from "../../../../../slices/aclDetailsSlice";
/**
* This component renders the access table containing access rules provided by user before in wizard summary pages
*/
const AccessSummaryTable = ({
- policies,
- header
-}: any) => {
+ policies,
+ header
+}: {
+ policies: TransformedAcl[]
+ header: string
+}) => {
const { t } = useTranslation();
return (
@@ -32,7 +36,6 @@ const AccessSummaryTable = ({
{/*Insert row for each policy user has provided*/}
-{/* @ts-expect-error TS(7006): Parameter 'policy' implicitly has an 'any' type. */}
{policies.map((policy, key) => (
{policy.role}
@@ -44,7 +47,6 @@ const AccessSummaryTable = ({
{/*repeat for each additional action*/}
-{/* @ts-expect-error TS(7006): Parameter 'action' implicitly has an 'any' type. */}
{policy.actions.map((action, key) => (
{action}
))}
diff --git a/src/components/events/partials/wizards/summaryTables/MetadataExtendedSummaryTable.tsx b/src/components/events/partials/wizards/summaryTables/MetadataExtendedSummaryTable.tsx
index 73f0efcb52..7ad11874b3 100644
--- a/src/components/events/partials/wizards/summaryTables/MetadataExtendedSummaryTable.tsx
+++ b/src/components/events/partials/wizards/summaryTables/MetadataExtendedSummaryTable.tsx
@@ -1,20 +1,22 @@
import React from "react";
import { useTranslation } from "react-i18next";
import { getMetadataCollectionFieldName } from "../../../../../utils/resourceUtils";
+import { MetadataCatalog } from "../../../../../slices/eventSlice";
/**
* This component renders the metadata extended table containing access rules provided by user
* before in wizard summary pages
*/
const MetadataExtendedSummaryTable = ({
-// @ts-expect-error TS(7031): Binding element 'extendedMetadata' implicitly has ... Remove this comment to see the full error message
extendedMetadata,
-// @ts-expect-error TS(7031): Binding element 'formikValues' implicitly has an '... Remove this comment to see the full error message
formikValues,
-// @ts-expect-error TS(7031): Binding element 'formikInitialValues' implicitly h... Remove this comment to see the full error message
formikInitialValues,
-// @ts-expect-error TS(7031): Binding element 'header' implicitly has an 'any' t... Remove this comment to see the full error message
header,
+}: {
+ extendedMetadata: MetadataCatalog[],
+ formikValues: { [key: string]: string | string[] | boolean },
+ formikInitialValues: { [key: string]: string | string[] | boolean },
+ header: string,
}) => {
const { t } = useTranslation();
@@ -22,8 +24,11 @@ const MetadataExtendedSummaryTable = ({
const catalogs = [];
for (const catalog of extendedMetadata) {
const metadataFields = catalog.fields;
-// @ts-expect-error TS(7034): Variable 'metadata' implicitly has type 'any[]' in... Remove this comment to see the full error message
- let metadata = [];
+ let metadata: {
+ name: string,
+ label: string,
+ value: unknown,
+ }[] = [];
for (let i = 0; metadataFields.length > i; i++) {
let fieldValue =
@@ -39,10 +44,10 @@ const MetadataExtendedSummaryTable = ({
}
if (!!fieldValue && fieldValue.length > 0) {
+ const collection = metadataFields[i].collection;
if (
metadataFields[i].type === "text" &&
- !!metadataFields[i].collection &&
- metadataFields[i].collection.length > 0
+ !!collection && collection.length > 0
) {
fieldValue = getMetadataCollectionFieldName(
metadataFields[i],
@@ -53,7 +58,6 @@ const MetadataExtendedSummaryTable = ({
);
}
-// @ts-expect-error TS(7005): Variable 'metadata' implicitly has an 'any[]' type... Remove this comment to see the full error message
metadata = metadata.concat({
name: catalog.flavor + "_" + metadataFields[i].id,
label: metadataFields[i].label,
diff --git a/src/components/events/partials/wizards/summaryTables/MetadataSummaryTable.tsx b/src/components/events/partials/wizards/summaryTables/MetadataSummaryTable.tsx
index a80744d59c..182baffdbf 100644
--- a/src/components/events/partials/wizards/summaryTables/MetadataSummaryTable.tsx
+++ b/src/components/events/partials/wizards/summaryTables/MetadataSummaryTable.tsx
@@ -1,27 +1,36 @@
import React from "react";
import { useTranslation } from "react-i18next";
import { getMetadataCollectionFieldName } from "../../../../../utils/resourceUtils";
+import { MetadataField } from "../../../../../slices/eventSlice";
/**
* This component renders the metadata table containing access rules provided by user before in wizard summary pages
*/
const MetadataSummaryTable = ({
- metadataFields,
- formikValues,
- header
-}: any) => {
+ metadataFields,
+ formikValues,
+ header
+}: {
+ metadataFields: MetadataField[],
+ formikValues: { [key: string]: string | string[] },
+ header: string,
+}) => {
const { t } = useTranslation();
// metadata that user has provided
-// @ts-expect-error TS(7034): Variable 'metadata' implicitly has type 'any[]' in... Remove this comment to see the full error message
- let metadata = [];
+ let metadata: {
+ name: string,
+ label: string,
+ value: unknown,
+ }[] = [];
for (let i = 0; metadataFields.length > i; i++) {
let fieldValue = formikValues[metadataFields[i].id];
if (!!fieldValue && fieldValue.length > 0) {
+ const collection = metadataFields[i].collection;
if (
metadataFields[i].type === "text" &&
- !!metadataFields[i].collection &&
- metadataFields[i].collection.length > 0
+ !!collection &&
+ collection.length > 0
) {
fieldValue = getMetadataCollectionFieldName(
metadataFields[i],
@@ -32,7 +41,6 @@ const MetadataSummaryTable = ({
)
}
-// @ts-expect-error TS(7005): Variable 'metadata' implicitly has an 'any[]' type... Remove this comment to see the full error message
metadata = metadata.concat({
name: metadataFields[i].id,
label: metadataFields[i].label,
diff --git a/src/components/recordings/Recordings.tsx b/src/components/recordings/Recordings.tsx
index c042d7f8c8..b030f0dce9 100644
--- a/src/components/recordings/Recordings.tsx
+++ b/src/components/recordings/Recordings.tsx
@@ -19,6 +19,8 @@ import { hasAccess } from "../../utils/utils";
import { getCurrentFilterResource } from "../../selectors/tableFilterSelectors";
import { useAppDispatch, useAppSelector } from "../../store";
import { fetchRecordings } from "../../slices/recordingSlice";
+import { AsyncThunk } from "@reduxjs/toolkit";
+import { AsyncThunkConfig } from "@reduxjs/toolkit/dist/createAsyncThunk";
/**
* This component renders the table view of recordings
@@ -32,10 +34,6 @@ const Recordings = () => {
const currentFilterType = useAppSelector(state => getCurrentFilterResource(state));
const recordings = useAppSelector(state => getTotalRecordings(state));
- const fetchRecordingsWrapper = () => {
- fetchRecordings(undefined)
- }
-
const loadRecordings = async () => {
// Fetching recordings from server
await dispatch(fetchRecordings(undefined));
@@ -88,7 +86,7 @@ const Recordings = () => {
{/* Include filters component */}
}
loadResourceIntoTable={loadRecordingsIntoTable}
resource={"recordings"}
/>
diff --git a/src/components/recordings/partials/RecordingsNameCell.tsx b/src/components/recordings/partials/RecordingsNameCell.tsx
index 12baa0c890..2b91e8e9db 100644
--- a/src/components/recordings/partials/RecordingsNameCell.tsx
+++ b/src/components/recordings/partials/RecordingsNameCell.tsx
@@ -18,8 +18,7 @@ const RecordingsNameCell = ({
const { t } = useTranslation();
const dispatch = useAppDispatch();
-// @ts-expect-error TS(7006): Parameter 'locationName' implicitly has an 'any' t... Remove this comment to see the full error message
- const redirectToEvents = async (locationName) => {
+ const redirectToEvents = async (locationName: string) => {
// redirect to tables
await dispatch(loadEventsIntoTable());
diff --git a/src/components/recordings/partials/modal/RecordingsDetails.tsx b/src/components/recordings/partials/modal/RecordingsDetails.tsx
index 5752e501c0..088a5a5eec 100644
--- a/src/components/recordings/partials/modal/RecordingsDetails.tsx
+++ b/src/components/recordings/partials/modal/RecordingsDetails.tsx
@@ -33,8 +33,7 @@ const RecordingsDetails: React.FC = () => {
},
];
-// @ts-expect-error TS(7006): Parameter 'tabNr' implicitly has an 'any' type.
- const openTab = (tabNr) => {
+ const openTab = (tabNr: number) => {
setPage(tabNr);
};
diff --git a/src/components/shared/EditTableViewModal.tsx b/src/components/shared/EditTableViewModal.tsx
index bba49d6c59..e6e9ac4c48 100644
--- a/src/components/shared/EditTableViewModal.tsx
+++ b/src/components/shared/EditTableViewModal.tsx
@@ -11,6 +11,7 @@ import { DragDropContext, Droppable, OnDragEndResponder, Draggable as Draggablee
import { availableHotkeys } from "../../configs/hotkeysConfig";
import { useHotkeys } from "react-hotkeys-hook";
import { useAppDispatch, useAppSelector } from "../../store";
+import { TableColumn } from "../../configs/tableConfigs/aclsTableConfig";
/**
* This component renders the modal for editing which columns are shown in the table
@@ -57,8 +58,7 @@ const EditTableViewModal = ({
};
// set deactivated property of column to true (deactivate = true) or false (deactivate = false) and move to corresponding list
-// @ts-expect-error TS(7006): Parameter 'column' implicitly has an 'any' type.
- const changeColumn = (column, deactivate) => {
+ const changeColumn = (column: TableColumn, deactivate: boolean) => {
if (deactivate) {
setActiveColumns(activeCols.filter((col) => col !== column));
column = { ...column, deactivated: deactivate };
@@ -86,14 +86,14 @@ const EditTableViewModal = ({
// change column order based on where column was dragged and dropped
const onDragEnd: OnDragEndResponder = (result) => {
- // dropped outside the list
- if (!result.destination) {
- return;
- }
-
- // @ts-expect-error TS(7006): Parameter 'columns' implicitly has an 'any' type.
- setActiveColumns((columns) => arrayMoveImmutable(columns, result.source.index, result.destination.index));
- }
+ // dropped outside the list
+ const destination = result.destination
+ if (destination === null) {
+ return;
+ }
+
+ setActiveColumns((columns) => arrayMoveImmutable(columns, result.source.index, destination.index));
+ }
return (
<>
diff --git a/src/components/shared/MainNav.tsx b/src/components/shared/MainNav.tsx
index 5c55220a37..67ee4ce1ad 100644
--- a/src/components/shared/MainNav.tsx
+++ b/src/components/shared/MainNav.tsx
@@ -39,10 +39,11 @@ import { Tooltip } from "./Tooltip";
* This component renders the main navigation that opens when the burger button is clicked
*/
const MainNav = ({
-// @ts-expect-error TS(7031): Binding element 'isOpen' implicitly has an 'any' t... Remove this comment to see the full error message
isOpen,
-// @ts-expect-error TS(7031): Binding element 'toggleMenu' implicitly has an 'an... Remove this comment to see the full error message
toggleMenu,
+}: {
+ isOpen: boolean,
+ toggleMenu: () => void,
}) => {
const { t } = useTranslation();
const dispatch = useAppDispatch();
diff --git a/src/components/shared/Stats.tsx b/src/components/shared/Stats.tsx
index 4ba24859ed..2266bba353 100644
--- a/src/components/shared/Stats.tsx
+++ b/src/components/shared/Stats.tsx
@@ -5,6 +5,7 @@ import {
editFilterValue,
resetFilterValues,
fetchStats,
+ Stats as StatsType,
} from "../../slices/tableFilterSlice";
import { loadEventsIntoTable } from "../../thunks/tableThunks";
import { useAppDispatch, useAppSelector } from "../../store";
@@ -21,11 +22,9 @@ const Stats = () => {
const stats = useAppSelector(state => getStats(state));
// Filter with value of clicked status
-// @ts-expect-error TS(7006): Parameter 'stats' implicitly has an 'any' type.
- const showStatsFilter = async (stats) => {
+ const showStatsFilter = async (stats: StatsType) => {
dispatch(resetFilterValues());
let filterValue;
-// @ts-expect-error TS(7006): Parameter 'f' implicitly has an 'any' type.
await stats.filters.forEach((f) => {
let filter = filterMap.find(({ name }) => name === f.name);
filterValue = f.value;
diff --git a/src/components/shared/Table.tsx b/src/components/shared/Table.tsx
index e7159b5bd9..91280305c9 100644
--- a/src/components/shared/Table.tsx
+++ b/src/components/shared/Table.tsx
@@ -16,6 +16,8 @@ import {
setOffset,
setSortBy,
updatePageSize,
+ Page,
+ Pagination,
} from "../../slices/tableSlice";
import {
changeAllSelected,
@@ -32,6 +34,7 @@ import sortUpIcon from "../../img/tbl-sort-up.png";
import sortDownIcon from "../../img/tbl-sort-down.png";
import Notifications from "./Notifications";
import { useAppDispatch, useAppSelector } from "../../store";
+import { TableColumn } from "../../configs/tableConfigs/aclsTableConfig";
const SortIcon = styled.i`
float: right;
@@ -50,18 +53,23 @@ const SortActiveIcon = styled.i<{order: string}>`
left: auto;
width: 8px;
height: 13px;
- background-image: url(${(props: any) =>
+ background-image: url(${(props: { order: string }) =>
props.order === "ASC" ? sortUpIcon : sortDownIcon})};
`;
-const containerPageSize = React.createRef();
+const containerPageSize = React.createRef();
+
+type TemplateMap = {
+ [key: string]: ({ row }: { row: any }) => JSX.Element | JSX.Element[]
+}
/**
* This component renders the table in the table views of resources
*/
const Table = ({
-// @ts-expect-error TS(7031): Binding element 'templateMap' implicitly has an 'a... Remove this comment to see the full error message
templateMap,
+}: {
+ templateMap: TemplateMap
}) => {
const dispatch = useAppDispatch();
@@ -97,12 +105,9 @@ const Table = ({
useEffect(() => {
// Function for handling clicks outside of an open dropdown menu
-// @ts-expect-error TS(7006): Parameter 'e' implicitly has an 'any' type.
- const handleClickOutside = (e) => {
+ const handleClickOutside = (e: any) => {
if (
- containerPageSize.current &&
-// @ts-expect-error TS(2571): Object is of type 'unknown'.
- !containerPageSize.current.contains(e.target)
+ e && containerPageSize.current && !containerPageSize.current.contains(e.target)
) {
setShowPageSizes(false);
}
@@ -117,14 +122,12 @@ const Table = ({
});
// Select or deselect all rows on a page
-// @ts-expect-error TS(7006): Parameter 'e' implicitly has an 'any' type.
- const onChangeAllSelected = (e) => {
+ const onChangeAllSelected = (e: React.ChangeEvent) => {
const selected = e.target.checked;
dispatch(changeAllSelected(selected));
};
-// @ts-expect-error TS(7006): Parameter 'size' implicitly has an 'any' type.
- const changePageSize = (size) => {
+ const changePageSize = (size: number) => {
dispatch(updatePageSize(size));
dispatch(setOffset(0));
dispatch(updatePages());
@@ -302,7 +305,6 @@ const Table = ({
setShowPageSizes(!showPageSizes)}
-// @ts-expect-error TS(2322): Type 'RefObject' is not assignable to typ... Remove this comment to see the full error message
ref={containerPageSize}
>
{pagination.limit}
@@ -356,8 +358,8 @@ const Table = ({
};
// get all pages directly accessible from current page
-// @ts-expect-error TS(7006): Parameter 'pages' implicitly has an 'any' type.
-const getDirectAccessiblePages = (pages, pagination) => {
+
+const getDirectAccessiblePages = (pages: Page[], pagination: Pagination) => {
let startIndex = pagination.offset - pagination.directAccessibleNo,
endIndex = pagination.offset + pagination.directAccessibleNo,
directAccessible = [],
@@ -407,8 +409,10 @@ const getDirectAccessiblePages = (pages, pagination) => {
};
// Apply a column template and render corresponding components
-// @ts-expect-error TS(7031): Binding element 'row' implicitly has an 'any' type... Remove this comment to see the full error message
-const ColumnTemplate = ({ row, column, templateMap }) => {
+const ColumnTemplate = ({ row, column, templateMap }: {row: Row, column: TableColumn, templateMap: any}) => {
+ if (!column.template) {
+ return <>>;
+ }
let Template = templateMap[column.template];
return ;
};
diff --git a/src/components/shared/TableFilterProfiles.tsx b/src/components/shared/TableFilterProfiles.tsx
index 2468832f9f..3c775d502e 100644
--- a/src/components/shared/TableFilterProfiles.tsx
+++ b/src/components/shared/TableFilterProfiles.tsx
@@ -11,11 +11,13 @@ import {
goToPage,
} from "../../thunks/tableThunks";
import { getFilters } from "../../selectors/tableFilterSelectors";
-import { loadFilterProfile } from "../../slices/tableFilterSlice";
+import { FilterData, loadFilterProfile } from "../../slices/tableFilterSlice";
import { AppThunk, useAppDispatch, useAppSelector } from "../../store";
import { useHotkeys } from "react-hotkeys-hook";
import { availableHotkeys } from "../../configs/hotkeysConfig";
import { Tooltip } from "./Tooltip";
+import { AsyncThunk } from "@reduxjs/toolkit";
+import { AsyncThunkConfig } from "@reduxjs/toolkit/dist/createAsyncThunk";
/**
* This component renders the table filter profiles in the upper right corner when clicked on settings icon of the
@@ -30,8 +32,7 @@ const TableFiltersProfiles = ({
}: {
showFilterSettings: boolean,
setFilterSettings: (_: boolean) => void,
- // TODO: Figure out proper typings
- loadResource: any,
+ loadResource: AsyncThunk,
loadResourceIntoTable: () => AppThunk,
resource: string,
}) => {
@@ -77,8 +78,7 @@ const TableFiltersProfiles = ({
resetStateValues();
};
-// @ts-expect-error TS(7006): Parameter 'profile' implicitly has an 'any' type.
- const editFilterProfile = (profile) => {
+ const editFilterProfile = (profile: FilterProfile) => {
setSettingsMode(false);
setCurrentlyEditing(profile);
setProfileName(profile.name);
@@ -110,8 +110,7 @@ const TableFiltersProfiles = ({
setValidName(false);
};
-// @ts-expect-error TS(7006): Parameter 'e' implicitly has an 'any' type.
- const handleChange = (e) => {
+ const handleChange = (e: React.ChangeEvent) => {
const itemName = e.target.name;
const itemValue = e.target.value;
@@ -131,8 +130,7 @@ const TableFiltersProfiles = ({
}
};
-// @ts-expect-error TS(7006): Parameter 'filterMap' implicitly has an 'any' type... Remove this comment to see the full error message
- const chooseFilterProfile = (filterMap) => {
+ const chooseFilterProfile = (filterMap: FilterData[]) => {
dispatch(loadFilterProfile(filterMap));
// No matter what, we go to page one.
diff --git a/src/components/shared/TableFilters.tsx b/src/components/shared/TableFilters.tsx
index 096c7d81b2..b312b95384 100644
--- a/src/components/shared/TableFilters.tsx
+++ b/src/components/shared/TableFilters.tsx
@@ -28,6 +28,8 @@ import { AppThunk, useAppDispatch, useAppSelector } from "../../store";
import { renderValidDate } from "../../utils/dateUtils";
import { Tooltip } from "./Tooltip";
import DropDown from "./DropDown";
+import { AsyncThunk } from "@reduxjs/toolkit";
+import { AsyncThunkConfig } from "@reduxjs/toolkit/dist/createAsyncThunk";
/**
* This component renders the table filters in the upper right corner of the table
@@ -37,8 +39,7 @@ const TableFilters = ({
loadResourceIntoTable,
resource,
}: {
- // TODO: Figure out proper typings
- loadResource: any, // (() => AppThunk ) | AsyncThunkAction
+ loadResource: AsyncThunk,
loadResourceIntoTable: () => AppThunk,
resource: string,
}) => {
@@ -81,8 +82,7 @@ const TableFilters = ({
};
// Remove a certain filter
-// @ts-expect-error TS(7006): Parameter 'filter' implicitly has an 'any' type.
- const removeFilter = async (filter) => {
+ const removeFilter = async (filter: FilterData) => {
if (filter.name === "startDate") {
// Clear state
setStartDate(undefined);
@@ -97,8 +97,7 @@ const TableFilters = ({
};
// Handle changes when an item of the component is changed
- // @ts-expect-error TS(7006): Parameter 'e' implicitly has an 'any' type.
- const handleChange = (name, value) => {
+ const handleChange = (name: string, value: string) => {
let mustApplyChanges = false;
if (name === "textFilter") {
dispatch(editTextFilter(value));
@@ -229,9 +228,7 @@ const TableFilters = ({
[removeFilters]
);
-// @ts-expect-error TS(7006): Parameter 'filter' implicitly has an 'any' type.
- const renderBlueBox = (filter) => {
-// @ts-expect-error TS(7006): Parameter 'opt' implicitly has an 'any' type.
+ const renderBlueBox = (filter: FilterData) => {
let valueLabel = filter.options?.find((opt) => opt.value === filter.value)
?.label || filter.value;
return (
diff --git a/src/components/shared/TimeSeriesStatistics.tsx b/src/components/shared/TimeSeriesStatistics.tsx
index d900a9450e..5b72053a3a 100644
--- a/src/components/shared/TimeSeriesStatistics.tsx
+++ b/src/components/shared/TimeSeriesStatistics.tsx
@@ -2,7 +2,7 @@ import React from "react";
import moment from "moment";
import { getCurrentLanguageInformation } from "../../utils/utils";
import { DatePicker } from "@mui/x-date-pickers/DatePicker";
-import { Formik } from "formik";
+import { Formik, FormikErrors } from "formik";
import { Field } from "./Field";
import BarChart from "./BarChart";
import {
@@ -13,44 +13,48 @@ import {
} from "../../configs/statisticsConfig";
import { localizedMoment } from "../../utils/dateUtils";
import { parseISO } from "date-fns";
+import { useTranslation } from "react-i18next";
+import type { ChartDataset, ChartOptions } from 'chart.js';
+
/**
* This component visualizes statistics with data of type time series
*/
const TimeSeriesStatistics = ({
-// @ts-expect-error TS(7031): Binding element 't' implicitly has an 'any' type.
- t,
-// @ts-expect-error TS(7031): Binding element 'resourceId' implicitly has an 'an... Remove this comment to see the full error message
resourceId,
-// @ts-expect-error TS(7031): Binding element 'statTitle' implicitly has an 'any... Remove this comment to see the full error message
statTitle,
-// @ts-expect-error TS(7031): Binding element 'providerId' implicitly has an 'an... Remove this comment to see the full error message
providerId,
-// @ts-expect-error TS(7031): Binding element 'fromDate' implicitly has an 'any'... Remove this comment to see the full error message
fromDate,
-// @ts-expect-error TS(7031): Binding element 'toDate' implicitly has an 'any' t... Remove this comment to see the full error message
toDate,
-// @ts-expect-error TS(7031): Binding element 'timeMode' implicitly has an 'any'... Remove this comment to see the full error message
timeMode,
-// @ts-expect-error TS(7031): Binding element 'dataResolution' implicitly has an... Remove this comment to see the full error message
dataResolution,
-// @ts-expect-error TS(7031): Binding element 'statDescription' implicitly has a... Remove this comment to see the full error message
statDescription,
-// @ts-expect-error TS(7031): Binding element 'onChange' implicitly has an 'any'... Remove this comment to see the full error message
onChange,
-// @ts-expect-error TS(7031): Binding element 'exportUrl' implicitly has an 'any... Remove this comment to see the full error message
exportUrl,
-// @ts-expect-error TS(7031): Binding element 'exportFileName' implicitly has an... Remove this comment to see the full error message
exportFileName,
-// @ts-expect-error TS(7031): Binding element 'totalValue' implicitly has an 'an... Remove this comment to see the full error message
totalValue,
-// @ts-expect-error TS(7031): Binding element 'sourceData' implicitly has an 'an... Remove this comment to see the full error message
sourceData,
-// @ts-expect-error TS(7031): Binding element 'chartLabels' implicitly has an 'a... Remove this comment to see the full error message
chartLabels,
-// @ts-expect-error TS(7031): Binding element 'chartOptions' implicitly has an '... Remove this comment to see the full error message
chartOptions,
+}: {
+ resourceId: string,
+ statTitle: string,
+ providerId: string,
+ fromDate: string,
+ toDate: string,
+ timeMode: any, // startOf | "custom" ???
+ dataResolution: string[],
+ statDescription: string,
+ onChange: (id: any, providerId: any, from: any, to: any, dataResolution: any, timeMode: any) => void,
+ exportUrl: string,
+ exportFileName: (statsTitle: string) => string,
+ totalValue: string,
+ sourceData: ChartDataset<'bar'>,
+ chartLabels: string[],
+ chartOptions: ChartOptions<'bar'>,
}) => {
+ const { t } = useTranslation();
+
// Style for radio buttons
const radioButtonStyle = {
backgroundColor: "whitesmoke",
@@ -74,16 +78,19 @@ const TimeSeriesStatistics = ({
const currentLanguage = getCurrentLanguageInformation();
// change formik values and get new statistic values from API
-// @ts-expect-error TS(7006): Parameter 'setFormikValue' implicitly has an 'any'... Remove this comment to see the full error message
- const change = (setFormikValue, timeMode, from, to, dataResolution) => {
+ const change = (
+ setFormikValue: (field: string, value: any) => Promise>,
+ timeMode: string,
+ from: Date | string,
+ to: Date | string,
+ dataResolution: unknown
+ ) => {
if (timeMode === "year" || timeMode === "month") {
from = moment(from).clone().startOf(timeMode).format("YYYY-MM-DD");
to = moment(from).clone().endOf(timeMode).format("YYYY-MM-DD");
- setFormikValue("fromDate", from);
+ setFormikValue("fromDat0e", from);
setFormikValue("toDate", to);
-// @ts-expect-error TS(7053): Element implicitly has an 'any' type because expre... Remove this comment to see the full error message
setFormikValue("dataResolution", fixedDataResolutions[timeMode]);
-// @ts-expect-error TS(7053): Element implicitly has an 'any' type because expre... Remove this comment to see the full error message
dataResolution = fixedDataResolutions[timeMode];
}
@@ -92,16 +99,11 @@ const TimeSeriesStatistics = ({
// change time mode in formik and get new values from API
const changeTimeMode = async (
-// @ts-expect-error TS(7006): Parameter 'newTimeMode' implicitly has an 'any' ty... Remove this comment to see the full error message
- newTimeMode,
-// @ts-expect-error TS(7006): Parameter 'setFormikValue' implicitly has an 'any'... Remove this comment to see the full error message
- setFormikValue,
-// @ts-expect-error TS(7006): Parameter 'from' implicitly has an 'any' type.
- from,
-// @ts-expect-error TS(7006): Parameter 'to' implicitly has an 'any' type.
- to,
-// @ts-expect-error TS(7006): Parameter 'dataResolution' implicitly has an 'any'... Remove this comment to see the full error message
- dataResolution
+ newTimeMode: string,
+ setFormikValue: (field: string, value: any) => Promise>,
+ from: Date | string,
+ to: Date | string,
+ dataResolution: unknown
) => {
setFormikValue("timeMode", newTimeMode);
change(setFormikValue, newTimeMode, from, to, dataResolution);
@@ -109,16 +111,11 @@ const TimeSeriesStatistics = ({
// change custom from date in formik and get new values from API
const changeFrom = async (
-// @ts-expect-error TS(7006): Parameter 'newFrom' implicitly has an 'any' type.
- newFrom,
-// @ts-expect-error TS(7006): Parameter 'setFormikValue' implicitly has an 'any'... Remove this comment to see the full error message
- setFormikValue,
-// @ts-expect-error TS(7006): Parameter 'timeMode' implicitly has an 'any' type.
- timeMode,
-// @ts-expect-error TS(7006): Parameter 'to' implicitly has an 'any' type.
- to,
-// @ts-expect-error TS(7006): Parameter 'dataResolution' implicitly has an 'any'... Remove this comment to see the full error message
- dataResolution
+ newFrom: Date,
+ setFormikValue: (field: string, value: any) => Promise>,
+ timeMode: string,
+ to: Date | string,
+ dataResolution: unknown,
) => {
setFormikValue("fromDate", newFrom);
change(setFormikValue, timeMode, newFrom, to, dataResolution);
@@ -126,16 +123,11 @@ const TimeSeriesStatistics = ({
// change custom to date in formik and get new values from API
const changeTo = async (
-// @ts-expect-error TS(7006): Parameter 'newTo' implicitly has an 'any' type.
- newTo,
-// @ts-expect-error TS(7006): Parameter 'setFormikValue' implicitly has an 'any'... Remove this comment to see the full error message
- setFormikValue,
-// @ts-expect-error TS(7006): Parameter 'timeMode' implicitly has an 'any' type.
- timeMode,
-// @ts-expect-error TS(7006): Parameter 'from' implicitly has an 'any' type.
- from,
-// @ts-expect-error TS(7006): Parameter 'dataResolution' implicitly has an 'any'... Remove this comment to see the full error message
- dataResolution
+ newTo: Date,
+ setFormikValue: (field: string, value: any) => Promise>,
+ timeMode: string,
+ from: Date | string,
+ dataResolution: unknown
) => {
setFormikValue("toDate", newTo);
change(setFormikValue, timeMode, from, newTo, dataResolution);
@@ -143,33 +135,33 @@ const TimeSeriesStatistics = ({
// change custom time granularity in formik and get new values from API
const changeGranularity = async (
-// @ts-expect-error TS(7006): Parameter 'granularity' implicitly has an 'any' ty... Remove this comment to see the full error message
- granularity,
-// @ts-expect-error TS(7006): Parameter 'setFormikValue' implicitly has an 'any'... Remove this comment to see the full error message
- setFormikValue,
-// @ts-expect-error TS(7006): Parameter 'timeMode' implicitly has an 'any' type.
- timeMode,
-// @ts-expect-error TS(7006): Parameter 'from' implicitly has an 'any' type.
- from,
-// @ts-expect-error TS(7006): Parameter 'to' implicitly has an 'any' type.
- to
+ granularity: unknown,
+ setFormikValue: (field: string, value: any) => Promise>,
+ timeMode: string,
+ from: Date | string,
+ to: Date | string,
) => {
setFormikValue("dataResolution", granularity);
change(setFormikValue, timeMode, from, to, granularity);
};
// format selected time to display as name of timeframe
-// @ts-expect-error TS(7006): Parameter 'from' implicitly has an 'any' type.
- const formatSelectedTimeframeName = (from, timeMode) => {
+ const formatSelectedTimeframeName = (
+ from: string,
+ timeMode: keyof typeof formatStrings
+ ) => {
return localizedMoment(from, currentLanguage ? currentLanguage.dateLocale.code : "en").format(
-// @ts-expect-error TS(7053): Element implicitly has an 'any' type because expre... Remove this comment to see the full error message
formatStrings[timeMode]
);
};
// change to and from dates in formik to previous timeframe and get new values from API
-// @ts-expect-error TS(7006): Parameter 'setFormikValue' implicitly has an 'any'... Remove this comment to see the full error message
- const selectPrevious = (setFormikValue, from, timeMode, dataResolution) => {
+ const selectPrevious = (
+ setFormikValue: (field: string, value: any) => Promise>,
+ from: string,
+ timeMode: keyof typeof formatStrings,
+ dataResolution: unknown,
+ ) => {
const newFrom = moment(from)
// @ts-expect-error TS(2769): No overload matches this call.
.subtract(1, timeMode + "s")
@@ -179,8 +171,12 @@ const TimeSeriesStatistics = ({
};
// change to and from dates in formik to next timeframe and get new values from API
-// @ts-expect-error TS(7006): Parameter 'setFormikValue' implicitly has an 'any'... Remove this comment to see the full error message
- const selectNext = (setFormikValue, from, timeMode, dataResolution) => {
+ const selectNext = (
+ setFormikValue: (field: string, value: any) => Promise>,
+ from: string,
+ timeMode: keyof typeof formatStrings,
+ dataResolution: unknown,
+ ) => {
const newFrom = moment(from)
// @ts-expect-error TS(2769): No overload matches this call.
.add(1, timeMode + "s")
@@ -306,15 +302,17 @@ const TimeSeriesStatistics = ({
slotProps={{ textField: { placeholder: t(
"EVENTS.EVENTS.NEW.SOURCE.PLACEHOLDER.START_DATE"
) } }}
- onChange={(value) =>
- changeFrom(
- value,
- formik.setFieldValue,
- formik.values.timeMode,
- formik.values.toDate,
- formik.values.dataResolution
- )
- }
+ onChange={(value) => {
+ if (value) {
+ changeFrom(
+ value,
+ formik.setFieldValue,
+ formik.values.timeMode,
+ formik.values.toDate,
+ formik.values.dataResolution
+ )
+ }
+ }}
/>