<script setup lang="ts">
import AccordionContent from "@/Components/ui/accordion/AccordionContent.vue";
import AccordionItem from "@/Components/ui/accordion/AccordionItem.vue";
import AccordionTrigger from "@/Components/ui/accordion/AccordionTrigger.vue";
import { JobRunArtifact } from "@/types/Jobs/job";
import JobRunArtifacts from "./JobRunArtifacts.vue";

defineProps<{
    jobRun: JobRunArtifact;
}>();
</script>

<template>
    <AccordionItem :value="''+jobRun.id" :class="[jobRun.success ? 'bg-green-100' : 'bg-red-200', 'first:rounded-t last:rounded-b', 'px-3']">
        <AccordionTrigger>
            {{ new Date(Date.parse(jobRun.created_at)).toLocaleTimeString(undefined, {
                    weekday: "long",
                    year: "numeric",
                    month: "long",
                    day: "numeric",
                })
            }}
        </AccordionTrigger>
        <AccordionContent>
            <JobRunArtifacts :jobRun="jobRun" />
        </AccordionContent>
    </AccordionItem>
</template>
