misc_pterodactyl-panel/resources/scripts/components/server/schedules/ScheduleRow.tsx

48 lines
1.7 KiB
TypeScript
Raw Normal View History

import React from 'react';
import { Schedule } from '@/api/server/schedules/getServerSchedules';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
2020-07-05 01:46:09 +00:00
import { faCalendarAlt } from '@fortawesome/free-solid-svg-icons';
import { format } from 'date-fns';
2020-07-05 00:00:19 +00:00
import tw from 'twin.macro';
2020-10-15 03:13:36 +00:00
import ScheduleCronRow from '@/components/server/schedules/ScheduleCronRow';
export default ({ schedule }: { schedule: Schedule }) => (
<>
<div css={tw`hidden md:block`}>
2020-07-05 00:00:19 +00:00
<FontAwesomeIcon icon={faCalendarAlt} fixedWidth/>
</div>
<div css={tw`flex-1 md:ml-4`}>
<p>{schedule.name}</p>
2020-07-05 00:00:19 +00:00
<p css={tw`text-xs text-neutral-400`}>
Last run
at: {schedule.lastRunAt ? format(schedule.lastRunAt, 'MMM do \'at\' h:mma') : 'never'}
</p>
</div>
<div>
<p
css={[
tw`py-1 px-3 rounded text-xs uppercase text-white sm:hidden`,
schedule.isActive ? tw`bg-green-600` : tw`bg-neutral-400`,
]}
>
{schedule.isActive ? 'Active' : 'Inactive'}
</p>
</div>
2020-10-15 03:13:36 +00:00
<ScheduleCronRow cron={schedule.cron} css={tw`mx-auto sm:mx-8 w-full sm:w-auto mt-4 sm:mt-0`}/>
<div>
<p
2020-07-05 00:00:19 +00:00
css={[
tw`py-1 px-3 rounded text-xs uppercase text-white hidden sm:block`,
2020-10-15 03:13:36 +00:00
schedule.isActive && !schedule.isProcessing ? tw`bg-green-600` : tw`bg-neutral-400`,
2020-07-05 00:00:19 +00:00
]}
>
2020-10-15 03:13:36 +00:00
{schedule.isProcessing ?
'Processing'
:
schedule.isActive ? 'Active' : 'Inactive'
}
</p>
</div>
</>
);