import { __, sprintf } from '@wordpress/i18n'; import type { JSX } from 'react'; import type { Job, JobUpdate } from '../../shared/api/types/jobs'; import { jobName, jobNextRun } from '../../shared/jobs/jobTexts'; import { classNames } from '../../shared/lib/classNames'; import { Icon } from '../../shared/ui/Icon'; import { Switch } from '../../shared/ui/Switch'; import { switchedText } from './jobChangeTexts'; import { jobDescription, jobIcon, jobLastResult } from './jobDetails'; import { JobFrequencySelect } from './JobFrequencySelect'; import { useUpdateJob } from './jobQueries'; import { useNotifyOutcome } from '../../shared/ui/useNotifyOutcome'; const PAUSED_JOB_STYLE = { background: 'var(--sunken)', color: 'var(--muted)', }; type JobRowProps = { job: Job; now: number; }; export function JobRow( { job, now }: JobRowProps ): JSX.Element { const updateJob = useUpdateJob(); const notifyOutcome = useNotifyOutcome(); const name = jobName( job.id ); const changeJob = ( update: JobUpdate, successText: string ) => { updateJob.mutate( { id: job.id, update }, notifyOutcome( successText ) ); }; return (