Add opcode and bodyshop query to main

This commit is contained in:
Patrick Fic
2025-03-21 08:33:41 -07:00
parent 6345b5a9a8
commit 6da5822197
9 changed files with 199 additions and 40 deletions

View File

@@ -6,6 +6,13 @@ import ipcTypes from "../../util/ipcTypes.json";
const requestMiddleware: RequestMiddleware = async (request) => {
const token = await getTokenFromRenderer();
log.info(
`%c[Graphql Request]%c${request.operationName}`,
"color: red",
"color: green",
request
);
return {
...request,
headers: { ...request.headers, Authorization: `Bearer ${token}` },

View File

@@ -0,0 +1,73 @@
import { parse, TypedQueryDocumentNode } from "graphql";
import { gql } from "graphql-request";
// Define types for the query result and variables
export interface ActiveBodyshopQueryResult {
bodyshops: Array<{
id: string;
shopname: string;
region_config: string;
}>;
}
// No variables needed for this query
interface ActiveBodyshopQueryVariables {}
// Transform the string query into a TypedQueryDocumentNode
export const QUERY_ACTIVE_BODYSHOP_TYPED: TypedQueryDocumentNode<
ActiveBodyshopQueryResult,
ActiveBodyshopQueryVariables
> = parse(gql`
query QUERY_ACTIVE_BODYSHOP {
bodyshops(where: { associations: { active: { _eq: true } } }) {
id
shopname
region_config
}
}
`);
export interface MasterdataQueryResult {
masterdata: Array<{
value: string;
key: string;
}>;
}
interface MasterdataQueryVariables {
key: string;
}
export const QUERY_MASTERDATA_TYPED: TypedQueryDocumentNode<
MasterdataQueryResult,
MasterdataQueryVariables
> = parse(gql`
query QUERY_MASTERDATA($key: String!) {
masterdata(where: { key: { _eq: $key } }) {
value
key
}
}
`);
export interface VehicleQueryResult {
masterdata: Array<{
value: string;
key: string;
}>;
}
interface VehicleQueryVariables {
vin: string;
}
export const QUERY_VEHICLE_BY_VIN_TYPED: TypedQueryDocumentNode<
VehicleQueryResult,
VehicleQueryVariables
> = parse(gql`
query QUERY_VEHICLE_BY_VIN($vin: String!) {
vehicles(where: { v_vin: { _eq: $vin } }) {
id
}
}
`);