import { gql } from "@apollo/client";

export const QUERY_AVAILABLE_JOBS = gql`
  query QUERY_AVAILABLE_JOBS {
    available_jobs(order_by: { updated_at: desc }) {
      cieca_id
      clm_amt
      clm_no
      created_at
      id
      issupplement
      ownr_name
      source_system
      supplement_number
      updated_at
      uploaded_by
      ins_co_nm
      vehicle_info
      job {
        id
        ro_number
        status
      }
    }
  }
`;

export const QUERY_AVAILABLE_NEW_JOBS = gql`
  query QUERY_AVAILABLE_NEW_JOBS {
    available_jobs(where: { issupplement: { _eq: false } }, order_by: { updated_at: desc }) {
      cieca_id
      clm_amt
      clm_no
      created_at
      id
      issupplement
      ownr_name
      source_system
      supplement_number
      updated_at
      uploaded_by
      ins_co_nm
      vehicle_info
    }
  }
`;

export const QUERY_AVAILABLE_SUPPLEMENT_JOBS = gql`
  query QUERY_AVAILABLE_SUPPLEMENT_JOBS {
    available_jobs(where: { issupplement: { _eq: true } }, order_by: { updated_at: desc }) {
      cieca_id
      clm_amt
      clm_no
      created_at
      id
      issupplement
      ownr_name
      source_system
      supplement_number
      updated_at
      uploaded_by
      ins_co_nm
      vehicle_info
      job {
        id
        ro_number
      }
    }
  }
`;

export const DELETE_AVAILABLE_JOB = gql`
  mutation DELETE_AVAILABLE_JOB($id: uuid) {
    delete_available_jobs(where: { id: { _eq: $id } }) {
      affected_rows
    }
  }
`;

export const DELETE_ALL_AVAILABLE_JOBS = gql`
  mutation DELETE_ALL_AVAILABLE_JOBS {
    delete_available_jobs(where: {}) {
      affected_rows
    }
  }
`;

export const DELETE_ALL_AVAILABLE_NEW_JOBS = gql`
  mutation DELETE_ALL_AVAILABLE_NEW_JOBS {
    delete_available_jobs(where: { issupplement: { _eq: false } }) {
      affected_rows
    }
  }
`;

export const DELETE_ALL_AVAILABLE_SUPPLEMENT_JOBS = gql`
  mutation DELETE_ALL_AVAILABLE_NEW_JOBS {
    delete_available_jobs(where: { issupplement: { _eq: true } }) {
      affected_rows
    }
  }
`;

export const QUERY_AVAILABLE_NEW_JOBS_EST_DATA_BY_PK = gql`
  query QUERY_AVAILABLE_NEW_JOBS_EST_DATA_BY_PK($id: uuid!) {
    available_jobs_by_pk(id: $id) {
      id
      issupplement
      est_data
    }
  }
`;
