updated living space add list updagte
This commit is contained in:
@@ -2,7 +2,6 @@ import { z } from "zod"
|
||||
|
||||
export const CreateLivingSpaceInputSchema = z.object({
|
||||
buildID: z.string(),
|
||||
collectionToken: z.string(),
|
||||
partID: z.string(),
|
||||
userTypeID: z.string(),
|
||||
companyID: z.string(),
|
||||
|
||||
@@ -8,12 +8,13 @@ export async function GET(request: Request) {
|
||||
|
||||
const searchParams = new URL(request.url).searchParams;
|
||||
const uuid = searchParams.get('uuid');
|
||||
console.dir({ uuid }, { depth: null });
|
||||
const buildID = searchParams.get('buildID');
|
||||
console.dir({ uuid, buildID }, { depth: null });
|
||||
if (!uuid) { return NextResponse.json({ error: 'UUID not found in search params' }, { status: 400 }) }
|
||||
try {
|
||||
const client = new GraphQLClient(endpoint);
|
||||
const query = gql`mutation DeleteCompany($uuid: String!) { deleteCompany(uuid: $uuid) }`;
|
||||
const data = await client.request(query, { uuid });
|
||||
const query = gql`mutation DeleteCompany($buildID: String!, $uuid: String!) { deleteCompany(buildID: $buildID, uuid: $uuid) }`;
|
||||
const data = await client.request(query, { buildID, uuid });
|
||||
return NextResponse.json({ data: data.deleteUserType, status: 200 });
|
||||
} catch (err: any) {
|
||||
console.error(err);
|
||||
|
||||
@@ -6,40 +6,36 @@ const endpoint = "http://localhost:3001/graphql";
|
||||
|
||||
export async function POST(request: Request) {
|
||||
const body = await request.json();
|
||||
const { limit, skip, sort, filters } = body;
|
||||
const { limit, skip, sort, filters, buildID } = body;
|
||||
try {
|
||||
const client = new GraphQLClient(endpoint);
|
||||
const query = gql`
|
||||
query GetCompanies($input: ListArguments!) {
|
||||
getCompanies(input:$input) {
|
||||
query GetLivingSpaces($input: ListArguments!, $buildID: String!) {
|
||||
getLivingSpaces(input: $input, buildID: $buildID) {
|
||||
data {
|
||||
_id
|
||||
uuid
|
||||
company_type
|
||||
commercial_type
|
||||
tax_no
|
||||
default_lang_type
|
||||
default_money_type
|
||||
is_commercial
|
||||
is_blacklist
|
||||
workplace_no
|
||||
official_address
|
||||
top_responsible_company
|
||||
parent_id
|
||||
company_tag
|
||||
formal_name
|
||||
public_name
|
||||
parent_id
|
||||
expiryStarts
|
||||
build
|
||||
part
|
||||
userType
|
||||
company
|
||||
person
|
||||
isNotificationSend
|
||||
expiryEnds
|
||||
expiryStarts
|
||||
createdAt
|
||||
updatedAt
|
||||
isConfirmed
|
||||
deleted
|
||||
|
||||
}
|
||||
totalCount
|
||||
}
|
||||
}
|
||||
`;
|
||||
const variables = { input: { limit, skip, sort, filters } };
|
||||
const variables = { input: { limit, skip, sort, filters }, buildID };
|
||||
const data = await client.request(query, variables);
|
||||
return NextResponse.json({ data: data.getCompanies.data, totalCount: data.getCompanies.totalCount });
|
||||
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 });
|
||||
|
||||
@@ -8,13 +8,15 @@ const endpoint = "http://localhost:3001/graphql";
|
||||
export async function POST(request: Request) {
|
||||
const searchUrl = new URL(request.url);
|
||||
const uuid = searchUrl.searchParams.get("uuid") || "";
|
||||
const buildID = searchUrl.searchParams.get("buildID") || "";
|
||||
if (uuid === "") { return NextResponse.json({ error: "UUID is required" }, { status: 400 }) }
|
||||
if (buildID === "") { return NextResponse.json({ error: "Build ID is required" }, { status: 400 }) }
|
||||
const body = await request.json();
|
||||
const validatedBody = UpdateLivingSpaceInputSchema.parse(body);
|
||||
try {
|
||||
const client = new GraphQLClient(endpoint);
|
||||
const query = gql`mutation UpdateLivingSpace($uuid: String!, $input: UpdateLivingSpaceInput!) { updateLivingSpace(uuid:$uuid, input: $input) {_id} }`;
|
||||
const variables = { uuid: uuid, input: { ...validatedBody } };
|
||||
const query = gql`mutation UpdateLivingSpace($buildID:String!, $uuid: String!, $input: UpdateLivingSpaceInput!) { updateLivingSpace(buildID: $buildID, uuid: $uuid, input: $input) {_id}} `;
|
||||
const variables = { uuid: uuid, buildID: buildID, input: { ...validatedBody } };
|
||||
const data = await client.request(query, variables);
|
||||
return NextResponse.json({ data: data.updateLivingSpace, status: 200 });
|
||||
} catch (err: any) {
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
import { z } from "zod"
|
||||
|
||||
export const UpdateLivingSpaceInputSchema = z.object({
|
||||
buildID: z.string(),
|
||||
collectionToken: z.string(),
|
||||
partID: z.string(),
|
||||
userTypeID: z.string(),
|
||||
companyID: z.string(),
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// import { PageLivingSpace } from "@/pages/living-space/add/page"
|
||||
import { PageLivingSpaceList } from "@/pages/living-space/list/page";
|
||||
|
||||
const SSRPageLivingSpace = () => { return <><div>PageLivingSpace</div></> }
|
||||
const SSRPageLivingSpace = () => { return <><div><PageLivingSpaceList /></div></> }
|
||||
|
||||
export default SSRPageLivingSpace;
|
||||
|
||||
5
frontend/app/living-spaces/update/page.tsx
Normal file
5
frontend/app/living-spaces/update/page.tsx
Normal file
@@ -0,0 +1,5 @@
|
||||
import { PageLivingSpaceUpdate } from "@/pages/living-space/update/page";
|
||||
|
||||
const LivingSpaceUpdatePage = () => { return <PageLivingSpaceUpdate /> }
|
||||
|
||||
export default LivingSpaceUpdatePage;
|
||||
Reference in New Issue
Block a user