Skip to content

Commit 9c64fb2

Browse files
authored
Fix ScheduleEdit page not working directly by url (pterodactyl#3477)
1 parent e8746fe commit 9c64fb2

File tree

2 files changed

+3
-9
lines changed

2 files changed

+3
-9
lines changed

resources/scripts/components/server/schedules/ScheduleContainer.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ export default () => {
5858
css={tw`cursor-pointer mb-2 flex-wrap`}
5959
onClick={(e: any) => {
6060
e.preventDefault();
61-
history.push(`${match.url}/${schedule.id}`, { schedule });
61+
history.push(`${match.url}/${schedule.id}`);
6262
}}
6363
>
6464
<ScheduleRow schedule={schedule}/>

resources/scripts/components/server/schedules/ScheduleEditContainer.tsx

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import React, { useCallback, useEffect, useState } from 'react';
2-
import { useHistory, useLocation, useParams } from 'react-router-dom';
3-
import { Schedule } from '@/api/server/schedules/getServerSchedules';
2+
import { useHistory, useParams } from 'react-router-dom';
43
import getServerSchedule from '@/api/server/schedules/getServerSchedule';
54
import Spinner from '@/components/elements/Spinner';
65
import FlashMessageRender from '@/components/FlashMessageRender';
@@ -23,10 +22,6 @@ interface Params {
2322
id: string;
2423
}
2524

26-
interface State {
27-
schedule?: Schedule;
28-
}
29-
3025
const CronBox = ({ title, value }: { title: string; value: string }) => (
3126
<div css={tw`bg-neutral-700 rounded p-3`}>
3227
<p css={tw`text-neutral-300 text-sm`}>{title}</p>
@@ -47,7 +42,6 @@ const ActivePill = ({ active }: { active: boolean }) => (
4742

4843
export default () => {
4944
const history = useHistory();
50-
const { state } = useLocation<State>();
5145
const { id: scheduleId } = useParams<Params>();
5246

5347
const id = ServerContext.useStoreState(state => state.server.data!.id);
@@ -57,7 +51,7 @@ export default () => {
5751
const [ isLoading, setIsLoading ] = useState(true);
5852
const [ showEditModal, setShowEditModal ] = useState(false);
5953

60-
const schedule = ServerContext.useStoreState(st => st.schedules.data.find(s => s.id === state.schedule?.id), isEqual);
54+
const schedule = ServerContext.useStoreState(st => st.schedules.data.find(s => s.id === Number(scheduleId)), isEqual);
6155
const appendSchedule = ServerContext.useStoreActions(actions => actions.schedules.appendSchedule);
6256

6357
useEffect(() => {

0 commit comments

Comments
 (0)