Skip to content

Commit

Permalink
REWORDME refactor openModal
Browse files Browse the repository at this point in the history
  • Loading branch information
JulianKniephoff committed Nov 14, 2024
1 parent fb27bc0 commit d290082
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 35 deletions.
18 changes: 2 additions & 16 deletions src/components/events/partials/EventActionCell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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();
}
};
Expand Down
20 changes: 2 additions & 18 deletions src/components/events/partials/SeriesActionsCell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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);
};

Expand Down
8 changes: 7 additions & 1 deletion src/slices/seriesDetailsSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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));
};

Expand Down

0 comments on commit d290082

Please sign in to comment.