Skip to content

add dashboard overview - #153

Open
shatakshisgtiwari-jpg wants to merge 1 commit into
fossology:main-newfrom
shatakshisgtiwari-jpg:feat/dashboard-rebased
Open

shatakshisgtiwari-jpg wants to merge 1 commit into
fossology:main-newfrom
shatakshisgtiwari-jpg:feat/dashboard-rebased

Conversation

@shatakshisgtiwari-jpg

Copy link
Copy Markdown

No description provided.

@deo002

deo002 commented Oct 29, 2026

Copy link
Copy Markdown
Collaborator

@shatakshisgtiwari-jpg can you please rebase with the latest main-new so that ci runs for your pr? Thanks!

@deo002 deo002 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some changes are required.

Comment thread app/api/dashboard/route.ts Outdated
import { ApiError, fetchJson } from "@/lib/api";

type BackendDashboard = {
licenses_count?: unknown;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use solid types instead of unknown. Here it should probably be something like number | null.

Comment thread app/api/dashboard/route.ts Outdated
};

type BackendAudit = {
timestamp?: unknown;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here as well

Comment thread app/api/dashboard/route.ts Outdated
user?: { display_name?: unknown; user_name?: unknown };
};

function asCount(value: unknown) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

asCount, asRiskFrequency, asRecentChanges etc can all be removed if you use type-safety features built in typescript.

Comment thread app/api/dashboard/route.ts Outdated
import { NextResponse, type NextRequest } from "next/server";
import { ApiError, fetchJson } from "@/lib/api";

type BackendDashboard = {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

create a separate file/folder for types so you can export and use them throughout the application and not just a single file.

Comment thread app/api/dashboard/route.ts Outdated
{ headers: { "Cache-Control": "private, no-store" } },
);
} catch (error) {
const status = error instanceof ApiError ? error.status : 502;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread components/dashboard.tsx Outdated
import { useState } from "react";
import { useTranslations } from "next-intl";

type DashboardData = {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread components/dashboard.tsx Outdated
import { useState } from "react";
import { useTranslations } from "next-intl";

type DashboardData = {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread components/dashboard.tsx Outdated
const chartColors = ["#7b1a89", "#9ebc45", "#db8a34", "#6094bf", "#d76078"];

async function getDashboardData() {
const response = await fetch("/api/dashboard", { cache: "no-store" });

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread components/dashboard.tsx Outdated
return payload.data;
}

function formatTimestamp(timestamp: string | null) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

such functions which might be used anywhere else in the codebase should be defined in and exported from lib/utils.ts.

@deo002

deo002 commented Nov 12, 2026

Copy link
Copy Markdown
Collaborator

Make sure the reuse compliance check passes as well. Just add the spdx copyright in all new files you create.


return (
<AppSidebar
authConfigured={authConfigured}
authMode={mode}
providerName={providerName}
/>
>
<Dashboard data={dashboard} />

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants