From 9c64fb29a4a08e9aa328ec7de80f8b78d46168a8 Mon Sep 17 00:00:00 2001 From: Linux123123 Date: Tue, 3 Aug 2021 06:07:39 +0300 Subject: [PATCH] Fix ScheduleEdit page not working directly by url (#3477) --- .../components/server/schedules/ScheduleContainer.tsx | 2 +- .../server/schedules/ScheduleEditContainer.tsx | 10 ++-------- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/resources/scripts/components/server/schedules/ScheduleContainer.tsx b/resources/scripts/components/server/schedules/ScheduleContainer.tsx index 85e6db20d..c1609674a 100644 --- a/resources/scripts/components/server/schedules/ScheduleContainer.tsx +++ b/resources/scripts/components/server/schedules/ScheduleContainer.tsx @@ -58,7 +58,7 @@ export default () => { css={tw`cursor-pointer mb-2 flex-wrap`} onClick={(e: any) => { e.preventDefault(); - history.push(`${match.url}/${schedule.id}`, { schedule }); + history.push(`${match.url}/${schedule.id}`); }} > diff --git a/resources/scripts/components/server/schedules/ScheduleEditContainer.tsx b/resources/scripts/components/server/schedules/ScheduleEditContainer.tsx index 720f0c728..fdd602304 100644 --- a/resources/scripts/components/server/schedules/ScheduleEditContainer.tsx +++ b/resources/scripts/components/server/schedules/ScheduleEditContainer.tsx @@ -1,6 +1,5 @@ import React, { useCallback, useEffect, useState } from 'react'; -import { useHistory, useLocation, useParams } from 'react-router-dom'; -import { Schedule } from '@/api/server/schedules/getServerSchedules'; +import { useHistory, useParams } from 'react-router-dom'; import getServerSchedule from '@/api/server/schedules/getServerSchedule'; import Spinner from '@/components/elements/Spinner'; import FlashMessageRender from '@/components/FlashMessageRender'; @@ -23,10 +22,6 @@ interface Params { id: string; } -interface State { - schedule?: Schedule; -} - const CronBox = ({ title, value }: { title: string; value: string }) => (

{title}

@@ -47,7 +42,6 @@ const ActivePill = ({ active }: { active: boolean }) => ( export default () => { const history = useHistory(); - const { state } = useLocation(); const { id: scheduleId } = useParams(); const id = ServerContext.useStoreState(state => state.server.data!.id); @@ -57,7 +51,7 @@ export default () => { const [ isLoading, setIsLoading ] = useState(true); const [ showEditModal, setShowEditModal ] = useState(false); - const schedule = ServerContext.useStoreState(st => st.schedules.data.find(s => s.id === state.schedule?.id), isEqual); + const schedule = ServerContext.useStoreState(st => st.schedules.data.find(s => s.id === Number(scheduleId)), isEqual); const appendSchedule = ServerContext.useStoreActions(actions => actions.schedules.appendSchedule); useEffect(() => {