108 lines
2.1 KiB
JavaScript
108 lines
2.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_jobid_line_no_unq_seq_key
|
|
update_columns: [
|
|
status
|
|
line_desc
|
|
part_type
|
|
part_qty
|
|
oem_partno
|
|
db_price
|
|
act_price
|
|
mod_lbr_ty
|
|
mod_lb_hrs
|
|
lbr_op
|
|
lbr_amt
|
|
notes
|
|
]
|
|
}
|
|
) {
|
|
affected_rows
|
|
}
|
|
}
|
|
`;
|
|
const DELETE_JOBLINES_BY_JOBID = `
|
|
mutation DeleteJoblinesByJobId($jobid: uuid!) {
|
|
delete_joblines(where: { jobid: { _eq: $jobid } }) {
|
|
affected_rows
|
|
}
|
|
}
|
|
`;
|
|
|
|
const INSERT_JOBLINES = `
|
|
mutation InsertJoblines($joblines: [joblines_insert_input!]!) {
|
|
insert_joblines(objects: $joblines) {
|
|
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,
|
|
DELETE_JOBLINES_BY_JOBID,
|
|
UPSERT_JOBLINES,
|
|
INSERT_JOBLINES
|
|
};
|