<script lang="ts">
	import { DateTime } from 'luxon';
	interface ScrapeJob {
		id: Number;
		targetSiteName: string;
		createdTs: string;
		completedTs: string;
		auctionsFound: Number;
		errors: string;
	}

	export let job: ScrapeJob;

	const { id, targetSiteName, createdTs, completedTs, auctionsFound, errors } = job;

	const createdDT = DateTime.fromISO(createdTs);
	const completedDT = DateTime.fromISO(completedTs);
</script>

<article class="scrape-job-result flex flex-col py-3 shadow-sm border-b-2 border-bh-gold m-2">
	<header class="pb-2">
		Job #{id}
	</header>
	<section>
		<ul>
			<li class="text-sm">Target: {targetSiteName}</li>
			<li class="text-sm">Started: {createdDT?.toLocaleString(DateTime.DATETIME_FULL)}</li>
			{#if completedTs !== null}
				<li class="text-sm">Completed: {completedDT?.toLocaleString(DateTime.DATETIME_FULL)}</li>
			{/if}
			<li class="text-sm">Found: {auctionsFound}</li>
			<li class="text-sm">Errors: {errors}</li>
		</ul>
	</section>
</article>
