parts and areas tested
This commit is contained in:
@@ -27,8 +27,7 @@ export async function POST(request: Request) {
|
||||
}
|
||||
}
|
||||
`;
|
||||
const variables = { input: validatedBody };
|
||||
const data = await client.request(query, variables);
|
||||
const data = await client.request(query, { input: validatedBody });
|
||||
return NextResponse.json({ data: data.createBuildArea, status: 200 });
|
||||
} catch (err: any) {
|
||||
console.error(err);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { z } from "zod"
|
||||
|
||||
export const buildAreaAddSchema = z.object({
|
||||
buildId: z.string(),
|
||||
areaName: z.string(),
|
||||
areaCode: z.string(),
|
||||
areaType: z.string(),
|
||||
@@ -10,7 +11,7 @@ export const buildAreaAddSchema = z.object({
|
||||
width: z.number(),
|
||||
size: z.number(),
|
||||
expiryStarts: z.string().optional(),
|
||||
expiryEnds: z.string().optional(),
|
||||
expiryEnds: z.string().optional()
|
||||
});
|
||||
|
||||
export type BuildAreaAdd = z.infer<typeof buildAreaAddSchema>;
|
||||
|
||||
@@ -12,26 +12,25 @@ export async function POST(request: Request) {
|
||||
const query = gql`
|
||||
query BuildAreas($input: ListArguments!) {
|
||||
buildAreas(input: $input) {
|
||||
data {
|
||||
_id
|
||||
uuid
|
||||
createdAt
|
||||
areaName
|
||||
areaCode
|
||||
areaType
|
||||
areaDirection
|
||||
areaGrossSize
|
||||
areaNetSize
|
||||
width
|
||||
size
|
||||
expiryStarts
|
||||
expiryEnds
|
||||
}
|
||||
data {
|
||||
_id
|
||||
uuid
|
||||
createdAt
|
||||
areaName
|
||||
areaCode
|
||||
areaType
|
||||
areaDirection
|
||||
areaGrossSize
|
||||
areaNetSize
|
||||
width
|
||||
size
|
||||
expiryStarts
|
||||
expiryEnds
|
||||
}
|
||||
totalCount
|
||||
}
|
||||
}`;
|
||||
const variables = { input: { limit, skip, sort, filters } };
|
||||
console.dir({ variables })
|
||||
const data = await client.request(query, variables);
|
||||
return NextResponse.json({ data: data.buildAreas.data, totalCount: data.buildAreas.totalCount });
|
||||
} catch (err: any) {
|
||||
|
||||
@@ -14,24 +14,13 @@ export async function POST(request: Request) {
|
||||
try {
|
||||
const client = new GraphQLClient(endpoint);
|
||||
const query = gql`
|
||||
mutation UpdateBuildAddress($uuid: String!, $input: UpdateBuildAddressInput!) {
|
||||
updateBuildAddress(uuid: $uuid, input: $input) {
|
||||
_id
|
||||
buildNumber
|
||||
doorNumber
|
||||
floorNumber
|
||||
commentAddress
|
||||
letterAddress
|
||||
shortLetterAddress
|
||||
latitude
|
||||
longitude
|
||||
street
|
||||
}
|
||||
mutation UpdateBuildArea($uuid:String!, $input: UpdateBuildAreaInput!) {
|
||||
updateBuildArea(uuid: $uuid, input: $input) { _id }
|
||||
}
|
||||
`;
|
||||
const variables = { uuid: uuid, input: validatedBody };
|
||||
const data = await client.request(query, variables);
|
||||
return NextResponse.json({ data: data.updateBuildAddress, status: 200 });
|
||||
return NextResponse.json({ data: data.updateBuildArea, status: 200 });
|
||||
} catch (err: any) {
|
||||
console.error(err);
|
||||
return NextResponse.json({ error: err.message }, { status: 500 });
|
||||
|
||||
@@ -1,15 +1,17 @@
|
||||
import { z } from "zod"
|
||||
|
||||
export const UpdateBuildAddressSchema = z.object({
|
||||
buildNumber: z.string().optional(),
|
||||
doorNumber: z.string().optional(),
|
||||
floorNumber: z.string().optional(),
|
||||
commentAddress: z.string().optional(),
|
||||
letterAddress: z.string().optional(),
|
||||
shortLetterAddress: z.string().optional(),
|
||||
latitude: z.number().optional(),
|
||||
longitude: z.number().optional(),
|
||||
street: z.string().optional(),
|
||||
buildId: z.string(),
|
||||
areaName: z.string(),
|
||||
areaCode: z.string(),
|
||||
areaType: z.string(),
|
||||
areaDirection: z.string(),
|
||||
areaGrossSize: z.number(),
|
||||
areaNetSize: z.number(),
|
||||
width: z.number(),
|
||||
size: z.number(),
|
||||
expiryStarts: z.string().optional(),
|
||||
expiryEnds: z.string().optional()
|
||||
});
|
||||
|
||||
export type UpdateBuildAddress = z.infer<typeof UpdateBuildAddressSchema>;
|
||||
|
||||
Reference in New Issue
Block a user