parts and areas tested
This commit is contained in:
53
frontend/app/api/builds/list/route.ts
Normal file
53
frontend/app/api/builds/list/route.ts
Normal file
@@ -0,0 +1,53 @@
|
||||
'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 ListBuild($input: ListArguments!) {
|
||||
builds(input: $input) {
|
||||
data {
|
||||
_id
|
||||
collectionToken
|
||||
buildType {
|
||||
token
|
||||
typeToken
|
||||
type
|
||||
}
|
||||
info {
|
||||
govAddressCode
|
||||
buildName
|
||||
buildNo
|
||||
maxFloor
|
||||
undergroundFloor
|
||||
buildDate
|
||||
decisionPeriodDate
|
||||
taxNo
|
||||
liftCount
|
||||
heatingSystem
|
||||
coolingSystem
|
||||
hotWaterSystem
|
||||
blockServiceManCount
|
||||
securityServiceManCount
|
||||
garageCount
|
||||
managementRoomId
|
||||
}
|
||||
}
|
||||
totalCount
|
||||
}
|
||||
}
|
||||
`;
|
||||
const variables = { input: { limit, skip, sort, filters } };
|
||||
const data = await client.request(query, variables);
|
||||
return NextResponse.json({ data: data.builds.data, totalCount: data.builds.totalCount });
|
||||
} catch (err: any) {
|
||||
console.error(err);
|
||||
return NextResponse.json({ error: err.message }, { status: 500 });
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user