update seeder with roles
This commit is contained in:
parent
aa30e8badd
commit
5207fd3159
@ -49,6 +49,9 @@ import {
|
|||||||
const uidUser1: string = randomString();
|
const uidUser1: string = randomString();
|
||||||
const uidUser2: string = randomString();
|
const uidUser2: string = randomString();
|
||||||
|
|
||||||
|
const uidRole1: string = randomString();
|
||||||
|
const uidRole2: string = randomString();
|
||||||
|
|
||||||
const uidOfficeFolder1: string = randomString();
|
const uidOfficeFolder1: string = randomString();
|
||||||
const uidOfficeFolder2: string = randomString();
|
const uidOfficeFolder2: string = randomString();
|
||||||
const uidOfficeFolder3: string = randomString();
|
const uidOfficeFolder3: string = randomString();
|
||||||
@ -231,6 +234,7 @@ import {
|
|||||||
idNot: randomString(),
|
idNot: randomString(),
|
||||||
contact_uid: uidContact1,
|
contact_uid: uidContact1,
|
||||||
office_uid: uidOffice1,
|
office_uid: uidOffice1,
|
||||||
|
roles_uid: uidRole1,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
uid: uidUser2,
|
uid: uidUser2,
|
||||||
@ -239,6 +243,7 @@ import {
|
|||||||
idNot: randomString(),
|
idNot: randomString(),
|
||||||
contact_uid: uidContact2,
|
contact_uid: uidContact2,
|
||||||
office_uid: uidOffice2,
|
office_uid: uidOffice2,
|
||||||
|
roles_uid: uidRole2,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@ -100,6 +100,9 @@ import {
|
|||||||
const uidUser4: string = randomString();
|
const uidUser4: string = randomString();
|
||||||
const uidUser5: string = randomString();
|
const uidUser5: string = randomString();
|
||||||
|
|
||||||
|
const uidRole1: string = randomString();
|
||||||
|
const uidRole2: string = randomString();
|
||||||
|
|
||||||
const uidOfficeFolder1: string = randomString();
|
const uidOfficeFolder1: string = randomString();
|
||||||
const uidOfficeFolder2: string = randomString();
|
const uidOfficeFolder2: string = randomString();
|
||||||
const uidOfficeFolder3: string = randomString();
|
const uidOfficeFolder3: string = randomString();
|
||||||
@ -793,6 +796,7 @@ import {
|
|||||||
idNot: randomString(),
|
idNot: randomString(),
|
||||||
contact_uid: uidContact16,
|
contact_uid: uidContact16,
|
||||||
office_uid: uidOffice1,
|
office_uid: uidOffice1,
|
||||||
|
roles_uid: uidRole1,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
uid: uidUser2,
|
uid: uidUser2,
|
||||||
@ -801,6 +805,7 @@ import {
|
|||||||
idNot: randomString(),
|
idNot: randomString(),
|
||||||
contact_uid: uidContact17,
|
contact_uid: uidContact17,
|
||||||
office_uid: uidOffice1,
|
office_uid: uidOffice1,
|
||||||
|
roles_uid: uidRole2,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
uid: uidUser3,
|
uid: uidUser3,
|
||||||
@ -809,6 +814,7 @@ import {
|
|||||||
idNot: randomString(),
|
idNot: randomString(),
|
||||||
contact_uid: uidContact18,
|
contact_uid: uidContact18,
|
||||||
office_uid: uidOffice1,
|
office_uid: uidOffice1,
|
||||||
|
roles_uid: uidRole1,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
uid: uidUser4,
|
uid: uidUser4,
|
||||||
@ -817,6 +823,7 @@ import {
|
|||||||
idNot: randomString(),
|
idNot: randomString(),
|
||||||
contact_uid: uidContact19,
|
contact_uid: uidContact19,
|
||||||
office_uid: uidOffice1,
|
office_uid: uidOffice1,
|
||||||
|
roles_uid: uidRole2,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
uid: uidUser5,
|
uid: uidUser5,
|
||||||
@ -825,6 +832,7 @@ import {
|
|||||||
idNot: randomString(),
|
idNot: randomString(),
|
||||||
contact_uid: uidContact20,
|
contact_uid: uidContact20,
|
||||||
office_uid: uidOffice1,
|
office_uid: uidOffice1,
|
||||||
|
roles_uid: uidRole1,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@ -1,5 +1,16 @@
|
|||||||
import { Customers, DeedTypes, DocumentTypes, ECivility, ECustomerStatus, Offices, PrismaClient, Users } from "@prisma/client";
|
import {
|
||||||
import User, { Customer, DeedType, DocumentType, Office } from "le-coffre-resources/dist/SuperAdmin";
|
Customers,
|
||||||
|
DeedTypes,
|
||||||
|
DocumentTypes,
|
||||||
|
ECivility,
|
||||||
|
ECustomerStatus,
|
||||||
|
Offices,
|
||||||
|
PrismaClient,
|
||||||
|
Roles,
|
||||||
|
Rules,
|
||||||
|
Users,
|
||||||
|
} from "@prisma/client";
|
||||||
|
import User, { Customer, DeedType, DocumentType, Office, Role, Rule } from "le-coffre-resources/dist/SuperAdmin";
|
||||||
|
|
||||||
const prisma = new PrismaClient();
|
const prisma = new PrismaClient();
|
||||||
|
|
||||||
@ -54,68 +65,94 @@ export const initDeedType = (deedType: DeedType, office: Office, documentTypes?:
|
|||||||
export const initCustomers = (customer: Customer): Promise<Customers> => {
|
export const initCustomers = (customer: Customer): Promise<Customers> => {
|
||||||
return prisma.customers.create({
|
return prisma.customers.create({
|
||||||
data: {
|
data: {
|
||||||
status: ECustomerStatus.PENDING,
|
status: ECustomerStatus.PENDING,
|
||||||
contact: {
|
contact: {
|
||||||
create: {
|
create: {
|
||||||
first_name: customer.contact!.first_name,
|
first_name: customer.contact!.first_name,
|
||||||
last_name: customer.contact!.last_name,
|
last_name: customer.contact!.last_name,
|
||||||
email: customer.contact!.email,
|
email: customer.contact!.email,
|
||||||
phone_number: customer.contact!.phone_number,
|
phone_number: customer.contact!.phone_number,
|
||||||
cell_phone_number: customer.contact!?.cell_phone_number,
|
cell_phone_number: customer.contact!?.cell_phone_number,
|
||||||
civility: ECivility[customer.contact!.civility as keyof typeof ECivility],
|
civility: ECivility[customer.contact!.civility as keyof typeof ECivility],
|
||||||
address: {
|
address: {
|
||||||
create: {
|
create: {
|
||||||
address: customer.contact!.address!.address,
|
address: customer.contact!.address!.address,
|
||||||
zip_code: customer.contact!.address!.zip_code,
|
zip_code: customer.contact!.address!.zip_code,
|
||||||
city: customer.contact!.address!.city,
|
city: customer.contact!.address!.city,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
export const initRules = (rule: Rule): Promise<Rules> => {
|
||||||
|
return prisma.rules.create({
|
||||||
|
data: {
|
||||||
|
name: rule.name,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
export const initRoles = (role: Role): Promise<Roles> => {
|
||||||
|
return prisma.roles.create({
|
||||||
|
data: {
|
||||||
|
name: role.name,
|
||||||
|
},
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
export const initUsers = (user: User): Promise<Users> => {
|
export const initUsers = (user: User): Promise<Users> => {
|
||||||
return prisma.users.create({
|
return prisma.users.create({
|
||||||
data: {
|
data: {
|
||||||
idNot: user.idNot,
|
idNot: user.idNot,
|
||||||
office_membership: {
|
office_membership: {
|
||||||
connectOrCreate: {
|
connectOrCreate: {
|
||||||
where: {
|
where: {
|
||||||
idNot: user.office_membership!.idNot,
|
idNot: user.office_membership!.idNot,
|
||||||
},
|
},
|
||||||
create: {
|
create: {
|
||||||
idNot: user.office_membership!.idNot,
|
idNot: user.office_membership!.idNot,
|
||||||
name: user.office_membership!.name,
|
name: user.office_membership!.name,
|
||||||
crpcen: user.office_membership!.crpcen,
|
crpcen: user.office_membership!.crpcen,
|
||||||
address: {
|
address: {
|
||||||
create: {
|
create: {
|
||||||
address: user.office_membership!.address!.address,
|
address: user.office_membership!.address!.address,
|
||||||
zip_code: user.office_membership!.address!.zip_code,
|
zip_code: user.office_membership!.address!.zip_code,
|
||||||
city: user.office_membership!.address!.city,
|
city: user.office_membership!.address!.city,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
contact: {
|
contact: {
|
||||||
create: {
|
create: {
|
||||||
first_name: user.contact!.first_name,
|
first_name: user.contact!.first_name,
|
||||||
last_name: user.contact!.last_name,
|
last_name: user.contact!.last_name,
|
||||||
email: user.contact!.email,
|
email: user.contact!.email,
|
||||||
phone_number: user.contact!.phone_number,
|
phone_number: user.contact!.phone_number,
|
||||||
cell_phone_number: user.contact!.cell_phone_number,
|
cell_phone_number: user.contact!.cell_phone_number,
|
||||||
civility: ECivility[user.contact!.civility as keyof typeof ECivility],
|
civility: ECivility[user.contact!.civility as keyof typeof ECivility],
|
||||||
address: {
|
address: {
|
||||||
create: {
|
create: {
|
||||||
address: user.contact!.address!.address,
|
address: user.contact!.address!.address,
|
||||||
zip_code: user.contact!.address!.zip_code,
|
zip_code: user.contact!.address!.zip_code,
|
||||||
city: user.contact!.address!.city,
|
city: user.contact!.address!.city,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
role: {
|
||||||
});
|
connectOrCreate: {
|
||||||
|
where: {
|
||||||
|
uid: user.role!.uid,
|
||||||
|
},
|
||||||
|
create: {
|
||||||
|
name: user.role!.name,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user