updated living space added
This commit is contained in:
@@ -8,6 +8,9 @@ const endpoint = "http://localhost:3001/graphql";
|
||||
export async function POST(request: Request) {
|
||||
const body = await request.json();
|
||||
const validatedBody = buildIbansAddSchema.parse(body);
|
||||
const url = new URL(request.url)
|
||||
const buildID = url.searchParams.get('build');
|
||||
if (!buildID) { return NextResponse.json({ error: 'Build ID is required' }, { status: 400 }) }
|
||||
try {
|
||||
const client = new GraphQLClient(endpoint);
|
||||
const query = gql`
|
||||
@@ -22,7 +25,7 @@ export async function POST(request: Request) {
|
||||
}
|
||||
}
|
||||
`;
|
||||
const variables = { input: validatedBody };
|
||||
const variables = { input: { ...validatedBody, buildId: buildID } };
|
||||
const data = await client.request(query, variables);
|
||||
return NextResponse.json({ data: data.createBuildIban, status: 200 });
|
||||
} catch (err: any) {
|
||||
|
||||
37
frontend/app/api/living-space/detail/route.ts
Normal file
37
frontend/app/api/living-space/detail/route.ts
Normal file
@@ -0,0 +1,37 @@
|
||||
'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 { uuid, buildID } = body;
|
||||
try {
|
||||
const client = new GraphQLClient(endpoint);
|
||||
const query = gql`
|
||||
query GetLivingSpaceDetail($uuid: String!, $buildID: String!) {
|
||||
getLivingSpaceDetail(uuid: $uuid, buildID: $buildID) {
|
||||
_id
|
||||
company {_id}
|
||||
userType {_id}
|
||||
build {_id}
|
||||
person {_id}
|
||||
part {_id}
|
||||
}
|
||||
}
|
||||
`;
|
||||
const variables = { uuid, buildID };
|
||||
const data = await client.request(query, variables);
|
||||
if (!data?.getLivingSpaceDetail) { return NextResponse.json({ error: 'Living space not found' }, { status: 404 }) };
|
||||
return NextResponse.json({
|
||||
data: {
|
||||
_id: data.getLivingSpaceDetail._id, company: data.getLivingSpaceDetail?.company?._id, userType: data.getLivingSpaceDetail.userType._id,
|
||||
build: data.getLivingSpaceDetail.build._id, person: data.getLivingSpaceDetail.person._id, part: data.getLivingSpaceDetail.part._id,
|
||||
}
|
||||
});
|
||||
} catch (err: any) {
|
||||
console.error(err);
|
||||
return NextResponse.json({ error: err.message }, { status: 500 });
|
||||
}
|
||||
}
|
||||
43
frontend/app/api/living-space/list/oldroute.ts
Normal file
43
frontend/app/api/living-space/list/oldroute.ts
Normal file
@@ -0,0 +1,43 @@
|
||||
'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, buildID } = body;
|
||||
try {
|
||||
const client = new GraphQLClient(endpoint);
|
||||
const query = gql`
|
||||
query GetLivingSpaces($input: ListArguments!, $buildID: String!) {
|
||||
getLivingSpaces(input: $input, buildID: $buildID) {
|
||||
data {
|
||||
_id
|
||||
uuid
|
||||
build
|
||||
part
|
||||
userType
|
||||
company
|
||||
person
|
||||
isNotificationSend
|
||||
expiryEnds
|
||||
expiryStarts
|
||||
createdAt
|
||||
updatedAt
|
||||
isConfirmed
|
||||
deleted
|
||||
|
||||
}
|
||||
totalCount
|
||||
}
|
||||
}
|
||||
`;
|
||||
const variables = { input: { limit, skip, sort, filters }, buildID };
|
||||
const data = await client.request(query, variables);
|
||||
return NextResponse.json({ data: data.getLivingSpaces.data, totalCount: data.getLivingSpaces.totalCount });
|
||||
} catch (err: any) {
|
||||
console.error(err);
|
||||
return NextResponse.json({ error: err.message }, { status: 500 });
|
||||
}
|
||||
}
|
||||
@@ -10,26 +10,42 @@ export async function POST(request: Request) {
|
||||
try {
|
||||
const client = new GraphQLClient(endpoint);
|
||||
const query = gql`
|
||||
query GetLivingSpaces($input: ListArguments!, $buildID: String!) {
|
||||
getLivingSpaces(input: $input, buildID: $buildID) {
|
||||
query GetLivingSpaces($buildID: String!, $input: ListArguments!) {
|
||||
getLivingSpaces(buildID: $buildID, input: $input) {
|
||||
data {
|
||||
_id
|
||||
uuid
|
||||
build
|
||||
part
|
||||
userType
|
||||
company
|
||||
person
|
||||
isNotificationSend
|
||||
expiryEnds
|
||||
expiryStarts
|
||||
createdAt
|
||||
updatedAt
|
||||
isConfirmed
|
||||
deleted
|
||||
|
||||
expiryStarts
|
||||
expiryEnds
|
||||
build {
|
||||
info {
|
||||
buildName
|
||||
buildNo
|
||||
}
|
||||
}
|
||||
part {
|
||||
no
|
||||
level
|
||||
humanLivability
|
||||
}
|
||||
person {
|
||||
firstName
|
||||
middleName
|
||||
surname
|
||||
birthDate
|
||||
birthPlace
|
||||
}
|
||||
userType {
|
||||
isProperty
|
||||
description
|
||||
}
|
||||
company {
|
||||
uuid
|
||||
}
|
||||
}
|
||||
totalCount
|
||||
totalCount
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
@@ -10,25 +10,23 @@ export async function POST(request: Request) {
|
||||
console.log("BODY")
|
||||
console.dir({ body })
|
||||
const validatedBody = userAddSchema.parse(body);
|
||||
validatedBody.person = "6917732face2287b1d901738"
|
||||
try {
|
||||
const client = new GraphQLClient(endpoint);
|
||||
const query = gql`
|
||||
mutation CreateUser($input: CreateUserInput!) {
|
||||
createUser(input: $input) {
|
||||
_id
|
||||
password
|
||||
tag
|
||||
email
|
||||
phone
|
||||
collectionTokens {
|
||||
default
|
||||
tokens {
|
||||
prefix
|
||||
token
|
||||
_id
|
||||
password
|
||||
tag
|
||||
email
|
||||
phone
|
||||
tag
|
||||
collectionTokens {
|
||||
defaultSelection
|
||||
selectedBuildIDS
|
||||
selectedCompanyIDS
|
||||
}
|
||||
}
|
||||
person
|
||||
person
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
@@ -1,29 +1,21 @@
|
||||
import { z } from "zod"
|
||||
|
||||
export const tokenSchema = z.object({
|
||||
prefix: z.string().min(1, "Prefix is required"),
|
||||
token: z.string().min(1, "Token is required"),
|
||||
})
|
||||
|
||||
export const collectionTokensSchema = z.object({
|
||||
default: z.string().optional(),
|
||||
tokens: z.array(tokenSchema)
|
||||
})
|
||||
|
||||
export const userAddSchema = z.object({
|
||||
|
||||
expiryStarts: z.string().optional(),
|
||||
expiryEnds: z.string().optional(),
|
||||
|
||||
isConfirmed: z.boolean(),
|
||||
isNotificationSend: z.boolean(),
|
||||
|
||||
password: z.string().min(6),
|
||||
tag: z.string().optional(),
|
||||
email: z.string().email(),
|
||||
phone: z.string().min(5),
|
||||
person: z.string().optional(),
|
||||
person: z.string(),
|
||||
collectionTokens: z.object({
|
||||
defaultSelection: z.string(),
|
||||
selectedBuildIDS: z.array(z.string()),
|
||||
selectedCompanyIDS: z.array(z.string()),
|
||||
}).optional()
|
||||
|
||||
collectionTokens: collectionTokensSchema,
|
||||
})
|
||||
|
||||
export type UserAdd = z.infer<typeof userAddSchema>
|
||||
|
||||
@@ -36,17 +36,16 @@ export async function POST(request: Request) {
|
||||
tag
|
||||
email
|
||||
phone
|
||||
person
|
||||
collectionTokens {
|
||||
default
|
||||
tokens {
|
||||
prefix
|
||||
token
|
||||
}
|
||||
defaultSelection
|
||||
selectedBuildIDS
|
||||
selectedCompanyIDS
|
||||
}
|
||||
createdAt
|
||||
updatedAt
|
||||
}
|
||||
totalCount
|
||||
totalCount
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
@@ -1,28 +1,20 @@
|
||||
import { z } from "zod"
|
||||
|
||||
export const tokenSchema = z.object({
|
||||
prefix: z.string().min(1, "Prefix is required").optional(),
|
||||
token: z.string().min(1, "Token is required").optional(),
|
||||
})
|
||||
|
||||
export const collectionTokensSchema = z.object({
|
||||
default: z.string().optional(),
|
||||
tokens: z.array(tokenSchema).optional()
|
||||
})
|
||||
|
||||
export const userUpdateSchema = z.object({
|
||||
|
||||
expiryStarts: z.string().optional(),
|
||||
expiryEnds: z.string().optional(),
|
||||
|
||||
isConfirmed: z.boolean().optional(),
|
||||
isNotificationSend: z.boolean().optional(),
|
||||
|
||||
isConfirmed: z.boolean(),
|
||||
isNotificationSend: z.boolean(),
|
||||
tag: z.string().optional(),
|
||||
email: z.string().email().optional(),
|
||||
phone: z.string().min(5).optional(),
|
||||
person: z.string().optional(),
|
||||
|
||||
collectionTokens: collectionTokensSchema,
|
||||
email: z.string().email(),
|
||||
phone: z.string().min(5),
|
||||
person: z.string(),
|
||||
collectionTokens: z.object({
|
||||
defaultSelection: z.string(),
|
||||
selectedBuildIDS: z.array(z.string()),
|
||||
selectedCompanyIDS: z.array(z.string()),
|
||||
}).optional()
|
||||
})
|
||||
|
||||
export type UserUpdate = z.infer<typeof userUpdateSchema>
|
||||
|
||||
Reference in New Issue
Block a user