import { gql } from "@apollo/client"; export const INSERT_NEW_COURTESY_CAR = gql` mutation INSERT_NEW_COURTESY_CAR( $courtesycar: [courtesycars_insert_input!]! ) { insert_courtesycars(objects: $courtesycar) { returning { id } } } `; export const QUERY_AVAILABLE_CC = gql` query QUERY_AVAILABLE_CC($today: date) { courtesycars( where: { _or: [ { serviceenddate: { _is_null: true } } { serviceenddate: { _gt: $today } } ] status: { _eq: "courtesycars.status.in" } } ) { color dailycost damage fleetnumber fuel id make model plate status year dailycost mileage notes nextservicekm nextservicedate } } `; export const CHECK_CC_FLEET_NUMBER = gql` query CHECK_VENDOR_NAME($name: String!) { courtesycars_aggregate(where: { fleetnumber: { _ilike: $name } }) { aggregate { count } nodes { id } } } `; export const QUERY_ALL_CC = gql` query QUERY_ALL_CC { courtesycars { color created_at dailycost damage fleetnumber fuel id insuranceexpires leaseenddate make model nextservicedate nextservicekm notes plate purchasedate registrationexpires serviceenddate servicestartdate status vin year mileage cccontracts( where: { status: { _eq: "contracts.status.out" } } order_by: { contract_date: desc } limit: 1 ) { id scheduledreturn job { id ro_number ownr_fn ownr_ln ownr_co_nm } } } } `; export const QUERY_CC_BY_PK = gql` query QUERY_CC_BY_PK( $id: uuid! $offset: Int $limit: Int $order: [cccontracts_order_by!]! ) { courtesycars_by_pk(id: $id) { bodyshopid color created_at dailycost damage fleetnumber fuel id insuranceexpires leaseenddate make model nextservicedate nextservicekm notes plate purchasedate registrationexpires serviceenddate servicestartdate status vin year mileage cccontracts_aggregate { aggregate { count(distinct: true) } } cccontracts(offset: $offset, limit: $limit, order_by: $order) { agreementnumber id status start scheduledreturn kmstart kmend driver_ln driver_fn job { ro_number ownr_ln ownr_fn ownr_co_nm id } } } } `; export const UPDATE_CC = gql` mutation UPDATE_CC($ccId: uuid!, $cc: courtesycars_set_input!) { update_courtesycars(where: { id: { _eq: $ccId } }, _set: $cc) { returning { id } } } `;