diff --git a/src/components/configuration/partials/ThemesActionsCell.tsx b/src/components/configuration/partials/ThemesActionsCell.tsx index e42bc9705a..87925b8fb9 100644 --- a/src/components/configuration/partials/ThemesActionsCell.tsx +++ b/src/components/configuration/partials/ThemesActionsCell.tsx @@ -9,15 +9,16 @@ import { import { getUserInformation } from "../../../selectors/userInfoSelectors"; import { hasAccess } from "../../../utils/utils"; import { useAppDispatch, useAppSelector } from "../../../store"; -import { deleteTheme } from "../../../slices/themeSlice"; +import { deleteTheme, ThemeDetailsType } from "../../../slices/themeSlice"; import { Tooltip } from "../../shared/Tooltip"; /** * This component renders the action cells of themes in the table view */ const ThemesActionsCell = ({ -// @ts-expect-error TS(7031): Binding element 'row' implicitly has an 'any' type... Remove this comment to see the full error message row, +}: { + row: ThemeDetailsType }) => { const { t } = useTranslation(); const dispatch = useAppDispatch(); @@ -61,7 +62,6 @@ const ThemesActionsCell = ({ {displayThemeDetails && ( )} diff --git a/src/components/configuration/partials/wizard/NewThemeWizard.tsx b/src/components/configuration/partials/wizard/NewThemeWizard.tsx index bfa72db1ae..7672ae5665 100644 --- a/src/components/configuration/partials/wizard/NewThemeWizard.tsx +++ b/src/components/configuration/partials/wizard/NewThemeWizard.tsx @@ -10,7 +10,7 @@ import { initialFormValuesNewThemes } from "../../../../configs/modalConfig"; import { usePageFunctions } from "../../../../hooks/wizardHooks"; import { NewThemeSchema } from "../../../../utils/validate"; import { useAppDispatch } from "../../../../store"; -import { postNewTheme } from "../../../../slices/themeSlice"; +import { postNewTheme, ThemeDetailsInitialValues } from "../../../../slices/themeSlice"; /** * This component manages the pages of the new theme wizard and the submission of values @@ -64,7 +64,7 @@ const NewThemeWizard: React.FC<{ // Validation schema of current page const currentValidationSchema = NewThemeSchema[page]; - const handleSubmit = (values: any) => { + const handleSubmit = (values: ThemeDetailsInitialValues) => { dispatch(postNewTheme(values)); close(); }; diff --git a/src/components/configuration/partials/wizard/ThemeDetails.tsx b/src/components/configuration/partials/wizard/ThemeDetails.tsx index a8528cbca1..36ca83a8c6 100644 --- a/src/components/configuration/partials/wizard/ThemeDetails.tsx +++ b/src/components/configuration/partials/wizard/ThemeDetails.tsx @@ -15,7 +15,7 @@ import ModalNavigation from "../../../shared/modals/ModalNavigation"; import { NewThemeSchema } from "../../../../utils/validate"; import { useAppDispatch, useAppSelector } from "../../../../store"; import { updateThemeDetails } from "../../../../slices/themeDetailsSlice"; -import { ThemeDetailsType } from "../../../../slices/themeSlice"; +import { ThemeDetailsInitialValues } from "../../../../slices/themeSlice"; /** * This component manages the pages of the theme details @@ -86,7 +86,7 @@ const ThemeDetails : React.FC<{ const currentValidationSchema = NewThemeSchema[page]; // update theme - const handleSubmit = (values: ThemeDetailsType) => { + const handleSubmit = (values: ThemeDetailsInitialValues) => { dispatch(updateThemeDetails({id: themeDetails.id, values: values})); close(); }; diff --git a/src/components/configuration/partials/wizard/ThemeDetailsModal.tsx b/src/components/configuration/partials/wizard/ThemeDetailsModal.tsx index db8d9ca570..fe3e4a242e 100644 --- a/src/components/configuration/partials/wizard/ThemeDetailsModal.tsx +++ b/src/components/configuration/partials/wizard/ThemeDetailsModal.tsx @@ -6,10 +6,12 @@ import ThemeDetails from "./ThemeDetails"; * This component renders the modal for displaying theme details */ const ThemeDetailsModal = ({ - handleClose, - themeId, - themeName -}: any) => { + handleClose, + themeName +}: { + handleClose: () => void, + themeName: string +}) => { const { t } = useTranslation(); const close = () => { diff --git a/src/components/configuration/partials/wizard/WatermarkPage.tsx b/src/components/configuration/partials/wizard/WatermarkPage.tsx index db9efd0934..91d6f52a14 100644 --- a/src/components/configuration/partials/wizard/WatermarkPage.tsx +++ b/src/components/configuration/partials/wizard/WatermarkPage.tsx @@ -31,8 +31,7 @@ const WatermarkPage = ({ }) => { const { t } = useTranslation(); -// @ts-expect-error TS(7006): Parameter 'position' implicitly has an 'any' type. - const handleButtonClick = (position) => { + const handleButtonClick = (position: "topLeft" | "topRight" | "bottomLeft" | "bottomRight") => { formik.setFieldValue("watermarkPosition", position); }; diff --git a/src/components/events/partials/EventActionCell.tsx b/src/components/events/partials/EventActionCell.tsx index 0f0461dc44..0654b63cf2 100644 --- a/src/components/events/partials/EventActionCell.tsx +++ b/src/components/events/partials/EventActionCell.tsx @@ -39,8 +39,7 @@ const EventActionCell = ({ setDeleteConfirmation(false); }; -// @ts-expect-error TS(7006): Parameter 'id' implicitly has an 'any' type. - const deletingEvent = (id) => { + const deletingEvent = (id: string) => { dispatch(deleteEvent(id)); }; diff --git a/src/components/events/partials/EventsNotesCell.tsx b/src/components/events/partials/EventsNotesCell.tsx index 406cf5a180..3238f114dc 100644 --- a/src/components/events/partials/EventsNotesCell.tsx +++ b/src/components/events/partials/EventsNotesCell.tsx @@ -36,14 +36,14 @@ const EventsNotesCell = ({ }); } - const updateComment = (event: React.ChangeEvent, commentId: any) => { + const updateComment = (event: React.ChangeEvent, commentId: number) => { if (!event.target.value || !row.id || !commentId) { return; } dispatch(updateNewComment({eventId: row.id, commentId, commentText: event.target.value, commentReason: notesCommentReason})) } - const deleteComment = (event: React.FocusEvent, commentId: any) => { + const deleteComment = (event: React.FocusEvent, commentId: number) => { if (!row.id || !commentId) { return; } diff --git a/src/components/events/partials/EventsSeriesCell.tsx b/src/components/events/partials/EventsSeriesCell.tsx index ab7f437ef8..b946c17052 100644 --- a/src/components/events/partials/EventsSeriesCell.tsx +++ b/src/components/events/partials/EventsSeriesCell.tsx @@ -22,28 +22,31 @@ const EventsSeriesCell = ({ const filterMap = useAppSelector(state => getFilters(state)); // Filter with value of current cell -// @ts-expect-error TS(7006): Parameter 'series' implicitly has an 'any' type. - const addFilter = async (series) => { + const addFilter = async (seriesId: string) => { let filter = filterMap.find(({ name }) => name === "series"); if (!!filter) { - await dispatch(editFilterValue({filterName: filter.name, value: series.id})); + await dispatch(editFilterValue({filterName: filter.name, value: seriesId})); await dispatch(fetchEvents()); dispatch(loadEventsIntoTable()); } }; return ( - !!row.series && ( + !!row.series ? ( // Link template for series of event ) + : <> ); }; diff --git a/src/components/events/partials/EventsTechnicalDateCell.tsx b/src/components/events/partials/EventsTechnicalDateCell.tsx index bd38889305..2ac4b3132e 100644 --- a/src/components/events/partials/EventsTechnicalDateCell.tsx +++ b/src/components/events/partials/EventsTechnicalDateCell.tsx @@ -37,8 +37,7 @@ const EventsTechnicalDateCell = ({ diff --git a/src/components/events/partials/ModalTabsAndPages/DetailsExtendedMetadataTab.tsx b/src/components/events/partials/ModalTabsAndPages/DetailsExtendedMetadataTab.tsx index 73e84275bb..5a54353fde 100644 --- a/src/components/events/partials/ModalTabsAndPages/DetailsExtendedMetadataTab.tsx +++ b/src/components/events/partials/ModalTabsAndPages/DetailsExtendedMetadataTab.tsx @@ -1,6 +1,6 @@ import React from "react"; import { useTranslation } from "react-i18next"; -import { Formik } from "formik"; +import { Formik, FormikProps } from "formik"; import { Field } from "../../../shared/Field"; import cn from "classnames"; import _ from "lodash"; @@ -13,8 +13,10 @@ import { parseValueForBooleanStrings, } from "../../../../utils/utils"; import { getMetadataCollectionFieldName } from "../../../../utils/resourceUtils"; -import { useAppSelector } from "../../../../store"; +import { useAppDispatch, useAppSelector } from "../../../../store"; import { MetadataCatalog } from "../../../../slices/eventSlice"; +import { AsyncThunk } from "@reduxjs/toolkit"; +import { AsyncThunkConfig } from "@reduxjs/toolkit/dist/createAsyncThunk"; /** * This component renders metadata details of a certain event or series @@ -28,25 +30,29 @@ const DetailsExtendedMetadataTab = ({ resourceId: string, editAccessRole: string, metadata: MetadataCatalog[], - updateResource: (id: string, values: { [key: string]: any }, catalog: MetadataCatalog) => void, + updateResource: AsyncThunk //(id: string, values: { [key: string]: any }, catalog: MetadataCatalog) => void, }) => { const { t } = useTranslation(); + const dispatch = useAppDispatch(); const user = useAppSelector(state => getUserInformation(state)); const handleSubmit = (values: { [key: string]: any }, catalog: MetadataCatalog) => { - updateResource(resourceId, values, catalog); + dispatch(updateResource({id: resourceId, values, catalog})); }; // set current values of metadata fields as initial values const getInitialValues = (metadataCatalog: MetadataCatalog) => { - let initialValues = {}; + let initialValues: { [key: string]: any } = {}; // Transform metadata fields and their values provided by backend (saved in redux) if (!!metadataCatalog.fields && metadataCatalog.fields.length > 0) { metadataCatalog.fields.forEach((field) => { let value = parseValueForBooleanStrings(field.value); -// @ts-expect-error TS(7053): Element implicitly has an 'any' type because expre... Remove this comment to see the full error message initialValues[field.id] = value; }); } @@ -54,8 +60,7 @@ const DetailsExtendedMetadataTab = ({ return initialValues; }; -// @ts-expect-error TS(7006): Parameter 'formik' implicitly has an 'any' type. - const checkValidity = (formik) => { + const checkValidity = (formik: FormikProps<{}>) => { if (formik.dirty && formik.isValid && hasAccess(editAccessRole, user)) { // check if user provided values differ from initial ones return !_.isEqual(formik.values, formik.initialValues); @@ -154,7 +159,7 @@ const DetailsExtendedMetadataTab = ({ diff --git a/src/components/events/partials/ModalTabsAndPages/DetailsMetadataTab.tsx b/src/components/events/partials/ModalTabsAndPages/DetailsMetadataTab.tsx index 39c3ffd502..179f2abd10 100644 --- a/src/components/events/partials/ModalTabsAndPages/DetailsMetadataTab.tsx +++ b/src/components/events/partials/ModalTabsAndPages/DetailsMetadataTab.tsx @@ -1,6 +1,6 @@ import React from "react"; import { useTranslation } from "react-i18next"; -import { Formik } from "formik"; +import { Formik, FormikProps } from "formik"; import { Field } from "../../../shared/Field"; import cn from "classnames"; import _ from "lodash"; @@ -11,8 +11,10 @@ import RenderField from "../../../shared/wizard/RenderField"; import { getUserInformation } from "../../../../selectors/userInfoSelectors"; import { hasAccess } from "../../../../utils/utils"; import { getMetadataCollectionFieldName } from "../../../../utils/resourceUtils"; -import { useAppSelector } from "../../../../store"; +import { useAppDispatch, useAppSelector } from "../../../../store"; import { MetadataCatalog } from "../../../../slices/eventSlice"; +import { AsyncThunk } from "@reduxjs/toolkit"; +import { AsyncThunkConfig } from "@reduxjs/toolkit/dist/createAsyncThunk"; /** * This component renders metadata details of a certain event or series @@ -25,22 +27,23 @@ const DetailsMetadataTab = ({ editAccessRole, }: { metadataFields: MetadataCatalog, - updateResource: (id: string, values: { [key: string]: any }) => void, + updateResource: AsyncThunk resourceId: string, header: string, editAccessRole: string, }) => { const { t } = useTranslation(); + const dispatch = useAppDispatch(); const user = useAppSelector(state => getUserInformation(state)); const handleSubmit = (values: { [key: string]: any }) => { - updateResource(resourceId, values); + dispatch(updateResource({id: resourceId, values})); }; // set current values of metadata fields as initial values const getInitialValues = () => { - let initialValues = {}; + let initialValues: { [key: string]: string | string[] } = {}; // Transform metadata fields and their values provided by backend (saved in redux) if ( @@ -49,7 +52,6 @@ const DetailsMetadataTab = ({ metadataFields.fields.length > 0 ) { metadataFields.fields.forEach((field) => { -// @ts-expect-error TS(7053): Element implicitly has an 'any' type because expre... Remove this comment to see the full error message initialValues[field.id] = field.value; }); } @@ -57,8 +59,7 @@ const DetailsMetadataTab = ({ return initialValues; }; -// @ts-expect-error TS(7006): Parameter 'formik' implicitly has an 'any' type. - const checkValidity = (formik) => { + const checkValidity = (formik: FormikProps<{ [key: string]: string | string[] }>) => { if (formik.dirty && formik.isValid && hasAccess(editAccessRole, user)) { // check if user provided values differ from initial ones return !_.isEqual(formik.values, formik.initialValues); @@ -152,7 +153,7 @@ const DetailsMetadataTab = ({ diff --git a/src/components/events/partials/ModalTabsAndPages/EditScheduledEventsEditPage.tsx b/src/components/events/partials/ModalTabsAndPages/EditScheduledEventsEditPage.tsx index e825f7921a..a9b5f305ef 100644 --- a/src/components/events/partials/ModalTabsAndPages/EditScheduledEventsEditPage.tsx +++ b/src/components/events/partials/ModalTabsAndPages/EditScheduledEventsEditPage.tsx @@ -17,8 +17,8 @@ import { removeNotificationWizardForm } from "../../../../slices/notificationSli import { Event, EditedEvents, - checkForSchedulingConflicts, fetchScheduling, + Conflict, } from "../../../../slices/eventSlice"; import { Recording } from "../../../../slices/recordingSlice"; import lodash, { groupBy } from "lodash"; @@ -44,7 +44,7 @@ const EditScheduledEventsEditPage = ({ previousPage: (values: T) => void, setPageCompleted: (rec: Record) => void, inputDevices: Recording[], - conflictState: { conflicts: any, setConflicts: any }, + conflictState: { conflicts: Conflict[], setConflicts: (conflicts: Conflict[]) => void }, }) => { const { t } = useTranslation(); const dispatch = useAppDispatch(); @@ -52,11 +52,6 @@ const EditScheduledEventsEditPage = ({ const loading = useAppSelector(state => isLoadingScheduling(state)); const seriesOptions = useAppSelector(state => getSchedulingSeriesOptions(state)); - // TODO: Get rid of the wrappers when modernizing redux is done - const checkForSchedulingConflictsWrapper = async(events: any) => { - return dispatch(checkForSchedulingConflicts(events)); - } - const user = useAppSelector(state => getUserInformation(state)); useEffect(() => { @@ -140,9 +135,7 @@ const EditScheduledEventsEditPage = ({ {t("EVENTS.EVENTS.TABLE.START")} {t("EVENTS.EVENTS.TABLE.END")} -{/* @ts-expect-error TS(7006): Parameter 'conflict' implicitly has an 'any' type. */} {conflicts.map((conflict) => -// @ts-expect-error TS(7006): Parameter 'c' implicitly has an 'any' type. conflict.conflicts.map((c, key) => ( {conflict.eventId} @@ -543,7 +536,6 @@ const EditScheduledEventsEditPage = ({ await checkSchedulingConflicts( formik.values, setConflicts, - checkForSchedulingConflictsWrapper, dispatch ) ) { diff --git a/src/components/events/partials/ModalTabsAndPages/EditScheduledEventsSummaryPage.tsx b/src/components/events/partials/ModalTabsAndPages/EditScheduledEventsSummaryPage.tsx index cae9f0dd5f..4f8bf31aa3 100644 --- a/src/components/events/partials/ModalTabsAndPages/EditScheduledEventsSummaryPage.tsx +++ b/src/components/events/partials/ModalTabsAndPages/EditScheduledEventsSummaryPage.tsx @@ -25,7 +25,7 @@ const EditScheduledEventsSummaryPage = ({ const { t } = useTranslation(); // Changes applied to events - const [changes, setChanges] = useState([]); + const [changes, setChanges] = useState<{eventId: string, title: string, changes: { type: string, previous: string, next: string }[]}[]>([]); const seriesOptions = useAppSelector(state => getSchedulingSeriesOptions(state)); @@ -36,12 +36,11 @@ const EditScheduledEventsSummaryPage = ({ }, []); const checkForChanges = () => { - let changed = []; + let changed: {eventId: string, title: string, changes: { type: string, previous: string, next: string }[]}[] = []; // Loop through each event selected for editing and compare original values and changed values - for (let i = 0; i < formik.values.editedEvents.length; i++) { - let event = formik.values.editedEvents[i]; - let eventChanges : {eventId: string, title: string, changes: any[]}= { + for (const event of formik.values.editedEvents) { + let eventChanges : {eventId: string, title: string, changes: { type: string, previous: string, next: string }[]}= { eventId: event.eventId, title: event.title, changes: [], @@ -128,13 +127,11 @@ const EditScheduledEventsSummaryPage = ({ } // Set changes state -// @ts-expect-error TS(2345): Argument of type '{ eventId: any; title: any; chan... Remove this comment to see the full error message setChanges(changed); }; // Compare two values -// @ts-expect-error TS(7006): Parameter 'oldValue' implicitly has an 'any' type. - const isChanged = (oldValue, newValue) => { + const isChanged = (oldValue: string, newValue: string) => { return oldValue !== newValue; }; @@ -150,7 +147,6 @@ const EditScheduledEventsSummaryPage = ({
{t( "BULK_ACTIONS.EDIT_EVENTS.SUMMARY.SINGLE_EVENT_CAPTION", -// @ts-expect-error TS(2339): Property 'title' does not exist on type 'never'. { title: event.title } )}
@@ -171,7 +167,6 @@ const EditScheduledEventsSummaryPage = ({ {/* Add table row with old value and new one if something has changed */} -{/* @ts-expect-error TS(2339): Property 'changes' does not exist on type 'never'. */} {event.changes.map((row, key) => ( {t(row.type)} diff --git a/src/components/events/partials/ModalTabsAndPages/EventDetailsAccessPolicyTab.tsx b/src/components/events/partials/ModalTabsAndPages/EventDetailsAccessPolicyTab.tsx index 3ea781cc16..69a6e6a373 100644 --- a/src/components/events/partials/ModalTabsAndPages/EventDetailsAccessPolicyTab.tsx +++ b/src/components/events/partials/ModalTabsAndPages/EventDetailsAccessPolicyTab.tsx @@ -1,13 +1,12 @@ import React from "react"; import { getPolicies } from "../../../../selectors/eventDetailsSelectors"; import ResourceDetailsAccessPolicyTab from "../../../shared/modals/ResourceDetailsAccessPolicyTab"; -import { useAppDispatch, useAppSelector } from "../../../../store"; +import { useAppSelector } from "../../../../store"; import { fetchAccessPolicies, fetchHasActiveTransactions, saveAccessPolicies, } from "../../../../slices/eventDetailsSlice"; -import { unwrapResult } from "@reduxjs/toolkit"; import { useTranslation } from "react-i18next"; /** @@ -25,18 +24,6 @@ const EventDetailsAccessPolicyTab = ({ setPolicyChanged: (value: boolean) => void, }) => { const { t } = useTranslation(); - const dispatch = useAppDispatch(); - - // TODO: Get rid of the wrappers when modernizing redux is done - const fetchAccessPoliciesWrapper = (eventId: any) => { - dispatch(fetchAccessPolicies(eventId)); - } - const fetchHasActiveTransactionsWrapper = async(eventId: any) => { - return await dispatch(fetchHasActiveTransactions(eventId)).then(unwrapResult); - } - const saveNewAccessPoliciesWrapper = (eventId: any, policies: any) => { - return dispatch(saveAccessPolicies({eventId, policies})); - } const policies = useAppSelector(state => getPolicies(state)); @@ -47,9 +34,9 @@ const EventDetailsAccessPolicyTab = ({ buttonText={"EVENTS.EVENTS.DETAILS.ACCESS.ACCESS_POLICY.LABEL"} saveButtonText={"SAVE"} policies={policies} - fetchAccessPolicies={fetchAccessPoliciesWrapper} - fetchHasActiveTransactions={fetchHasActiveTransactionsWrapper} - saveNewAccessPolicies={saveNewAccessPoliciesWrapper} + fetchAccessPolicies={fetchAccessPolicies} + fetchHasActiveTransactions={fetchHasActiveTransactions} + saveNewAccessPolicies={saveAccessPolicies} descriptionText={t("EVENTS.SERIES.NEW.ACCESS.ACCESS_POLICY.DESCRIPTION")} editAccessRole={"ROLE_UI_EVENTS_DETAILS_ACL_EDIT"} policyChanged={policyChanged} diff --git a/src/components/events/partials/ModalTabsAndPages/EventDetailsAssetsAddAsset.tsx b/src/components/events/partials/ModalTabsAndPages/EventDetailsAssetsAddAsset.tsx index 22b5f31ef8..634642a30c 100644 --- a/src/components/events/partials/ModalTabsAndPages/EventDetailsAssetsAddAsset.tsx +++ b/src/components/events/partials/ModalTabsAndPages/EventDetailsAssetsAddAsset.tsx @@ -2,7 +2,7 @@ import React from "react"; import EventDetailsTabHierarchyNavigation from "./EventDetailsTabHierarchyNavigation"; import Notifications from "../../../shared/Notifications"; import { style_button_spacing } from "../../../../utils/eventDetailsUtils"; -import { Formik } from "formik"; +import { Formik, FormikProps } from "formik"; import { getAssetUploadOptions } from "../../../../selectors/eventSelectors"; import { translateOverrideFallback } from "../../../../utils/utils"; import { useAppDispatch, useAppSelector } from "../../../../store"; @@ -23,6 +23,8 @@ const EventDetailsAssetsAddAsset = ({ const uploadAssetOptions = useAppSelector(state => getAssetUploadOptions(state)); + const initialValues: { [key: string]: File } = {}; + // Get upload assets that are not of type track const uploadAssets = uploadAssetOptions.filter( (asset) => asset.type !== "track" @@ -32,17 +34,19 @@ const EventDetailsAssetsAddAsset = ({ dispatch(setModalAssetsTabHierarchy(subTabName)); }; -// @ts-expect-error TS(7006): Parameter 'values' implicitly has an 'any' type. - function saveAssets(values) { + function saveAssets(values: { [key: string]: File }) { dispatch(updateAssets({values, eventId})); } -// @ts-expect-error TS(7006): Parameter 'e' implicitly has an 'any' type. - const handleChange = (e, formik, assetId) => { - if (e.target.files.length === 0) { - formik.setFieldValue(assetId, null); + const handleChange = (e: React.ChangeEvent, formik: FormikProps<{ [key: string]: File }>, assetId: string) => { + if (e.target.files) { + if (e.target.files.length === 0) { + formik.setFieldValue(assetId, null); + } else { + formik.setFieldValue(assetId, e.target.files[0]); + } } else { - formik.setFieldValue(assetId, e.target.files[0]); + console.warn("File event did not contain any files") } }; @@ -68,7 +72,7 @@ const EventDetailsAssetsAddAsset = ({
saveAssets(values)} > {(formik) => ( @@ -101,10 +105,8 @@ const EventDetailsAssetsAddAsset = ({ type="file" tabIndex={0} /> -{/* @ts-expect-error TS(7053): Element implicitly has an 'any' type because expre... Remove this comment to see the full error message */} {formik.values[asset.id] && ( -{/* @ts-expect-error TS(7053): Element implicitly has an 'any' type because expre... Remove this comment to see the full error message */} {formik.values[asset.id].name.substr( 0, 50 @@ -119,9 +121,10 @@ const EventDetailsAssetsAddAsset = ({ className="button-like-anchor remove" onClick={() => { formik.setFieldValue(asset.id, null); -// @ts-expect-error TS(2531): Object is possibly 'null'. - document.getElementById(asset.id).value = - ""; + const element = document.getElementById(asset.id) as HTMLInputElement; + if (element) { + element.value = ""; + } }} /> diff --git a/src/components/events/partials/ModalTabsAndPages/EventDetailsCommentsTab.tsx b/src/components/events/partials/ModalTabsAndPages/EventDetailsCommentsTab.tsx index 63e66145d5..d8c8ab4977 100644 --- a/src/components/events/partials/ModalTabsAndPages/EventDetailsCommentsTab.tsx +++ b/src/components/events/partials/ModalTabsAndPages/EventDetailsCommentsTab.tsx @@ -16,6 +16,8 @@ import { saveCommentReply as saveNewCommentReply, deleteComment as deleteOneComment, deleteCommentReply, + Comment, + CommentReply, } from "../../../../slices/eventDetailsSlice"; import { renderValidDate } from "../../../../utils/dateUtils"; import { useTranslation } from "react-i18next"; @@ -44,8 +46,8 @@ const EventDetailsCommentsTab = ({ }, []); const [replyToComment, setReplyToComment] = useState(false); - const [replyCommentId, setReplyCommentId] = useState(null); - const [originalComment, setOriginalComment] = useState(null); + const [replyCommentId, setReplyCommentId] = useState(undefined); + const [originalComment, setOriginalComment] = useState(undefined); const [commentReplyText, setCommentReplyText] = useState(""); const [commentReplyIsResolved, setCommentReplyIsResolved] = useState(false); @@ -54,8 +56,7 @@ const EventDetailsCommentsTab = ({ const user = useAppSelector(state => getUserInformation(state)); -// @ts-expect-error TS(7006): Parameter 'commentText' implicitly has an 'any' ty... Remove this comment to see the full error message - const saveComment = (commentText, commentReason) => { + const saveComment = (commentText: string, commentReason: string) => { dispatch(saveNewComment({eventId, commentText, commentReason})).then((successful) => { if (successful) { dispatch(fetchComments(eventId)); @@ -65,8 +66,7 @@ const EventDetailsCommentsTab = ({ }); }; -// @ts-expect-error TS(7006): Parameter 'comment' implicitly has an 'any' type. - const replyTo = (comment, key) => { + const replyTo = (comment: Comment, key: number) => { setReplyToComment(true); setReplyCommentId(key); setOriginalComment(comment); @@ -74,14 +74,13 @@ const EventDetailsCommentsTab = ({ const exitReplyMode = () => { setReplyToComment(false); - setReplyCommentId(null); - setOriginalComment(null); + setReplyCommentId(undefined); + setOriginalComment(undefined); setCommentReplyText(""); setCommentReplyIsResolved(false); }; -// @ts-expect-error TS(7006): Parameter 'originalComment' implicitly has an 'any... Remove this comment to see the full error message - const saveReply = (originalComment, reply, isResolved) => { + const saveReply = (originalComment: Comment, reply: string, isResolved: boolean) => { dispatch(saveNewCommentReply({eventId, commentId: originalComment.id, replyText: reply, commentResolved: isResolved})).then( (success) => { if (success) { @@ -92,8 +91,7 @@ const EventDetailsCommentsTab = ({ ); }; -// @ts-expect-error TS(7006): Parameter 'comment' implicitly has an 'any' type. - const deleteComment = (comment) => { + const deleteComment = (comment: Comment) => { dispatch(deleteOneComment({eventId, commentId: comment.id})).then((success) => { if (success) { dispatch(fetchComments(eventId)); @@ -101,8 +99,7 @@ const EventDetailsCommentsTab = ({ }); }; -// @ts-expect-error TS(7006): Parameter 'comment' implicitly has an 'any' type. - const deleteReply = (comment, reply) => { + const deleteReply = (comment: Comment, reply: CommentReply) => { dispatch(deleteCommentReply({eventId, commentId: comment.id, replyId: reply.id})).then((success) => { if (success) { dispatch(fetchComments(eventId)); @@ -211,8 +208,7 @@ const EventDetailsCommentsTab = ({ ) && ( diff --git a/src/components/events/partials/ModalTabsAndPages/EventDetailsSchedulingTab.tsx b/src/components/events/partials/ModalTabsAndPages/EventDetailsSchedulingTab.tsx index e33516fa31..20e243e498 100644 --- a/src/components/events/partials/ModalTabsAndPages/EventDetailsSchedulingTab.tsx +++ b/src/components/events/partials/ModalTabsAndPages/EventDetailsSchedulingTab.tsx @@ -2,7 +2,7 @@ import React, { useEffect } from "react"; import cn from "classnames"; import _ from "lodash"; import { DatePicker } from "@mui/x-date-pickers/DatePicker"; -import { Formik } from "formik"; +import { Formik, FormikErrors, FormikProps } from "formik"; import { Field } from "../../../shared/Field"; import Notifications from "../../../shared/Notifications"; import { @@ -42,6 +42,7 @@ import { useAppDispatch, useAppSelector } from "../../../../store"; import { checkConflicts, saveSchedulingInfo, + SchedulingInfo, } from "../../../../slices/eventDetailsSlice"; import { removeNotificationWizardForm, @@ -68,8 +69,7 @@ const EventDetailsSchedulingTab = ({ const checkingConflicts = useAppSelector(state => isCheckingConflicts(state)); const captureAgents = useAppSelector(state => getRecordings(state)); - // TODO: Get rid of the wrappers when modernizing redux is done - const checkConflictsWrapper = (eventId: any, startDate: any, endDate: any, deviceId: any) => { + const checkConflictsWrapper = (eventId: string, startDate: Date, endDate: Date, deviceId: string) => { dispatch(checkConflicts({eventId, startDate, endDate, deviceId})); } @@ -120,8 +120,7 @@ const EventDetailsSchedulingTab = ({ }; // changes the inputs in the formik -// @ts-expect-error TS(7006): Parameter 'deviceId' implicitly has an 'any' type. - const changeInputs = (deviceId: Recording["id"], setFieldValue) => { + const changeInputs = (deviceId: Recording["id"], setFieldValue: (field: string, value: any) => Promise>) => { setFieldValue("captureAgent", deviceId); setFieldValue("inputs", []); }; @@ -130,8 +129,7 @@ const EventDetailsSchedulingTab = ({ }; // checks validity of the formik form -// @ts-expect-error TS(7006): Parameter 'formik' implicitly has an 'any' type. - const checkValidity = (formik) => { + const checkValidity = (formik: FormikProps) => { if ( formik.dirty && formik.isValid && @@ -158,8 +156,7 @@ const EventDetailsSchedulingTab = ({ }; // submits the formik form -// @ts-expect-error TS(7006): Parameter 'values' implicitly has an 'any' type. - const submitForm = async (values) => { + const submitForm = async (values: SchedulingInfo) => { dispatch(removeNotificationWizardForm()); const startDate = makeDate( values.scheduleStartDate, @@ -198,12 +195,12 @@ const EventDetailsSchedulingTab = ({ : []; return { - scheduleStartDate: startDate.setHours(0, 0, 0), + scheduleStartDate: startDate.setHours(0, 0, 0).toString(), scheduleStartHour: source.start.hour != null ? makeTwoDigits(source.start.hour) : "", scheduleStartMinute: source.start.minute != null ? makeTwoDigits(source.start.minute) : "", scheduleDurationHours: source.duration.hour != null ? makeTwoDigits(source.duration.hour) : "", scheduleDurationMinutes: source.duration.minute != null ? makeTwoDigits(source.duration.minute): "", - scheduleEndDate: endDate.setHours(0, 0, 0), + scheduleEndDate: endDate.setHours(0, 0, 0).toString(), scheduleEndHour: source.end.hour != null ? makeTwoDigits(source.end.hour): "", scheduleEndMinute: source.end.minute != null ? makeTwoDigits(source.end.minute): "", captureAgent: source.device.name, @@ -304,8 +301,7 @@ const EventDetailsSchedulingTab = ({ ) : ( <> {sourceStartDate.toLocaleDateString( -// @ts-expect-error TS(2532): Object is possibly 'undefined'. - currentLanguage.dateLocale.code + currentLanguage ? currentLanguage.dateLocale.code : undefined )} )} @@ -536,8 +532,7 @@ const EventDetailsSchedulingTab = ({ {new Date( formik.values.scheduleEndDate ).toLocaleDateString( -// @ts-expect-error TS(2532): Object is possibly 'undefined'. - currentLanguage.dateLocale.code + currentLanguage ? currentLanguage.dateLocale.code : undefined )} )} @@ -553,8 +548,7 @@ const EventDetailsSchedulingTab = ({ {new Date( formik.values.scheduleEndDate ).toLocaleDateString( -// @ts-expect-error TS(2532): Object is possibly 'undefined'. - currentLanguage.dateLocale.code + currentLanguage ? currentLanguage.dateLocale.code : undefined )} )} diff --git a/src/components/events/partials/ModalTabsAndPages/EventDetailsStatisticsTab.tsx b/src/components/events/partials/ModalTabsAndPages/EventDetailsStatisticsTab.tsx index eb400fa50d..2329e7ccce 100644 --- a/src/components/events/partials/ModalTabsAndPages/EventDetailsStatisticsTab.tsx +++ b/src/components/events/partials/ModalTabsAndPages/EventDetailsStatisticsTab.tsx @@ -30,8 +30,7 @@ const EventDetailsStatisticsTab = ({ } /* 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(); @@ -61,7 +60,6 @@ const EventDetailsStatisticsTab = ({ /* visualization of statistic for time series data */
= ({ +const EventDetailsTabHierarchyNavigation = ({ openSubTab, hierarchyDepth, translationKey0 = "", @@ -27,6 +18,15 @@ const EventDetailsTabHierarchyNavigation : React.FC<{ subTabArgument1, translationKey2 = "", subTabArgument2, +}: { + openSubTab: (tabType: T) => void, + hierarchyDepth: number, + translationKey0: string, + subTabArgument0: T, + translationKey1?: string, + subTabArgument1?: T, + translationKey2?: string, + subTabArgument2?: T, }) => { const { t } = useTranslation(); @@ -47,7 +47,7 @@ const EventDetailsTabHierarchyNavigation : React.FC<{ )} - {hierarchyDepth > 0 && ( + {hierarchyDepth > 0 && subTabArgument1 && (