feat: CSV exports, PDF improvements, play internal/external with hour split, roles cleanup, admin companies with 'Cliente avulso', ticket list spacing/alignment fixes, status translations and mappings
This commit is contained in:
parent
addd4ce6e8
commit
3bafcc5a0a
45 changed files with 1401 additions and 256 deletions
|
|
@ -26,7 +26,7 @@ if (!secret) {
|
|||
process.exit(1)
|
||||
}
|
||||
|
||||
const allowedRoles = new Set(["ADMIN", "MANAGER", "AGENT", "COLLABORATOR", "CUSTOMER"])
|
||||
const allowedRoles = new Set(["ADMIN", "MANAGER", "AGENT", "COLLABORATOR"])
|
||||
|
||||
const client = new ConvexHttpClient(convexUrl)
|
||||
|
||||
|
|
@ -61,7 +61,7 @@ const STATUS_MAP = {
|
|||
ON_HOLD: "PAUSED",
|
||||
PAUSED: "PAUSED",
|
||||
RESOLVED: "RESOLVED",
|
||||
CLOSED: "CLOSED",
|
||||
CLOSED: "RESOLVED",
|
||||
}
|
||||
|
||||
function normalizeStatus(status) {
|
||||
|
|
@ -84,6 +84,7 @@ async function upsertCompanies(snapshotCompanies) {
|
|||
},
|
||||
update: {
|
||||
name: company.name,
|
||||
isAvulso: Boolean(company.isAvulso ?? false),
|
||||
cnpj: company.cnpj ?? null,
|
||||
domain: company.domain ?? null,
|
||||
phone: company.phone ?? null,
|
||||
|
|
@ -94,6 +95,7 @@ async function upsertCompanies(snapshotCompanies) {
|
|||
tenantId,
|
||||
name: company.name,
|
||||
slug,
|
||||
isAvulso: Boolean(company.isAvulso ?? false),
|
||||
cnpj: company.cnpj ?? null,
|
||||
domain: company.domain ?? null,
|
||||
phone: company.phone ?? null,
|
||||
|
|
@ -117,8 +119,8 @@ async function upsertUsers(snapshotUsers, companyMap) {
|
|||
const normalizedEmail = normalizeEmail(user.email)
|
||||
if (!normalizedEmail) continue
|
||||
|
||||
const normalizedRole = (user.role ?? "CUSTOMER").toUpperCase()
|
||||
const role = allowedRoles.has(normalizedRole) ? normalizedRole : "CUSTOMER"
|
||||
const normalizedRole = (user.role ?? "MANAGER").toUpperCase()
|
||||
const role = allowedRoles.has(normalizedRole) ? normalizedRole : "MANAGER"
|
||||
const companyId = user.companySlug ? companyMap.get(user.companySlug) ?? null : null
|
||||
|
||||
const record = await prisma.user.upsert({
|
||||
|
|
@ -195,7 +197,7 @@ async function upsertUsers(snapshotUsers, companyMap) {
|
|||
await prisma.user.update({
|
||||
where: { id: staff.id },
|
||||
data: {
|
||||
role: "CUSTOMER",
|
||||
role: "MANAGER",
|
||||
},
|
||||
})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ const defaultUsers = singleUserFromEnv ?? [
|
|||
email: "cliente.demo@sistema.dev",
|
||||
password: "cliente123",
|
||||
name: "Cliente Demo",
|
||||
role: "customer",
|
||||
role: "manager",
|
||||
tenantId,
|
||||
},
|
||||
{
|
||||
|
|
@ -50,28 +50,28 @@ const defaultUsers = singleUserFromEnv ?? [
|
|||
email: "joao.ramos@atlasengenharia.com.br",
|
||||
password: "cliente123",
|
||||
name: "João Pedro Ramos",
|
||||
role: "customer",
|
||||
role: "manager",
|
||||
tenantId,
|
||||
},
|
||||
{
|
||||
email: "aline.rezende@atlasengenharia.com.br",
|
||||
password: "cliente123",
|
||||
name: "Aline Rezende",
|
||||
role: "customer",
|
||||
role: "manager",
|
||||
tenantId,
|
||||
},
|
||||
{
|
||||
email: "ricardo.matos@omnisaude.com.br",
|
||||
password: "cliente123",
|
||||
name: "Ricardo Matos",
|
||||
role: "customer",
|
||||
role: "manager",
|
||||
tenantId,
|
||||
},
|
||||
{
|
||||
email: "luciana.prado@omnisaude.com.br",
|
||||
password: "cliente123",
|
||||
name: "Luciana Prado",
|
||||
role: "customer",
|
||||
role: "manager",
|
||||
tenantId,
|
||||
},
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue