Resolve cc contract car query error with service dates IO-728
This commit is contained in:
@@ -3,9 +3,12 @@ import React from "react";
|
|||||||
import { QUERY_AVAILABLE_CC } from "../../graphql/courtesy-car.queries";
|
import { QUERY_AVAILABLE_CC } from "../../graphql/courtesy-car.queries";
|
||||||
import AlertComponent from "../alert/alert.component";
|
import AlertComponent from "../alert/alert.component";
|
||||||
import ContractCarsComponent from "./contract-cars.component";
|
import ContractCarsComponent from "./contract-cars.component";
|
||||||
|
import moment from "moment";
|
||||||
|
|
||||||
export default function ContractCarsContainer({ selectedCarState, form }) {
|
export default function ContractCarsContainer({ selectedCarState, form }) {
|
||||||
const { loading, error, data } = useQuery(QUERY_AVAILABLE_CC);
|
const { loading, error, data } = useQuery(QUERY_AVAILABLE_CC, {
|
||||||
|
variables: { today: moment().format("YYYY-MM-DD") },
|
||||||
|
});
|
||||||
|
|
||||||
const [selectedCar, setSelectedCar] = selectedCarState;
|
const [selectedCar, setSelectedCar] = selectedCarState;
|
||||||
|
|
||||||
|
|||||||
@@ -13,28 +13,24 @@ export const INSERT_NEW_COURTESY_CAR = gql`
|
|||||||
`;
|
`;
|
||||||
|
|
||||||
export const QUERY_AVAILABLE_CC = gql`
|
export const QUERY_AVAILABLE_CC = gql`
|
||||||
query QUERY_AVAILABLE_CC {
|
query QUERY_AVAILABLE_CC($today: date) {
|
||||||
courtesycars(
|
courtesycars(where: {_or: [{serviceenddate: {_is_null: true}}, {serviceenddate: {_gt: $today}}], status: {_eq: "courtesycars.status.in"}}) {
|
||||||
where: {
|
color
|
||||||
serviceenddate: { _is_null: true }
|
dailycost
|
||||||
status: { _eq: "courtesycars.status.in" }
|
damage
|
||||||
}
|
fleetnumber
|
||||||
) {
|
fuel
|
||||||
color
|
id
|
||||||
dailycost
|
make
|
||||||
damage
|
model
|
||||||
fleetnumber
|
plate
|
||||||
fuel
|
status
|
||||||
id
|
year
|
||||||
make
|
dailycost
|
||||||
model
|
mileage
|
||||||
plate
|
|
||||||
status
|
|
||||||
year
|
|
||||||
dailycost
|
|
||||||
mileage
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
`;
|
`;
|
||||||
|
|
||||||
export const QUERY_ALL_CC = gql`
|
export const QUERY_ALL_CC = gql`
|
||||||
|
|||||||
Reference in New Issue
Block a user