// Deployment history modal — shows last 10 deployments for a target import { useEffect, useState, useCallback } from 'react' import { Dialog, Card, Box, Stack, Flex, Text, Badge, Spinner, Button, } from '@sanity/ui' import { LaunchIcon, CloseIcon } from '@sanity/icons' import { listDeployments } from '../lib/api' import { parseHookUrl, stateLabel, timeAgo, shortSha, safeHref } from '../lib/helpers' import type { DeployTarget, VercelDeployment } from '../types' interface DeployHistoryProps { target: DeployTarget token: string onClose: () => void } export function DeployHistory({ target, token, onClose }: DeployHistoryProps) { const [deployments, setDeployments] = useState([]) const [loading, setLoading] = useState(true) const [error, setError] = useState(null) const { projectId, hookId } = parseHookUrl(target.url) const load = useCallback(async () => { setLoading(true) setError(null) try { const data = await listDeployments({ projectId, hookId, token, teamId: target.teamId, limit: 10 }) setDeployments(data) } catch (err) { setError(err instanceof Error ? err.message : 'Failed to load history') } finally { setLoading(false) } }, [projectId, hookId, token, target.teamId]) useEffect(() => { load() }, [load]) return ( ) }