263 lines
5.1 KiB
JavaScript
263 lines
5.1 KiB
JavaScript
// GraphQL Queries and Mutations
|
|
const GET_BODYSHOP_STATUS = `
|
|
query GetBodyshopStatus($id: uuid!) {
|
|
bodyshops_by_pk(id: $id) {
|
|
md_order_statuses
|
|
}
|
|
}
|
|
`;
|
|
|
|
const GET_VEHICLE_BY_SHOP_VIN = `
|
|
query GetVehicleByShopVin($shopid: uuid!, $v_vin: String!) {
|
|
vehicles(where: { shopid: { _eq: $shopid }, v_vin: { _eq: $v_vin } }, limit: 1) {
|
|
id
|
|
}
|
|
}
|
|
`;
|
|
|
|
const INSERT_OWNER = `
|
|
mutation InsertOwner($owner: owners_insert_input!) {
|
|
insert_owners_one(object: $owner) {
|
|
id
|
|
}
|
|
}
|
|
`;
|
|
|
|
const INSERT_JOB_WITH_LINES = `
|
|
mutation InsertJob($job: jobs_insert_input!) {
|
|
insert_jobs_one(object: $job) {
|
|
id
|
|
joblines { id unq_seq }
|
|
}
|
|
}
|
|
`;
|
|
|
|
const GET_JOB_BY_CLAIM = `
|
|
query GetJobByClaim($shopid: uuid!, $clm_no: String!) {
|
|
jobs(
|
|
where: { shopid: { _eq: $shopid }, clm_no: { _eq: $clm_no } }
|
|
order_by: { created_at: desc }
|
|
limit: 1
|
|
) {
|
|
id
|
|
}
|
|
}
|
|
`;
|
|
|
|
const UPDATE_JOB_BY_ID = `
|
|
mutation UpdateJobById($id: uuid!, $job: jobs_set_input!) {
|
|
update_jobs_by_pk(pk_columns: { id: $id }, _set: $job) {
|
|
id
|
|
}
|
|
}
|
|
`;
|
|
|
|
const UPSERT_JOBLINES = `
|
|
mutation UpsertJoblines($joblines: [joblines_insert_input!]!) {
|
|
insert_joblines(
|
|
objects: $joblines
|
|
on_conflict: {
|
|
constraint: joblines_pkey
|
|
update_columns: [
|
|
jobid
|
|
status
|
|
line_desc
|
|
part_type
|
|
part_qty
|
|
oem_partno
|
|
db_price
|
|
act_price
|
|
mod_lbr_ty
|
|
mod_lb_hrs
|
|
lbr_op
|
|
lbr_amt
|
|
notes
|
|
manual_line
|
|
]
|
|
}
|
|
) {
|
|
affected_rows
|
|
}
|
|
}
|
|
`;
|
|
|
|
const DELETE_JOBLINES_BY_JOBID = `
|
|
mutation DeleteJoblinesByJobId($jobid: uuid!) {
|
|
delete_joblines(where: { jobid: { _eq: $jobid } }) {
|
|
affected_rows
|
|
}
|
|
}
|
|
`;
|
|
|
|
const DELETE_JOBLINES_BY_IDS = `
|
|
mutation DeleteJoblinesByIds($jobid: uuid!, $unqSeqs: [Int!]!) {
|
|
delete_joblines(
|
|
where: {
|
|
jobid: { _eq: $jobid },
|
|
unq_seq: { _in: $unqSeqs }
|
|
}
|
|
) {
|
|
affected_rows
|
|
}
|
|
}
|
|
`;
|
|
|
|
const INSERT_JOBLINES = `
|
|
mutation InsertJoblines($joblines: [joblines_insert_input!]!) {
|
|
insert_joblines(objects: $joblines) {
|
|
affected_rows
|
|
}
|
|
}
|
|
`;
|
|
|
|
const CHECK_EXTERNAL_SHOP_ID = `
|
|
query CHECK_KEY($key: String!) {
|
|
bodyshops(where: { external_shop_id: { _eq: $key } }) {
|
|
external_shop_id
|
|
}
|
|
}
|
|
`;
|
|
|
|
const CREATE_SHOP = `
|
|
mutation CREATE_SHOP($bs: bodyshops_insert_input!) {
|
|
insert_bodyshops_one(object: $bs) { id }
|
|
}
|
|
`;
|
|
|
|
const DELETE_VENDORS_BY_SHOP = `
|
|
mutation DELETE_VENDORS($shopId: uuid!) {
|
|
delete_vendors(where: { bodyshopid: { _eq: $shopId } }) {
|
|
affected_rows
|
|
}
|
|
}
|
|
`;
|
|
|
|
const DELETE_SHOP = `
|
|
mutation DELETE_SHOP($id: uuid!) {
|
|
delete_bodyshops_by_pk(id: $id) { id }
|
|
}
|
|
`;
|
|
|
|
const CREATE_USER = `
|
|
mutation CREATE_USER($u: users_insert_input!) {
|
|
insert_users_one(object: $u) {
|
|
id: authid
|
|
email
|
|
}
|
|
}
|
|
`;
|
|
|
|
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,
|
|
INSERT_OWNER,
|
|
INSERT_JOB_WITH_LINES,
|
|
GET_JOB_BY_CLAIM,
|
|
UPDATE_JOB_BY_ID,
|
|
UPSERT_JOBLINES,
|
|
DELETE_JOBLINES_BY_JOBID,
|
|
DELETE_JOBLINES_BY_IDS,
|
|
INSERT_JOBLINES,
|
|
CHECK_EXTERNAL_SHOP_ID,
|
|
CREATE_SHOP,
|
|
DELETE_VENDORS_BY_SHOP,
|
|
DELETE_SHOP,
|
|
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
|
|
};
|