diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..a7c4c0b Binary files /dev/null and b/.DS_Store differ diff --git a/compose.yaml b/compose.yaml index 6b876e5..db222b8 100644 --- a/compose.yaml +++ b/compose.yaml @@ -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 diff --git a/dashboard/.dockerignore b/dashboard/.dockerignore deleted file mode 100644 index fd00eaa..0000000 --- a/dashboard/.dockerignore +++ /dev/null @@ -1,34 +0,0 @@ -# Include any files or directories that you don't want to be copied to your -# container here (e.g., local build artifacts, temporary files, etc.). -# -# For more help, visit the .dockerignore file reference guide at -# https://docs.docker.com/go/build-context-dockerignore/ - -**/.classpath -**/.dockerignore -**/.env -**/.git -**/.gitignore -**/.project -**/.settings -**/.toolstarget -**/.vs -**/.vscode -**/.next -**/.cache -**/*.*proj.user -**/*.dbmdl -**/*.jfm -**/charts -**/docker-compose* -**/compose* -**/Dockerfile* -**/node_modules -**/npm-debug.log -**/obj -**/secrets.dev.yaml -**/values.dev.yaml -**/build -**/dist -LICENSE -README.md diff --git a/dashboard/Dockerfile b/dashboard/Dockerfile deleted file mode 100644 index 24a209e..0000000 --- a/dashboard/Dockerfile +++ /dev/null @@ -1,35 +0,0 @@ -FROM node:18-alpine as base -RUN apk add --no-cache g++ make py3-pip libc6-compat -WORKDIR /app -COPY package*.json ./ -EXPOSE 3000 - -FROM base as builder -WORKDIR /app -COPY . . -RUN npm run build - - -FROM base as production -WORKDIR /app - -ENV NODE_ENV=production -RUN npm ci - -RUN addgroup -g 1001 -S nodejs -RUN adduser -S nextjs -u 1001 -USER nextjs - - -COPY --from=builder --chown=nextjs:nodejs /app/.next ./.next -COPY --from=builder /app/node_modules ./node_modules -COPY --from=builder /app/package.json ./package.json -COPY --from=builder /app/public ./public - -CMD npm start - -FROM base as dev -ENV NODE_ENV=development -RUN npm install -COPY . . -CMD npm run dev \ No newline at end of file diff --git a/dashboard/app/api/user/get-all/route.ts b/dashboard/app/api/user/get-all/route.ts new file mode 100644 index 0000000..cee073a --- /dev/null +++ b/dashboard/app/api/user/get-all/route.ts @@ -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); + } + } +} \ No newline at end of file diff --git a/dashboard/app/dashboard/fetch-users/route.ts b/dashboard/app/dashboard/fetch-users/route.ts deleted file mode 100644 index f49bfa2..0000000 --- a/dashboard/app/dashboard/fetch-users/route.ts +++ /dev/null @@ -1,25 +0,0 @@ -export async function GET(req: Request): Promise { - const endPoint: (string | undefined) = `${process.env.NEXT_PUBLIC_API_BASE_URL}/user/get-all` - - if (endPoint) { - try { - const response = await fetch(endPoint, { - method: 'GET', - headers: { - 'Content-Type': 'application/json', // Set the appropriate content type for your request - 'x-api-key': process.env.X_API_KEY!, - }, - }); - - // if (!response.ok) { - // throw new Error('Network response was not ok'); - // } - // If the response is successful, you can handle the result here - const result = await response.json(); - console.log('POST request successful for Fetching Users'); - return Response.json({ result }) - } catch (error) { - console.error('Error during POST request:', error); - } - } -} \ No newline at end of file diff --git a/dashboard/app/dashboard/page.tsx b/dashboard/app/dashboard/page.tsx deleted file mode 100644 index 51d3010..0000000 --- a/dashboard/app/dashboard/page.tsx +++ /dev/null @@ -1,82 +0,0 @@ -"use client"; -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 fetchUsers = async () => { - setLoading(true) - const res = await fetch( - `${process.env.NEXT_PUBLIC_ENDPOINT}/fetch-users` - ); - const data = await res.json(); - setUsers(data.result); - setLoading(false) - } - - const columns: ColumnDef[] = [ - { - 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 ( -
- {new Date(parseInt(row.original.created_at.$date.$numberLong)).toLocaleString()} -
- ) - }, - }, - ]; - - useEffect(() => { - fetchUsers() - }, []) - - return ( -
-
- { - loading ? -
- -
- :
-

Dashboard

- -
- } -
- -
- ) -} - -export default DashboardPage \ No newline at end of file diff --git a/dashboard/app/page.tsx b/dashboard/app/page.tsx index baf6df3..9c86ea4 100644 --- a/dashboard/app/page.tsx +++ b/dashboard/app/page.tsx @@ -1,10 +1,89 @@ "use client"; -import React from 'react'; - -export default function Page(): JSX.Element { - return ( -
-

FlexAuth Dashboard

-
- ); +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[] = [ + { + 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 ( +
+ {new Date(parseInt(row.original.created_at.$date.$numberLong)).toLocaleString()} +
+ ) + }, + }, + ]; + + useEffect(() => { + getAllUsers() + }, []) + + return ( +
+
+ { + loading ? +
+ +
+ :
+

Dashboard

+ +
+ } +
+ +
+ ) } + +export default DashboardPage \ No newline at end of file