feature/IO-3255-simplified-parts-management Deprovision route can now remove jobs, joblines, and audit trail

This commit is contained in:
Dave
2025-08-19 11:17:29 -04:00
parent c0a215d20d
commit f6d6b548be
2 changed files with 167 additions and 71 deletions

View File

@@ -126,7 +126,7 @@ const CREATE_SHOP = `
const DELETE_VENDORS_BY_SHOP = `
mutation DELETE_VENDORS($shopId: uuid!) {
delete_vendors(where: { shopid: { _eq: $shopId } }) {
delete_vendors(where: { bodyshopid: { _eq: $shopId } }) {
affected_rows
}
}
@@ -147,6 +147,92 @@ const CREATE_USER = `
}
`;
const GET_BODYSHOP = `
query GetBodyshop($id: uuid!) {
bodyshops_by_pk(id: $id) {
external_shop_id
shopname
}
}
`;
const GET_ASSOCIATED_USERS = `
query GetAssociatedUsers($shopId: uuid!) {
associations(where: {shopid: {_eq: $shopId}}) {
user {
authid
email
}
}
}
`;
const DELETE_ASSOCIATIONS_BY_SHOP = `
mutation DeleteAssociationsByShop($shopId: uuid!) {
delete_associations(where: {shopid: {_eq: $shopId}}) {
affected_rows
}
}
`;
const GET_USER_ASSOCIATIONS_COUNT = `
query GetUserAssociationsCount($userEmail: String!) {
associations_aggregate(where: {useremail: {_eq: $userEmail}}) {
aggregate {
count
}
}
}
`;
const DELETE_USER = `
mutation DeleteUser($email: String!) {
delete_users(where: {email: {_eq: $email}}) {
affected_rows
}
}
`;
const GET_VENDORS = `
query GetVendors($shopId: uuid!) {
vendors(where: {bodyshopid: {_eq: $shopId}}) {
name
}
}
`;
const GET_JOBS_BY_SHOP = `
query GetJobsByShop($shopId: uuid!) {
jobs(where: {shopid: {_eq: $shopId}}) {
id
}
}
`;
const DELETE_JOBLINES_BY_JOB_IDS = `
mutation DeleteJoblinesByJobIds($jobIds: [uuid!]!) {
delete_joblines(where: {jobid: {_in: $jobIds}}) {
affected_rows
}
}
`;
const DELETE_JOBS_BY_IDS = `
mutation DeleteJobsByIds($jobIds: [uuid!]!) {
delete_jobs(where: {id: {_in: $jobIds}}) {
affected_rows
}
}
`;
const DELETE_AUDIT_TRAIL_BY_SHOP = `
mutation DeleteAuditTrailByShop($shopId: uuid!) {
delete_audit_trail(where: {bodyshopid: {_eq: $shopId}}) {
affected_rows
}
}
`;
module.exports = {
GET_BODYSHOP_STATUS,
GET_VEHICLE_BY_SHOP_VIN,
@@ -162,5 +248,15 @@ module.exports = {
CREATE_SHOP,
DELETE_VENDORS_BY_SHOP,
DELETE_SHOP,
CREATE_USER
CREATE_USER,
GET_BODYSHOP,
GET_ASSOCIATED_USERS,
DELETE_ASSOCIATIONS_BY_SHOP,
GET_USER_ASSOCIATIONS_COUNT,
DELETE_USER,
GET_VENDORS,
GET_JOBS_BY_SHOP,
DELETE_JOBLINES_BY_JOB_IDS,
DELETE_JOBS_BY_IDS,
DELETE_AUDIT_TRAIL_BY_SHOP
};