fix: normalize queue labels
This commit is contained in:
parent
dee31117d3
commit
e833888a3a
4 changed files with 103 additions and 16 deletions
|
|
@ -9,7 +9,7 @@ export const seedDemo = mutation({
|
|||
.query("queues")
|
||||
.withIndex("by_tenant", (q) => q.eq("tenantId", tenantId))
|
||||
.collect();
|
||||
const queues = existingQueues.length
|
||||
let queues = existingQueues.length
|
||||
? existingQueues
|
||||
: await Promise.all(
|
||||
[
|
||||
|
|
@ -19,6 +19,21 @@ export const seedDemo = mutation({
|
|||
).then((ids) => Promise.all(ids.map((id) => ctx.db.get(id))))
|
||||
;
|
||||
|
||||
queues = await Promise.all(
|
||||
queues.map(async (queue) => {
|
||||
if (!queue) return queue;
|
||||
if (queue.name === "Suporte N1" || queue.slug === "suporte-n1") {
|
||||
await ctx.db.patch(queue._id, { name: "Chamados", slug: "chamados" });
|
||||
return (await ctx.db.get(queue._id)) ?? queue;
|
||||
}
|
||||
if (queue.name === "Suporte N2" || queue.slug === "suporte-n2") {
|
||||
await ctx.db.patch(queue._id, { name: "Laboratório", slug: "laboratorio" });
|
||||
return (await ctx.db.get(queue._id)) ?? queue;
|
||||
}
|
||||
return queue;
|
||||
})
|
||||
);
|
||||
|
||||
// Ensure users
|
||||
async function ensureUser(name: string, email: string, role = "AGENT") {
|
||||
const found = await ctx.db
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue