6a5b2b7792
Add shared components (ConfirmDeleteDialog, EditEntryDialog, validation utils), enhance all 12 extension workspaces with edit/delete dialogs, input validation, period comparisons, and new analytics features. Fix critical bugs in ProjectBilling margin calculation and EarningsPerLiter revenue allocation. Add pure calculation modules with 183 new tests across all extensions. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
64 lines
1.9 KiB
TypeScript
64 lines
1.9 KiB
TypeScript
'use client'
|
|
|
|
import {
|
|
Dialog, DialogContent, DialogHeader, DialogTitle, DialogDescription, DialogFooter,
|
|
} from '@/components/ui/dialog'
|
|
import { Button } from '@/components/ui/button'
|
|
import { Loader2, AlertTriangle } from 'lucide-react'
|
|
|
|
interface ConfirmDeleteDialogProps {
|
|
open: boolean
|
|
onOpenChange: (open: boolean) => void
|
|
title?: string
|
|
description?: string
|
|
onConfirm: () => void | Promise<void>
|
|
isDeleting?: boolean
|
|
}
|
|
|
|
export default function ConfirmDeleteDialog({
|
|
open,
|
|
onOpenChange,
|
|
title = 'Bekrafta borttagning',
|
|
description = 'Ar du saker pa att du vill ta bort detta? Atgarden kan inte angras.',
|
|
onConfirm,
|
|
isDeleting = false,
|
|
}: ConfirmDeleteDialogProps) {
|
|
const handleConfirm = async () => {
|
|
await onConfirm()
|
|
onOpenChange(false)
|
|
}
|
|
|
|
return (
|
|
<Dialog open={open} onOpenChange={onOpenChange}>
|
|
<DialogContent className="max-w-sm">
|
|
<DialogHeader>
|
|
<div className="flex items-center gap-3">
|
|
<div className="flex h-10 w-10 items-center justify-center rounded-full bg-red-100 dark:bg-red-950/30">
|
|
<AlertTriangle className="h-5 w-5 text-red-600 dark:text-red-400" />
|
|
</div>
|
|
<div>
|
|
<DialogTitle>{title}</DialogTitle>
|
|
<DialogDescription>{description}</DialogDescription>
|
|
</div>
|
|
</div>
|
|
</DialogHeader>
|
|
<DialogFooter>
|
|
<Button variant="outline" onClick={() => onOpenChange(false)} disabled={isDeleting}>
|
|
Avbryt
|
|
</Button>
|
|
<Button variant="destructive" onClick={handleConfirm} disabled={isDeleting}>
|
|
{isDeleting ? (
|
|
<>
|
|
<Loader2 className="mr-2 h-4 w-4 animate-spin" />
|
|
Tar bort...
|
|
</>
|
|
) : (
|
|
'Ta bort'
|
|
)}
|
|
</Button>
|
|
</DialogFooter>
|
|
</DialogContent>
|
|
</Dialog>
|
|
)
|
|
}
|