feat(admin/jobs-table): toggle-buttons en view-state voor status/kosten-weergave
Voegt useState toe, breidt Job-type uit met model_id en cost_usd, extraheert huidige tabellogica naar StatusTable en voegt CostsTable-stub + toggle-knoppen toe aan JobsTable.
This commit is contained in:
parent
ca07fb842f
commit
7ba9494ea9
1 changed files with 34 additions and 2 deletions
|
|
@ -1,6 +1,6 @@
|
|||
'use client'
|
||||
|
||||
import { useTransition } from 'react'
|
||||
import { useState, useTransition } from 'react'
|
||||
import { Badge } from '@/components/ui/badge'
|
||||
import { Button } from '@/components/ui/button'
|
||||
import {
|
||||
|
|
@ -23,6 +23,8 @@ type Job = {
|
|||
branch: string | null
|
||||
pr_url: string | null
|
||||
error: string | null
|
||||
model_id: string | null
|
||||
cost_usd: number | null
|
||||
}
|
||||
|
||||
const STATUS_CLASS: Record<string, string> = {
|
||||
|
|
@ -92,7 +94,7 @@ function JobRow({ job }: { job: Job }) {
|
|||
)
|
||||
}
|
||||
|
||||
export function JobsTable({ jobs }: { jobs: Job[] }) {
|
||||
function StatusTable({ jobs }: { jobs: Job[] }) {
|
||||
return (
|
||||
<Table>
|
||||
<TableHeader>
|
||||
|
|
@ -123,3 +125,33 @@ export function JobsTable({ jobs }: { jobs: Job[] }) {
|
|||
</Table>
|
||||
)
|
||||
}
|
||||
|
||||
function CostsTable({ jobs: _jobs }: { jobs: Job[] }) {
|
||||
return null
|
||||
}
|
||||
|
||||
export function JobsTable({ jobs }: { jobs: Job[] }) {
|
||||
const [view, setView] = useState<'status' | 'costs'>('status')
|
||||
|
||||
return (
|
||||
<div className="space-y-3">
|
||||
<div className="flex gap-1">
|
||||
<Button
|
||||
size="sm"
|
||||
variant={view === 'status' ? 'default' : 'outline'}
|
||||
onClick={() => setView('status')}
|
||||
>
|
||||
Status
|
||||
</Button>
|
||||
<Button
|
||||
size="sm"
|
||||
variant={view === 'costs' ? 'default' : 'outline'}
|
||||
onClick={() => setView('costs')}
|
||||
>
|
||||
Kosten
|
||||
</Button>
|
||||
</div>
|
||||
{view === 'status' ? <StatusTable jobs={jobs} /> : <CostsTable jobs={jobs} />}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue