import React from 'react'; import { useHistory } from 'react-router-dom'; import { useSchedules } from 'loot-core/src/client/data-hooks/schedules'; import { send } from 'loot-core/src/platform/client/fetch'; import { View, Button } from 'loot-design/src/components/common'; import { Page } from '../Page'; import { SchedulesTable, ROW_HEIGHT } from './SchedulesTable'; export default function Schedules() { let history = useHistory(); let scheduleData = useSchedules(); if (scheduleData == null) { return null; } let { schedules, statuses } = scheduleData; function onEdit(id) { history.push(`/schedule/edit/${id}`, { locationPtr: history.location }); } function onAdd() { history.push(`/schedule/edit`, { locationPtr: history.location }); } async function onAction(name, id) { switch (name) { case 'post-transaction': await send('schedule/post-transaction', { id }); break; case 'skip': await send('schedule/skip-next-date', { id }); break; case 'complete': await send('schedule/update', { schedule: { id, completed: true } }); break; case 'restart': await send('schedule/update', { schedule: { id, completed: false }, resetNextDate: true }); break; case 'delete': await send('schedule/delete', { id }); break; default: } } return ( ); }