import { __ } from '@wordpress/i18n';
import type { Job, JobId } from '../api/types/jobs';
import { timeUntil } from '../lib/timeUntil';

export function jobName( jobId: JobId ): string {
	switch ( jobId ) {
		case 'check':
			return __( 'Check links', 'aiplaz-link-checkup' );
		case 'full':
			return __( 'Check everything again', 'aiplaz-link-checkup' );
		case 'mail':
			return __( 'Email report', 'aiplaz-link-checkup' );
		case 'tidy':
			return __( 'Tidy up', 'aiplaz-link-checkup' );
	}
}

export function jobNextRun( job: Job, now: number ): string {
	if ( ! job.enabled || job.next_run_at === null || job.next_run_at === '' ) {
		return __( 'Paused', 'aiplaz-link-checkup' );
	}

	return timeUntil( job.next_run_at, now );
}
