<script setup lang="ts">
import { Job, JobRunArtifact } from "@/types/Jobs/job";
import JobRunItem from "./JobRunItem.vue";
import Accordion from "@/Components/ui/accordion/Accordion.vue";
import ScrollArea from "@/Components/ui/scroll-area/ScrollArea.vue";

defineProps<{
    job: Job;
}>();
</script>

<template>
    <div v-if="job.job_runs.length > 0">
        <h2>Ancien jobs</h2>
        <ScrollArea class="min-h-[300px] max-h-[20vh] overflow-auto pr-2">
            <Accordion type="multiple" collapsible>
                <JobRunItem
                    :jobRun="jobRun"
                    v-for="jobRun in job.job_runs.sort((a, b) => {
                        return (
                            new Date(b.created_at).getTime() -
                            new Date(a.created_at).getTime()
                        );
                    })"
                    :key="jobRun.id"
                />
            </Accordion>
        </ScrollArea>
    </div>
</template>
