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