import { gql } from "apollo-boost";

export const QUERY_VEHICLE_BY_ID = gql`
  query QUERY_VEHICLE_BY_ID($id: uuid!) {
    vehicles_by_pk(id: $id) {
      created_at
      db_v_code
      id
      plate_no
      plate_st
      v_vin
      v_type
      v_trimcode
      v_tone
      v_stage
      v_prod_dt
      v_paint_codes
      v_options
      v_model_yr
      v_model_desc
      v_mldgcode
      v_makecode
      v_make_desc
      v_engine
      v_cond
      v_color
      v_bstyle
      updated_at
      trim_color
      jobs {
        id
        ro_number
        ownr_fn
        est_number
        ownr_ln
        owner {
          id
        }
        clm_no
        status
        clm_total
      }
    }
  }
`;

export const UPDATE_VEHICLE = gql`
  mutation UPDATE_VEHICLE($vehId: uuid!, $vehicle: vehicles_set_input!) {
    update_vehicles(where: { id: { _eq: $vehId } }, _set: $vehicle) {
      returning {
        id
      }
    }
  }
`;

export const QUERY_ALL_VEHICLES = gql`
  query QUERY_ALL_VEHICLES {
    vehicles {
      id
      plate_no
      plate_st
      v_vin
      v_model_yr
      v_model_desc
      v_make_desc
      v_color
      v_bstyle
      updated_at
    }
  }
`;
