chore: initial commit

This commit is contained in:
2026-07-22 17:50:30 +08:00
parent d46cdd676e
commit 3abf272e33
190 changed files with 18073 additions and 0 deletions

View File

@@ -0,0 +1,56 @@
import { useState } from 'react'
import { toast } from 'sonner'
import { deleteSysRole } from '@/api'
import {
AlertDialog,
AlertDialogCancel,
AlertDialogContent,
AlertDialogDescription,
AlertDialogFooter,
AlertDialogHeader,
AlertDialogTitle,
} from '@/components/ui/alert-dialog'
import { Button } from '@/components/ui/button.tsx'
import { Spinner } from '@/components/ui/spinner.tsx'
import { type SysRole } from '@/schemas'
interface Props {
currentRow: SysRole
onClose: () => void
onConfirm: () => void
open: boolean
}
export function DeleteDialog({ open, onClose, currentRow, onConfirm }: Props) {
const [loading, setLoading] = useState(false)
const onDelete = async () => {
try {
setLoading(true)
await deleteSysRole(currentRow.id)
toast('操作成功!')
onConfirm()
} finally {
setLoading(false)
}
}
return (
<AlertDialog open={open} onOpenChange={onClose}>
<AlertDialogContent>
<AlertDialogHeader>
<AlertDialogTitle>?</AlertDialogTitle>
<AlertDialogDescription>{currentRow?.name}</AlertDialogDescription>
</AlertDialogHeader>
<AlertDialogFooter>
<AlertDialogCancel disabled={loading}></AlertDialogCancel>
<Button disabled={loading} variant='destructive' onClick={onDelete}>
{loading && <Spinner data-icon='inline-start' />}
</Button>
</AlertDialogFooter>
</AlertDialogContent>
</AlertDialog>
)
}