Skip to content

Commit

Permalink
Fixed newtworking issue
Browse files Browse the repository at this point in the history
  • Loading branch information
Rajdip019 committed Jun 7, 2024
1 parent a69451c commit a009177
Show file tree
Hide file tree
Showing 8 changed files with 111 additions and 197 deletions.
Binary file added .DS_Store
Binary file not shown.
13 changes: 0 additions & 13 deletions compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,4 @@ services:
SMTP_PORT: ${SMTP_PORT}
ports:
- 25:25

dashboard:
build:
context: ./dashboard
target: dev
ports:
- "3000:3000"
environment:
NEXT_PUBLIC_API_BASE_URL: ${NEXT_PUBLIC_API_BASE_URL}
X_API_KEY: ${X_API_KEY}
NEXT_PUBLIC_ENDPOINT: ${NEXT_PUBLIC_ENDPOINT}
volumes:
- ./dashboard:/app

34 changes: 0 additions & 34 deletions dashboard/.dockerignore

This file was deleted.

35 changes: 0 additions & 35 deletions dashboard/Dockerfile

This file was deleted.

24 changes: 24 additions & 0 deletions dashboard/app/api/user/get-all/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
export async function GET(req: Request) {
const endPoint: (string | undefined) = `${process.env.NEXT_PUBLIC_API_BASE_URL}/api/user/get-all`

console.log('endPoint', endPoint);
console.log('process.env.X_API_KEY', process.env.X_API_KEY);


if (endPoint) {
try {
console.log('Fetching Users');

const res = await fetch(endPoint, {
headers: {
'Content-Type': 'application/json', // Set the appropriate content type for your request
'x-api-key': process.env.X_API_KEY!,
},
});
const data = await res.json();
return Response.json({ data })
} catch (error) {
console.error('Error during request:', error);
}
}
}
25 changes: 0 additions & 25 deletions dashboard/app/dashboard/fetch-users/route.ts

This file was deleted.

82 changes: 0 additions & 82 deletions dashboard/app/dashboard/page.tsx

This file was deleted.

95 changes: 87 additions & 8 deletions dashboard/app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,89 @@
"use client";
import React from 'react';

export default function Page(): JSX.Element {
return (
<div className="w-screen flex justify-center items-center h-screen">
<h1 className='text-primary'>FlexAuth Dashboard</h1>
</div>
);
import { Loader } from '@/components/custom/Loader';
import { IUser } from '@/interfaces/IUser';
import React, { useEffect, useState } from 'react'
import { ColumnDef } from "@tanstack/react-table";
import { DataTable } from '@/components/ui/data-table';

const DashboardPage = () => {
const [users, setUsers] = useState([] as IUser[])
const [loading, setLoading] = useState(true)

const getAllUsers = async () => {
try{
setLoading(true)
const res = await fetch(`${process.env.NEXT_PUBLIC_ENDPOINT}/api/user/get-all`, {
method: 'GET',
headers: {
'Content-Type': 'application/json',
},
});
const { data } = await res.json();
setUsers(data);
} catch (error) {
console.error('Error during POST request:', error);
}
setLoading(false)
}

const columns: ColumnDef<IUser>[] = [
{
accessorKey: "name",
header: "Name",
},
{
accessorKey: "email",
header: "Email",
},
{
accessorKey: "role",
header: "Role",
},
{
accessorKey: "email_verified",
header: "Email Verified",
},
{
accessorKey: "is_active",
header: "Active",
},
{
accessorKey: "created_at",
header: "Created At",
cell: ({ row }) => {
return (
<div>
{new Date(parseInt(row.original.created_at.$date.$numberLong)).toLocaleString()}
</div>
)
},
},
];

useEffect(() => {
getAllUsers()
}, [])

return (
<div className='p-6'>
<div>
{
loading ?
<div className='h-[100vh] flex justify-center items-center'>
<Loader />
</div>
: <div>
<h1 className='text-3xl text-primary mb-4'>Dashboard</h1>
<DataTable
data={users ? users : []}
columns={columns}
/>
</div>
}
</div>

</div>
)
}

export default DashboardPage

0 comments on commit a009177

Please sign in to comment.