chore: reorganize project structure and ensure default queues
This commit is contained in:
parent
854887f499
commit
1cccb852a5
201 changed files with 417 additions and 838 deletions
21
src/hooks/use-default-queues.ts
Normal file
21
src/hooks/use-default-queues.ts
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
"use client"
|
||||
|
||||
import { useEffect, useRef } from "react"
|
||||
import { useMutation } from "convex/react"
|
||||
// @ts-expect-error Convex runtime API lacks TypeScript declarations
|
||||
import { api } from "@/convex/_generated/api"
|
||||
|
||||
export function useDefaultQueues(tenantId?: string | null) {
|
||||
const ensureDefaults = useMutation(api.bootstrap.ensureDefaults)
|
||||
const pendingRef = useRef(false)
|
||||
|
||||
useEffect(() => {
|
||||
if (!tenantId) return
|
||||
if (pendingRef.current) return
|
||||
pendingRef.current = true
|
||||
ensureDefaults({ tenantId })
|
||||
.catch(() => {
|
||||
pendingRef.current = false
|
||||
})
|
||||
}, [ensureDefaults, tenantId])
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue