import React, { useState } from 'react'; import { Task } from '@/api/server/schedules/getServerSchedules'; import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import { faTrashAlt } from '@fortawesome/free-solid-svg-icons/faTrashAlt'; import { faCode } from '@fortawesome/free-solid-svg-icons/faCode'; import { faToggleOn } from '@fortawesome/free-solid-svg-icons/faToggleOn'; import ConfirmTaskDeletionModal from '@/components/server/schedules/ConfirmTaskDeletionModal'; import { ServerContext } from '@/state/server'; import { Actions, useStoreActions } from 'easy-peasy'; import { ApplicationStore } from '@/state'; import deleteScheduleTask from '@/api/server/schedules/deleteScheduleTask'; import { httpErrorToHuman } from '@/api/http'; import SpinnerOverlay from '@/components/elements/SpinnerOverlay'; import TaskDetailsModal from '@/components/server/schedules/TaskDetailsModal'; import { faPencilAlt } from '@fortawesome/free-solid-svg-icons/faPencilAlt'; interface Props { schedule: number; task: Task; onTaskUpdated: (task: Task) => void; onTaskRemoved: () => void; } export default ({ schedule, task, onTaskUpdated, onTaskRemoved }: Props) => { const [ visible, setVisible ] = useState(false); const [ isLoading, setIsLoading ] = useState(false); const [ isEditing, setIsEditing ] = useState(false); const uuid = ServerContext.useStoreState(state => state.server.data!.uuid); const { clearFlashes, addError } = useStoreActions((actions: Actions) => actions.flashes); const onConfirmDeletion = () => { setIsLoading(true); clearFlashes('schedules'); deleteScheduleTask(uuid, schedule, task.id) .then(() => onTaskRemoved()) .catch(error => { console.error(error); setIsLoading(false); addError({ message: httpErrorToHuman(error), key: 'schedules' }); }); }; return (
{isEditing && { task && onTaskUpdated(task); setIsEditing(false); }} />} setVisible(false)} onConfirmed={() => onConfirmDeletion()} />

{task.action === 'command' ? 'Send command' : 'Send power action'}

{task.payload}
{task.sequenceId > 1 &&

{task.timeOffset}s

Delay Run By

}
); };