From d29008251242926ea3954d319b34367ee8e27259 Mon Sep 17 00:00:00 2001 From: Julian Kniephoff Date: Thu, 14 Nov 2024 11:44:11 +0100 Subject: [PATCH] REWORDME refactor openModal --- .../events/partials/EventActionCell.tsx | 18 ++--------------- .../events/partials/SeriesActionsCell.tsx | 20 ++----------------- src/slices/seriesDetailsSlice.ts | 8 +++++++- 3 files changed, 11 insertions(+), 35 deletions(-) diff --git a/src/components/events/partials/EventActionCell.tsx b/src/components/events/partials/EventActionCell.tsx index c3f3228fdc..e81735d7ae 100644 --- a/src/components/events/partials/EventActionCell.tsx +++ b/src/components/events/partials/EventActionCell.tsx @@ -7,14 +7,7 @@ import { hasAccess } from "../../../utils/utils"; import SeriesDetailsModal from "./modals/SeriesDetailsModal"; import { EventDetailsPage } from "./modals/EventDetails"; import { useAppDispatch, useAppSelector } from "../../../store"; -import { - openModal as openSeriesModal, - fetchSeriesDetailsAcls, - fetchSeriesDetailsFeeds, - fetchSeriesDetailsMetadata, - fetchSeriesDetailsTheme, - fetchSeriesDetailsThemeNames, -} from "../../../slices/seriesDetailsSlice"; +import { openModal as openSeriesModal } from "../../../slices/seriesDetailsSlice"; import { Event, deleteEvent } from "../../../slices/eventSlice"; import { Tooltip } from "../../shared/Tooltip"; import { openModal as openEventModal } from "../../../slices/eventDetailsSlice"; @@ -62,14 +55,7 @@ const EventActionCell = ({ const onClickSeriesDetails = async () => { if (!!row.series) { - await dispatch(fetchSeriesDetailsMetadata(row.series.id)); - await dispatch(fetchSeriesDetailsAcls(row.series.id)); - await dispatch(fetchSeriesDetailsFeeds(row.series.id)); - await dispatch(fetchSeriesDetailsTheme(row.series.id)); - await dispatch(fetchSeriesDetailsThemeNames()); - - dispatch(openSeriesModal()); - + await dispatch(openSeriesModal(row.series.id)); showSeriesDetailsModal(); } }; diff --git a/src/components/events/partials/SeriesActionsCell.tsx b/src/components/events/partials/SeriesActionsCell.tsx index d94f2ad6b6..d0cd336f29 100644 --- a/src/components/events/partials/SeriesActionsCell.tsx +++ b/src/components/events/partials/SeriesActionsCell.tsx @@ -2,15 +2,7 @@ import React, { useState } from "react"; import { useTranslation } from "react-i18next"; import ConfirmModal from "../../shared/ConfirmModal"; import SeriesDetailsModal from "./modals/SeriesDetailsModal"; -import { - fetchSeriesDetailsThemeNames, - fetchSeriesDetailsAcls, - fetchSeriesDetailsFeeds, - fetchSeriesDetailsMetadata, - fetchSeriesDetailsTheme, - fetchSeriesDetailsTobira, - openModal, -} from "../../../slices/seriesDetailsSlice"; +import { openModal } from "../../../slices/seriesDetailsSlice"; import { getUserInformation } from "../../../selectors/userInfoSelectors"; import { hasAccess } from "../../../utils/utils"; import { @@ -63,15 +55,7 @@ const SeriesActionsCell = ({ }; const showSeriesDetailsModal = async () => { - await dispatch(fetchSeriesDetailsMetadata(row.id)); - await dispatch(fetchSeriesDetailsAcls(row.id)); - await dispatch(fetchSeriesDetailsFeeds(row.id)); - await dispatch(fetchSeriesDetailsTheme(row.id)); - await dispatch(fetchSeriesDetailsThemeNames()); - await dispatch(fetchSeriesDetailsTobira(row.id)); - - dispatch(openModal()); - + await dispatch(openModal(row.id)); setSeriesDetailsModal(true); }; diff --git a/src/slices/seriesDetailsSlice.ts b/src/slices/seriesDetailsSlice.ts index 7ee4618c5c..7b2c22fd78 100644 --- a/src/slices/seriesDetailsSlice.ts +++ b/src/slices/seriesDetailsSlice.ts @@ -116,7 +116,13 @@ const initialState: SeriesDetailsState = { }, }; -export const openModal = () => (dispatch: AppDispatch) => { +export const openModal = (id: string) => async (dispatch: AppDispatch) => { + await dispatch(fetchSeriesDetailsMetadata(id)); + await dispatch(fetchSeriesDetailsAcls(id)); + await dispatch(fetchSeriesDetailsFeeds(id)); + await dispatch(fetchSeriesDetailsTheme(id)); + await dispatch(fetchSeriesDetailsThemeNames()); + await dispatch(fetchSeriesDetailsTobira(id)); dispatch(setModalPage(0)); };