Repository navigation
add dashboard overview - #153
shatakshisgtiwari-jpg wants to merge 1 commit into
Conversation
|
@shatakshisgtiwari-jpg can you please rebase with the latest main-new so that ci runs for your pr? Thanks! |
4dc94a2 to
b7d523b
Compare
deo002
left a comment
There was a problem hiding this comment.
Some changes are required.
| import { ApiError, fetchJson } from "@/lib/api"; | ||
|
|
||
| type BackendDashboard = { | ||
| licenses_count?: unknown; |
There was a problem hiding this comment.
use solid types instead of unknown. Here it should probably be something like number | null.
| }; | ||
|
|
||
| type BackendAudit = { | ||
| timestamp?: unknown; |
| user?: { display_name?: unknown; user_name?: unknown }; | ||
| }; | ||
|
|
||
| function asCount(value: unknown) { |
There was a problem hiding this comment.
asCount, asRiskFrequency, asRecentChanges etc can all be removed if you use type-safety features built in typescript.
| import { NextResponse, type NextRequest } from "next/server"; | ||
| import { ApiError, fetchJson } from "@/lib/api"; | ||
|
|
||
| type BackendDashboard = { |
There was a problem hiding this comment.
create a separate file/folder for types so you can export and use them throughout the application and not just a single file.
| { headers: { "Cache-Control": "private, no-store" } }, | ||
| ); | ||
| } catch (error) { | ||
| const status = error instanceof ApiError ? error.status : 502; |
There was a problem hiding this comment.
It would be nice to use enums via https://www.npmjs.com/package/http-status-codes for better code readability instead of using status codes directly.
| import { useState } from "react"; | ||
| import { useTranslations } from "next-intl"; | ||
|
|
||
| type DashboardData = { |
There was a problem hiding this comment.
create a separate file/folder for types so you can export and use them throughout the application and not just a single file. DashboardData in this file is similar to BackendDashboard of app/api/dashboard/route.ts. There is duplication.
| import { useState } from "react"; | ||
| import { useTranslations } from "next-intl"; | ||
|
|
||
| type DashboardData = { |
There was a problem hiding this comment.
create a separate file/folder for types so you can export and use them throughout the application and not just a single file. DashboardData in this file is similar to BackendDashboard of app/api/dashboard/route.ts. There is duplication.
| const chartColors = ["#7b1a89", "#9ebc45", "#db8a34", "#6094bf", "#d76078"]; | ||
|
|
||
| async function getDashboardData() { | ||
| const response = await fetch("/api/dashboard", { cache: "no-store" }); |
There was a problem hiding this comment.
why are there 2 api calls to dashboard data being made? One in this file and once in app/api/dashboard/route.ts?
Either make this a client component and do the api call here or make this a server component and use the result from app/api/dashboard/route.ts. I'd prefer the latter if possible.
| return payload.data; | ||
| } | ||
|
|
||
| function formatTimestamp(timestamp: string | null) { |
There was a problem hiding this comment.
such functions which might be used anywhere else in the codebase should be defined in and exported from lib/utils.ts.
|
Make sure the reuse compliance check passes as well. Just add the spdx copyright in all new files you create. |
b7d523b to
159f7f7
Compare
159f7f7 to
22d1d33
Compare
|
|
||
| return ( | ||
| <AppSidebar | ||
| authConfigured={authConfigured} | ||
| authMode={mode} | ||
| providerName={providerName} | ||
| /> | ||
| > | ||
| <Dashboard data={dashboard} /> |
There was a problem hiding this comment.
Another request. It would be better to render the dashboard/license/obligation pages in separate route boundaries rather than as components in a single route. Look into parallel routes: https://nextjs.org/docs/app/api-reference/file-conventions/parallel-routes
Signed-off-by: Shatakshi Tiwari <shatakshisgtiwari@gmail.com>
22d1d33 to
e2eb8a9
Compare
No description provided.