parts and areas tested

This commit is contained in:
2025-11-24 21:04:14 +03:00
parent a5a7a7e7b5
commit eedfed1a65
131 changed files with 5429 additions and 471 deletions

View File

@@ -0,0 +1,47 @@
'use server';
import { NextResponse } from 'next/server';
import { GraphQLClient, gql } from 'graphql-request';
const endpoint = "http://localhost:3001/graphql";
export async function POST(request: Request) {
const body = await request.json();
const { limit, skip, sort, filters } = body;
try {
const client = new GraphQLClient(endpoint);
const query = gql`
query BuildParts($input: ListArguments!) {
buildParts(input: $input) {
data {
_id
uuid
addressGovCode
no
level
code
grossSize
netSize
defaultAccessory
humanLivability
key
directionId
typeId
createdAt
updatedAt
expiryStarts
expiryEnds
active
isConfirmed
}
totalCount
}
}
`;
const variables = { input: { limit, skip, sort, filters } };
const data = await client.request(query, variables);
return NextResponse.json({ data: data.buildParts.data, totalCount: data.buildParts.totalCount });
} catch (err: any) {
console.error(err);
return NextResponse.json({ error: err.message }, { status: 500 });
}
}