Auto-open modals from global quick actions

This commit is contained in:
Esdras Renan 2025-11-13 21:43:36 -03:00
parent 59a94744b3
commit abb29d9116
7 changed files with 70 additions and 11 deletions

View file

@ -95,6 +95,7 @@ type LastAlertInfo = { createdAt: number; usagePct: number; threshold: number }
type Props = {
initialCompanies: NormalizedCompany[]
tenantId?: string | null
autoOpenCreate?: boolean
}
type ViewMode = "table" | "board"
@ -291,7 +292,7 @@ function FieldError({ error }: { error?: string }) {
return <p className="text-xs font-medium text-destructive">{error}</p>
}
export function AdminCompaniesManager({ initialCompanies, tenantId }: Props) {
export function AdminCompaniesManager({ initialCompanies, tenantId, autoOpenCreate = false }: Props) {
const [companies, setCompanies] = useState<NormalizedCompany[]>(() => initialCompanies)
const [view, setView] = useState<ViewMode>("table")
const [search, setSearch] = useState("")
@ -429,6 +430,12 @@ export function AdminCompaniesManager({ initialCompanies, tenantId }: Props) {
const cancelDelete = useCallback(() => setIsDeleting(null), [])
useEffect(() => {
if (autoOpenCreate) {
openCreate()
}
}, [autoOpenCreate, openCreate])
const handleDelete = useCallback(async () => {
if (!isDeleting) return
try {