This commit is contained in:
2025-11-18 20:56:21 -03:00
parent b439b1e038
commit 3a42e4c7d2
2 changed files with 25 additions and 5 deletions

View File

@@ -195,6 +195,7 @@ export function DataTable<TData, TValue>({
<TableRow <TableRow
key={row.id} key={row.id}
data-state={row.getIsSelected() && 'selected'} data-state={row.getIsSelected() && 'selected'}
className="has-[[data-state=open]]:bg-muted/50"
> >
{row.getVisibleCells().map((cell) => ( {row.getVisibleCells().map((cell) => (
<TableCell <TableCell

View File

@@ -329,7 +329,7 @@ function RemoveDedupItem({
onSuccess, onSuccess,
...props ...props
}: ItemProps & { }: ItemProps & {
lock?: { hash: string } lock?: { hash: string; ttl?: number }
}) { }) {
const [loading, { set }] = useToggle(false) const [loading, { set }] = useToggle(false)
const [open, { set: setOpen }] = useToggle(false) const [open, { set: setOpen }] = useToggle(false)
@@ -338,7 +338,7 @@ function RemoveDedupItem({
e.preventDefault() e.preventDefault()
set(true) set(true)
if (!lock) return if (!lock) return null
const r = await fetch(`/~/api/enrollments/${id}/dedupwindow`, { const r = await fetch(`/~/api/enrollments/${id}/dedupwindow`, {
method: 'DELETE', method: 'DELETE',
@@ -353,6 +353,20 @@ function RemoveDedupItem({
} }
} }
const getDaysRemaining = () => {
if (!lock?.ttl) return null
return new Date(lock.ttl * 1000).toLocaleString('pt-BR', {
hour: '2-digit',
minute: '2-digit',
day: '2-digit',
month: '2-digit',
year: '2-digit'
})
}
const daysRemaining = getDaysRemaining()
return ( return (
<AlertDialog open={open} onOpenChange={setOpen}> <AlertDialog open={open} onOpenChange={setOpen}>
<AlertDialogTrigger asChild> <AlertDialogTrigger asChild>
@@ -368,9 +382,14 @@ function RemoveDedupItem({
<AlertDialogContent> <AlertDialogContent>
<AlertDialogHeader> <AlertDialogHeader>
<AlertDialogTitle>Tem certeza absoluta?</AlertDialogTitle> <AlertDialogTitle>Tem certeza absoluta?</AlertDialogTitle>
<AlertDialogDescription> <AlertDialogDescription className="space-y-2.5">
<p>
Esta ação não pode ser desfeita. Isso remove a proteção contra Esta ação não pode ser desfeita. Isso remove a proteção contra
duplicação permanentemente desta matrícula. duplicação permanentemente desta matrícula.
</p>
{daysRemaining && (
<p>Proteção contra duplicação válida até {daysRemaining}</p>
)}
</AlertDialogDescription> </AlertDialogDescription>
</AlertDialogHeader> </AlertDialogHeader>
<AlertDialogFooter className="*:cursor-pointer"> <AlertDialogFooter className="*:cursor-pointer">