update
This commit is contained in:
@@ -329,7 +329,7 @@ function RemoveDedupItem({
|
||||
onSuccess,
|
||||
...props
|
||||
}: ItemProps & {
|
||||
lock?: { hash: string }
|
||||
lock?: { hash: string; ttl?: number }
|
||||
}) {
|
||||
const [loading, { set }] = useToggle(false)
|
||||
const [open, { set: setOpen }] = useToggle(false)
|
||||
@@ -338,7 +338,7 @@ function RemoveDedupItem({
|
||||
e.preventDefault()
|
||||
set(true)
|
||||
|
||||
if (!lock) return
|
||||
if (!lock) return null
|
||||
|
||||
const r = await fetch(`/~/api/enrollments/${id}/dedupwindow`, {
|
||||
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 (
|
||||
<AlertDialog open={open} onOpenChange={setOpen}>
|
||||
<AlertDialogTrigger asChild>
|
||||
@@ -368,9 +382,14 @@ function RemoveDedupItem({
|
||||
<AlertDialogContent>
|
||||
<AlertDialogHeader>
|
||||
<AlertDialogTitle>Tem certeza absoluta?</AlertDialogTitle>
|
||||
<AlertDialogDescription>
|
||||
Esta ação não pode ser desfeita. Isso remove a proteção contra
|
||||
duplicação permanentemente desta matrícula.
|
||||
<AlertDialogDescription className="space-y-2.5">
|
||||
<p>
|
||||
Esta ação não pode ser desfeita. Isso remove a proteção contra
|
||||
duplicação permanentemente desta matrícula.
|
||||
</p>
|
||||
{daysRemaining && (
|
||||
<p>Proteção contra duplicação válida até {daysRemaining}</p>
|
||||
)}
|
||||
</AlertDialogDescription>
|
||||
</AlertDialogHeader>
|
||||
<AlertDialogFooter className="*:cursor-pointer">
|
||||
|
||||
Reference in New Issue
Block a user