Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feat]: Team Dashboard UI Enhancements #3530

Merged
merged 5 commits into from
Jan 20, 2025

Conversation

Innocent-Akim
Copy link
Contributor

@Innocent-Akim Innocent-Akim commented Jan 19, 2025

Description

#3251
Please include a summary of the changes and the related issues.

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation update

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • I have commented on my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings

Previous screenshots

Please add here videos or images of the previous status

Current screenshots

Please add here videos or images of the current (new) status

Summary by CodeRabbit

  • New Features

    • Added Team Dashboard with comprehensive statistics and visualizations.
    • Introduced Date Range Picker for filtering data.
    • Created interactive Team Stats Chart, Grid, and Table.
    • Implemented a customizable Dashboard Header with filtering and export options.
  • Dependencies

    • Updated lucide-react to version 0.473.0.
    • Added recharts library for charting functionality.
  • Chores

    • Reformatted UI component files for improved readability.

Copy link
Contributor

coderabbitai bot commented Jan 19, 2025

Warning

There were issues while running some tools. Please review the errors and either fix the tool’s configuration or disable the tool if it’s a critical failure.

🔧 eslint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

apps/web/app/[locale]/dashboard/team-dashboard/components/team-stats-chart.tsx

Oops! Something went wrong! :(

ESLint: 8.46.0

ESLint couldn't find the config "next/core-web-vitals" to extend from. Please check that the name of the config is correct.

The config "next/core-web-vitals" was referenced from the config file in "/apps/web/.eslintrc.json".

If you still have problems, please stop by https://eslint.org/chat/help to chat with the team.

Walkthrough

This pull request introduces several new components for the team dashboard in a web application. The changes include creating components for displaying team statistics, such as TeamStatsChart, TeamStatsGrid, and TeamStatsTable. A new DateRangePicker component allows users to select date ranges, while a DashboardHeader provides filtering and export options. Mock data has been added to support these components, and the project dependencies have been updated to include the recharts library for charting. Additionally, a new empty component AppUrls has been introduced.

Changes

File Change Summary
apps/web/app/[locale]/dashboard/app-url/page.tsx Added empty AppUrls component
apps/web/app/[locale]/dashboard/team-dashboard/components/dashboard-header.tsx New DashboardHeader component with filter and export dropdowns
apps/web/app/[locale]/dashboard/team-dashboard/components/date-range-picker.tsx New DateRangePicker component for date range selection
apps/web/app/[locale]/dashboard/team-dashboard/components/team-stats-chart.tsx Added TeamStatsChart with line chart and interactive elements
apps/web/app/[locale]/dashboard/team-dashboard/components/team-stats-grid.tsx New TeamStatsGrid displaying team performance statistics
apps/web/app/[locale]/dashboard/team-dashboard/components/team-stats-table.tsx Created TeamStatsTable for displaying team member details
apps/web/app/[locale]/dashboard/team-dashboard/data/mock-data.ts Added mock data for charts and team members
apps/web/app/[locale]/dashboard/team-dashboard/page.tsx New TeamDashboard component integrating various stats components
apps/web/components/ui/card.tsx Reformatted existing card components
apps/web/components/ui/chart.tsx Added comprehensive charting components
apps/web/package.json Updated lucide-react version and added recharts dependency

Sequence Diagram

sequenceDiagram
    participant User
    participant TeamDashboard
    participant DashboardHeader
    participant DateRangePicker
    participant TeamStatsGrid
    participant TeamStatsChart
    participant TeamStatsTable

    User->>TeamDashboard: Access Dashboard
    TeamDashboard->>DashboardHeader: Render Header
    TeamDashboard->>DateRangePicker: Initialize Date Range
    TeamDashboard->>TeamStatsGrid: Display Statistics
    TeamDashboard->>TeamStatsChart: Render Performance Chart
    TeamDashboard->>TeamStatsTable: Show Team Member Details
Loading

Possibly related PRs

  • [Feat]: Add Timelog FilterOptions  #3333: The introduction of the TimeSheetFilterPopover component and its enhancements in state management and performance could relate to the new AppUrls component, as both involve user interface components that manage state and user interactions.
  • [Feat]: Add sortable headers to Timesheet component with dynamic sorting #3367: The changes in the TimesheetLoader and the sorting functionality in the DataTableTimeSheet component may relate to the AppUrls component, as both involve rendering and managing user interface components in a timesheet context.
  • [Feat]: Timesheet Improvements #3480: The improvements in the AddTaskModal component for managing time entries and shifts could relate to the AppUrls component, as both involve user interactions and state management in a timesheet context.

Suggested labels

feature, WEB, UI/UX, Ever Teams

Suggested reviewers

  • evereq
  • Cedric921

Poem

🐰 Dashboards dancing, charts so bright,
Team stats leaping into light!
Dropdowns filter, data gleams,
A rabbit's view of coding dreams! 📊
Performance tracked with playful might! 🚀


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

socket-security bot commented Jan 19, 2025

👍 Dependency issues cleared. Learn more about Socket for GitHub ↗︎

This PR previously contained dependency changes with security issues that have been resolved, removed, or ignored.

View full report↗︎

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 9

🧹 Nitpick comments (9)
apps/web/components/ui/chart.tsx (3)

66-66: Ensure displayName matches the component name

The displayName for ChartContainer is set to "Chart". For clarity and consistency, consider setting it to "ChartContainer".

Apply this diff to update the displayName:

-ChartContainer.displayName = "Chart"
+ChartContainer.displayName = "ChartContainer"

255-255: Align displayName with component name

The displayName for ChartTooltipContent is set to "ChartTooltip". For consistency, consider setting it to "ChartTooltipContent".

Apply this diff to update the displayName:

-ChartTooltipContent.displayName = "ChartTooltip"
+ChartTooltipContent.displayName = "ChartTooltipContent"

315-315: Align displayName with component name

The displayName for ChartLegendContent is set to "ChartLegend". For consistency, consider setting it to "ChartLegendContent".

Apply this diff to update the displayName:

-ChartLegendContent.displayName = "ChartLegend"
+ChartLegendContent.displayName = "ChartLegendContent"
apps/web/app/[locale]/dashboard/team-dashboard/data/mock-data.ts (1)

46-74: Use consistent data types for time values and activity levels

Currently, time values like trackedTime, manualTime, idleTime, and unknownActivity are stored as strings (e.g., "8h 12m"), and activityLevel is also a string (e.g., "85%"). Storing these values as numbers in consistent units (e.g., total minutes for time and a number between 0 and 100 for activity level) would facilitate easier data manipulation and calculations.

apps/web/app/[locale]/dashboard/team-dashboard/components/team-stats-chart.tsx (1)

80-103: Add interactivity to legend buttons for filtering data.

The legend buttons are currently non-functional. They should toggle the visibility of corresponding lines in the chart.

+import { useState } from 'react';

 export function TeamStatsChart() {
+  const [visibleLines, setVisibleLines] = useState({
+    tracked: true,
+    manual: true,
+    idle: true
+  });
+
+  const toggleLine = (line: keyof typeof visibleLines) => {
+    setVisibleLines(prev => ({
+      ...prev,
+      [line]: !prev[line]
+    }));
+  };

   return (
     // ... chart code
     <div className="flex gap-3 justify-center -mt-2">
       <Button
         size="sm"
         variant="outline"
+        onClick={() => toggleLine('tracked')}
+        className={cn(
           "gap-2 px-3 py-1.5 h-8 text-xs font-normal",
+          !visibleLines.tracked && "opacity-50"
         )}
       >
         <div className="w-2 h-2 bg-blue-500 rounded-full" />
         Tracked
       </Button>
       // ... similar changes for other buttons
     </div>
   );
 }
apps/web/app/[locale]/dashboard/team-dashboard/page.tsx (1)

36-66: Add error boundaries and loading states.

The dashboard should gracefully handle errors and loading states for its child components.

import { ErrorBoundary } from '@/components/error-boundary';
import { Suspense } from 'react';
import { LoadingSkeleton } from '@/components/loading-skeleton';

// Wrap child components with error boundaries and loading states
<ErrorBoundary fallback={<ErrorFallback />}>
  <Suspense fallback={<LoadingSkeleton />}>
    <DashboardHeader />
    <TeamStatsGrid />
    <Card className="p-6 w-full">
      <TeamStatsChart />
    </Card>
  </Suspense>
</ErrorBoundary>
apps/web/app/[locale]/dashboard/team-dashboard/components/date-range-picker.tsx (3)

21-32: Consider initializing dateRange as undefined.

The initial dateRange is set to today's date, but this might not align with the UI's "Select date range" placeholder state. Consider initializing it as undefined for consistency with the unselected state.

-  const [dateRange, setDateRange] = React.useState<DateRange | undefined>({
-    from: new Date(),
-    to: new Date(),
-  });
+  const [dateRange, setDateRange] = React.useState<DateRange | undefined>(undefined);

34-127: Enhance code reusability and type safety.

The predefined ranges implementation could benefit from:

  1. A type-safe structure for range definitions
  2. A reusable helper for null checks
  3. A constant for weekStartsOn
+interface DateRangeOption {
+  label: string;
+  action: () => void;
+  isSelected: (range: DateRange | undefined) => boolean;
+}
+
+const WEEK_STARTS_ON = 1; // Monday
+
+const isValidDateRange = (range: DateRange | undefined): range is Required<DateRange> => {
+  return Boolean(range?.from && range?.to);
+};

-const predefinedRanges = [
+const predefinedRanges: DateRangeOption[] = [
   // ... existing ranges with updated null checks:
   {
     isSelected: (range: DateRange | undefined) => {
-      if (!range?.from || !range?.to) return false;
+      if (!isValidDateRange(range)) return false;
       // ... rest of the implementation
     }
   }
   // ... update other ranges similarly
 ];

207-213: Consider removing the Apply button.

The Apply button might be redundant since:

  1. Changes are already applied through handleDateRangeChange
  2. It only closes the popover, which could be handled by the selection itself

Consider either:

  1. Removing the Apply button and closing the popover on selection
  2. Or, implementing a preview state that only applies on clicking Apply
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3d31ece and e05a571.

⛔ Files ignored due to path filters (2)
  • package-lock.json is excluded by !**/package-lock.json
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (11)
  • apps/web/app/[locale]/dashboard/app-url/page.tsx (1 hunks)
  • apps/web/app/[locale]/dashboard/team-dashboard/components/dashboard-header.tsx (1 hunks)
  • apps/web/app/[locale]/dashboard/team-dashboard/components/date-range-picker.tsx (1 hunks)
  • apps/web/app/[locale]/dashboard/team-dashboard/components/team-stats-chart.tsx (1 hunks)
  • apps/web/app/[locale]/dashboard/team-dashboard/components/team-stats-grid.tsx (1 hunks)
  • apps/web/app/[locale]/dashboard/team-dashboard/components/team-stats-table.tsx (1 hunks)
  • apps/web/app/[locale]/dashboard/team-dashboard/data/mock-data.ts (1 hunks)
  • apps/web/app/[locale]/dashboard/team-dashboard/page.tsx (1 hunks)
  • apps/web/components/ui/card.tsx (1 hunks)
  • apps/web/components/ui/chart.tsx (1 hunks)
  • apps/web/package.json (2 hunks)
✅ Files skipped from review due to trivial changes (2)
  • apps/web/components/ui/card.tsx
  • apps/web/app/[locale]/dashboard/app-url/page.tsx
🧰 Additional context used
🪛 Biome (1.9.4)
apps/web/components/ui/chart.tsx

[error] 79-79: Avoid passing content using the dangerouslySetInnerHTML prop.

Setting content using code can expose users to cross-site scripting (XSS) attacks

(lint/security/noDangerouslySetInnerHtml)

⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Codacy Static Code Analysis
🔇 Additional comments (3)
apps/web/app/[locale]/dashboard/team-dashboard/components/date-range-picker.tsx (2)

1-19: LGTM! Well-structured component setup.

The imports are well-organized, and the interface is properly typed with optional props.


129-140: LGTM! Well-implemented date formatting logic.

The formatDateRange function handles all cases appropriately and uses date-fns utilities effectively.

apps/web/package.json (1)

101-101: Verify compatibility with updated dependencies.

The dependency updates look appropriate for the UI enhancements. However, please ensure:

  1. The lucide-react update doesn't introduce breaking changes
  2. The recharts version is compatible with the React version in use (^18.2.0)

Also applies to: 128-128

✅ Verification successful

Dependencies are compatible with the project

Both lucide-react 0.473.0 and recharts 2.15.0 explicitly support React ^18.2.0, and the version updates follow semver guidelines, suggesting no breaking changes.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check for breaking changes in lucide-react and verify recharts compatibility

# Check lucide-react changelog
gh api repos/lucide-icons/lucide/releases | jq -r '.[].body' | grep -A 10 "0.453.0"

# Verify recharts peer dependencies
curl -s https://registry.npmjs.org/recharts/2.15.0 | jq -r '.peerDependencies'

Length of output: 279


Script:

#!/bin/bash
# Try to get lucide-react release info from npm
curl -s https://registry.npmjs.org/lucide-react | jq -r '.versions["0.473.0"].dist.tarball' | xargs curl -s | tar -tzf - package/README.md 2>/dev/null

# Also check the current version's dependencies
curl -s https://registry.npmjs.org/lucide-react/0.473.0 | jq -r '.peerDependencies'

Length of output: 300

@Innocent-Akim Innocent-Akim marked this pull request as draft January 19, 2025 14:22
Copy link

Report too large to display inline

View full report↗︎

@Innocent-Akim Innocent-Akim self-assigned this Jan 19, 2025
@Innocent-Akim Innocent-Akim marked this pull request as ready for review January 19, 2025 14:41
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

♻️ Duplicate comments (2)
apps/web/app/[locale]/dashboard/team-dashboard/page.tsx (1)

28-35: ⚠️ Potential issue

Remove unsafe JSON.parse usage with translation string.

Using JSON.parse with translation strings is unsafe and could throw errors if the string is not valid JSON.

Apply this diff to fix the issue:

-{ title: JSON.parse(t('pages.home.BREADCRUMB')), href: '/' },
+{ title: t('pages.home.BREADCRUMB'), href: '/' },
apps/web/app/[locale]/dashboard/team-dashboard/components/team-stats-table.tsx (1)

65-89: 🛠️ Refactor suggestion

Implement pagination functionality.

The pagination UI is present but non-functional. Consider implementing proper pagination logic to enhance user experience.

Apply this diff to implement pagination:

+import { useState } from 'react';
+
 export function TeamStatsTable() {
+  const [currentPage, setCurrentPage] = useState(1);
+  const itemsPerPage = 10;
+  const totalPages = Math.ceil(members.length / itemsPerPage);
+  
+  const paginatedMembers = members.slice(
+    (currentPage - 1) * itemsPerPage,
+    currentPage * itemsPerPage
+  );
+
   return (
     <div className="space-y-4">
       <TableBody>
-        {members.map((member) => (
+        {paginatedMembers.map((member) => (
           // ... existing table row code
         ))}
       </TableBody>
       <div className="flex justify-between items-center px-2">
         <div className="flex items-center space-x-6">
           <p className="text-sm text-gray-500">
-            Showing 1 to {members.length} of {members.length} entries
+            Showing {(currentPage - 1) * itemsPerPage + 1} to {Math.min(currentPage * itemsPerPage, members.length)} of {members.length} entries
           </p>
         </div>
         <div className="flex items-center space-x-2">
           <Button
             variant="outline"
             size="icon"
-            disabled
+            disabled={currentPage === 1}
+            onClick={() => setCurrentPage(1)}
           >
             <ChevronsLeft className="w-4 h-4" />
           </Button>
           // ... update other pagination buttons similarly
         </div>
       </div>
     </div>
   );
 }
🧹 Nitpick comments (4)
apps/web/components/ui/chart.tsx (3)

9-17: Consider adding type safety for color values.

The color property in ChartConfig could benefit from stronger typing to ensure valid color values are provided.

export type ChartConfig = {
  [k in string]: {
    label?: React.ReactNode
    icon?: React.ComponentType
  } & (
-    | { color?: string; theme?: never }
+    | { color?: `#${string}` | `rgb(${number},${number},${number})` | `rgba(${number},${number},${number},${number})`; theme?: never }
    | { color?: never; theme: Record<keyof typeof THEMES, string> }
  )
}

103-255: Consider decomposing the tooltip content into smaller components.

The ChartTooltipContent component is quite large and handles multiple responsibilities. Breaking it down would improve maintainability and readability.

Consider extracting these components:

  1. TooltipLabel
  2. TooltipItem
  3. TooltipIndicator

Example structure:

const TooltipLabel = ({ value, formatter, payload, className }: TooltipLabelProps) => {
  if (formatter) {
    return <div className={className}>{formatter(value, payload)}</div>;
  }
  return value ? <div className={className}>{value}</div> : null;
};

const TooltipIndicator = ({ type, color }: TooltipIndicatorProps) => {
  // Extract indicator rendering logic
};

const TooltipItem = ({ item, config, formatter, index }: TooltipItemProps) => {
  // Extract item rendering logic
};

const ChartTooltipContent = ({ ... }) => {
  // Main component becomes simpler with extracted components
  return (
    <div>
      <TooltipLabel />
      {payload.map((item, index) => (
        <TooltipItem key={item.dataKey} item={item} index={index} />
      ))}
    </div>
  );
};

318-354: Enhance type safety in the helper function.

The getPayloadConfigFromPayload function uses type assertions and loose type checking. Consider using TypeScript's type guards for better type safety.

+ interface PayloadType {
+   payload?: Record<string, unknown>;
+   [key: string]: unknown;
+ }

function getPayloadConfigFromPayload(
  config: ChartConfig,
-  payload: unknown,
+  payload: PayloadType,
  key: string
) {
-  if (typeof payload !== "object" || payload === null) {
+  if (!payload) {
    return undefined;
  }

+  function isValidPayload(value: unknown): value is Record<string, unknown> {
+    return typeof value === "object" && value !== null;
+  }

  const payloadPayload =
-    "payload" in payload &&
-    typeof payload.payload === "object" &&
-    payload.payload !== null
+    "payload" in payload && isValidPayload(payload.payload)
      ? payload.payload
      : undefined;

  // ... rest of the function
}
apps/web/app/[locale]/dashboard/team-dashboard/components/team-stats-chart.tsx (1)

88-113: Add interactive legend functionality.

Consider making the legend buttons interactive to toggle the visibility of corresponding chart lines, enhancing user experience.

Apply this diff to implement interactive legend:

+import { useState } from 'react';
+
 export function TeamStatsChart() {
+  const [visibleLines, setVisibleLines] = useState({
+    tracked: true,
+    manual: true,
+    idle: true
+  });
+
+  const toggleLine = (line: keyof typeof visibleLines) => {
+    setVisibleLines(prev => ({
+      ...prev,
+      [line]: !prev[line]
+    }));
+  };
+
   return (
     <div className="flex flex-col">
       <LineChart>
         {/* ... other chart config ... */}
-        <Line dataKey="tracked" />
-        <Line dataKey="manual" />
-        <Line dataKey="idle" />
+        {visibleLines.tracked && <Line dataKey="tracked" />}
+        {visibleLines.manual && <Line dataKey="manual" />}
+        {visibleLines.idle && <Line dataKey="idle" />}
       </LineChart>
       <div className="flex gap-3 justify-center -mt-2">
         <Button
           variant="outline"
+          onClick={() => toggleLine('tracked')}
+          className={cn(
+            "gap-2 px-3 py-1.5 h-8 text-xs font-normal",
+            !visibleLines.tracked && "opacity-50"
+          )}
         >
           <div className="w-2 h-2 bg-blue-500 rounded-full" />
           Tracked
         </Button>
         {/* ... update other buttons similarly ... */}
       </div>
     </div>
   );
 }
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e05a571 and 4d1f922.

⛔ Files ignored due to path filters (1)
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (4)
  • apps/web/app/[locale]/dashboard/team-dashboard/components/team-stats-chart.tsx (1 hunks)
  • apps/web/app/[locale]/dashboard/team-dashboard/components/team-stats-table.tsx (1 hunks)
  • apps/web/app/[locale]/dashboard/team-dashboard/page.tsx (1 hunks)
  • apps/web/components/ui/chart.tsx (1 hunks)
🧰 Additional context used
🪛 Biome (1.9.4)
apps/web/components/ui/chart.tsx

[error] 79-79: Avoid passing content using the dangerouslySetInnerHTML prop.

Setting content using code can expose users to cross-site scripting (XSS) attacks

(lint/security/noDangerouslySetInnerHtml)

apps/web/app/[locale]/dashboard/team-dashboard/components/team-stats-table.tsx

[error] 11-11: isNaN is unsafe. It attempts a type coercion. Use Number.isNaN instead.

See the MDN documentation for more details.
Unsafe fix: Use Number.isNaN instead.

(lint/suspicious/noGlobalIsNan)

⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Codacy Static Code Analysis
🔇 Additional comments (9)
apps/web/components/ui/chart.tsx (3)

35-66: LGTM! Well-structured component with proper TypeScript usage.

The component correctly implements ref forwarding and provides comprehensive styling options.


68-99: Consider safer alternatives to dangerouslySetInnerHTML.

While the current implementation is controlled and likely safe, consider using CSS-in-JS solutions or styled-components for dynamic styling to eliminate potential XSS risks.

Alternative approaches:

  1. Use CSS-in-JS libraries like @emotion/css or styled-components
  2. Use CSS Custom Properties with dynamic values
  3. Create style elements programmatically using CSSStyleSheet API

Example using CSS Custom Properties:

const ChartStyle = ({ id, config }: { id: string; config: ChartConfig }) => {
  const colorConfig = Object.entries(config).filter(
    ([, config]) => config.theme || config.color
  )

  React.useEffect(() => {
    if (!colorConfig.length) return;
    
    Object.entries(THEMES).forEach(([theme, prefix]) => {
      const element = document.querySelector(`${prefix} [data-chart="${id}"]`);
      if (!element) return;
      
      colorConfig.forEach(([key, itemConfig]) => {
        const color = itemConfig.theme?.[theme as keyof typeof itemConfig.theme] || itemConfig.color;
        if (color) {
          (element as HTMLElement).style.setProperty(`--color-${key}`, color);
        }
      });
    });
  }, [id, colorConfig]);

  return null;
}
🧰 Tools
🪛 Biome (1.9.4)

[error] 79-79: Avoid passing content using the dangerouslySetInnerHTML prop.

Setting content using code can expose users to cross-site scripting (XSS) attacks

(lint/security/noDangerouslySetInnerHtml)


257-315: LGTM! Clean implementation of the legend components.

The components are well-typed and properly handle refs and customization options.

apps/web/app/[locale]/dashboard/team-dashboard/page.tsx (3)

1-26: LGTM! Imports and hooks are well organized.

The imports are properly structured, and hooks are initialized correctly.


37-64: LGTM! Layout structure is well-organized.

The header section is properly structured with correct back button implementation and well-nested components.


65-77: LGTM! Main content and authentication are properly implemented.

The main content is well-structured, and the authentication HOC is correctly applied.

apps/web/app/[locale]/dashboard/team-dashboard/components/team-stats-table.tsx (1)

18-64: LGTM! Table implementation is well-structured.

The table layout is clean, and the activity level progress bar is properly implemented.

apps/web/app/[locale]/dashboard/team-dashboard/components/team-stats-chart.tsx (2)

7-30: LGTM! CustomTooltip is well-implemented with proper TypeScript types.

The tooltip implementation is clean, type-safe, and follows best practices.


32-87: LGTM! Chart implementation is well-configured.

The chart is properly set up with appropriate styling, axes configuration, and responsive container.

@Innocent-Akim Innocent-Akim requested a review from evereq January 20, 2025 09:55
@evereq evereq merged commit f40a8bf into develop Jan 20, 2025
14 checks passed
@evereq evereq deleted the feat/team-dashboard-ui-enhancements branch January 20, 2025 20:22
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