added graphql entegration and tested tanstack query
This commit is contained in:
@@ -1,40 +0,0 @@
|
||||
import { AppSidebar } from "@/components/app-sidebar"
|
||||
import { ChartAreaInteractive } from "@/components/chart-area-interactive"
|
||||
import { DataTable } from "@/components/data-table"
|
||||
import { SectionCards } from "@/components/section-cards"
|
||||
import { SiteHeader } from "@/components/site-header"
|
||||
import {
|
||||
SidebarInset,
|
||||
SidebarProvider,
|
||||
} from "@/frontend/components/ui/sidebar"
|
||||
|
||||
import data from "./data.json"
|
||||
|
||||
export default function Page() {
|
||||
return (
|
||||
<SidebarProvider
|
||||
style={
|
||||
{
|
||||
"--sidebar-width": "calc(var(--spacing) * 72)",
|
||||
"--header-height": "calc(var(--spacing) * 12)",
|
||||
} as React.CSSProperties
|
||||
}
|
||||
>
|
||||
<AppSidebar variant="inset" />
|
||||
<SidebarInset>
|
||||
<SiteHeader />
|
||||
<div className="flex flex-1 flex-col">
|
||||
<div className="@container/main flex flex-1 flex-col gap-2">
|
||||
<div className="flex flex-col gap-4 py-4 md:gap-6 md:py-6">
|
||||
<SectionCards />
|
||||
<div className="px-4 lg:px-6">
|
||||
<ChartAreaInteractive />
|
||||
</div>
|
||||
<DataTable data={data} />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</SidebarInset>
|
||||
</SidebarProvider>
|
||||
)
|
||||
}
|
||||
61
frontend/app/api/users/list/route.ts
Normal file
61
frontend/app/api/users/list/route.ts
Normal file
@@ -0,0 +1,61 @@
|
||||
'use server';
|
||||
import { NextResponse } from 'next/server';
|
||||
import { GraphQLClient, gql } from 'graphql-request';
|
||||
|
||||
const endpoint = process.env.GRAPHQL_URL || "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 ListUsers($input: ListArguments!) {
|
||||
users(input: $input) {
|
||||
data {
|
||||
_id
|
||||
uuid
|
||||
expiryStarts
|
||||
expiryEnds
|
||||
isConfirmed
|
||||
deleted
|
||||
active
|
||||
crypUuId
|
||||
createdCredentialsToken
|
||||
updatedCredentialsToken
|
||||
confirmedCredentialsToken
|
||||
isNotificationSend
|
||||
isEmailSend
|
||||
refInt
|
||||
refId
|
||||
replicationId
|
||||
expiresAt
|
||||
resetToken
|
||||
password
|
||||
history
|
||||
tag
|
||||
email
|
||||
phone
|
||||
collectionTokens {
|
||||
default
|
||||
tokens {
|
||||
prefix
|
||||
token
|
||||
}
|
||||
}
|
||||
createdAt
|
||||
updatedAt
|
||||
}
|
||||
totalCount
|
||||
}
|
||||
}
|
||||
`;
|
||||
console.dir({ limit, skip, sort, filters }, { depth: null });
|
||||
const variables = { input: { limit, skip, sort, filters } };
|
||||
const data = await client.request(query, variables);
|
||||
return NextResponse.json({ data: data.users.data, totalCount: data.users.totalCount });
|
||||
} catch (err: any) {
|
||||
console.error(err);
|
||||
return NextResponse.json({ error: err.message }, { status: 500 });
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user