feat: sync convex companies and dashboard metrics

This commit is contained in:
Esdras Renan 2025-10-18 21:13:20 -03:00
parent 4f52114b48
commit 7a3eca9361
10 changed files with 356 additions and 19 deletions

View file

@ -85,3 +85,24 @@ export const ensureProvisioned = mutation({
}
},
})
export const removeBySlug = mutation({
args: {
tenantId: v.string(),
slug: v.string(),
},
handler: async (ctx, { tenantId, slug }) => {
const normalizedSlug = normalizeSlug(slug) ?? slug
const existing = await ctx.db
.query("companies")
.withIndex("by_tenant_slug", (q) => q.eq("tenantId", tenantId).eq("slug", normalizedSlug))
.unique()
if (!existing) {
return { removed: false }
}
await ctx.db.delete(existing._id)
return { removed: true }
},
})