Skip to content

Commit

Permalink
Bugfixes breakdown chart
Browse files Browse the repository at this point in the history
  • Loading branch information
atrincas committed Dec 11, 2024
1 parent 4a8332c commit 8b1b785
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 32 deletions.
3 changes: 2 additions & 1 deletion client/src/containers/header/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import { FC, useState } from "react";

import Link from "next/link";

import { Menu as MenuIcon } from "lucide-react";

import { Overlay } from "@/components/ui/overlay";
Expand All @@ -12,7 +14,6 @@ import {
} from "@/components/ui/popover";

import Menu from "./menu";
import Link from "next/link";

const Header: FC = () => {
const [isOpen, setIsOpen] = useState(false);
Expand Down
2 changes: 1 addition & 1 deletion client/src/containers/header/menu/index.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { FC } from "react";

import Link from "next/link";
import { usePathname } from "next/navigation";

import UserMenu from "./user";
import { usePathname } from "next/navigation";

export const classes = {
link: "block px-4 py-2 hover:bg-muted transition-colors",
Expand Down
7 changes: 1 addition & 6 deletions client/src/containers/widget/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -149,12 +149,7 @@ export default function Widget({
className,
)}
>
<WidgetHeader
indicator={indicator}
question={question}
menu={menu}
responseRate={responseRate}
/>
<WidgetHeader indicator={indicator} question={question} menu={menu} />
<Breakdown data={data.breakdown} />
</Card>
);
Expand Down
41 changes: 21 additions & 20 deletions client/src/containers/widget/widget-header/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,26 +33,27 @@ const WidgetHeader: FC<WidgetHeaderProps> = ({
<Title as="h3" className="text-base">
{indicator}
</Title>
<div className="flex items-center gap-2">
<TooltipProvider>
<Tooltip delayDuration={350}>
<TooltipTrigger>
<p
data-testid="response-rate"
className="inline-flex items-center gap-1 rounded-full bg-primary p-2 text-2xs font-medium text-muted-foreground"
>
<ClipboardCheckIcon className="h-4 w-4" strokeWidth={1.5} />
<span>{responseRate}%</span>
</p>
</TooltipTrigger>
<TooltipContent className="rounded-full border-none bg-background px-2 py-1 text-xs text-foreground">
<p>Response rate</p>
</TooltipContent>
</Tooltip>
</TooltipProvider>

{menu}
</div>
{typeof responseRate === "number" && (
<div className="flex items-center gap-2">
<TooltipProvider>
<Tooltip delayDuration={350}>
<TooltipTrigger>
<p
data-testid="response-rate"
className="inline-flex items-center gap-1 rounded-full bg-primary p-2 text-2xs font-medium text-muted-foreground"
>
<ClipboardCheckIcon className="h-4 w-4" strokeWidth={1.5} />
<span>{responseRate}%</span>
</p>
</TooltipTrigger>
<TooltipContent className="rounded-full border-none bg-background px-2 py-1 text-xs text-foreground">
<p>Response rate</p>
</TooltipContent>
</Tooltip>
</TooltipProvider>
</div>
)}
{menu}
</div>
{question && <p className="text-xs text-muted-foreground">{question}</p>}
</header>
Expand Down
10 changes: 6 additions & 4 deletions client/src/lib/normalize-widget-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,12 @@ function normalizeWidgetData(widgetData: WidgetData): WidgetData {
}

if (result.breakdown) {
result.breakdown = result.breakdown.map((b) => ({
...b,
data: normalizeChartData(b.data),
}));
result.breakdown = result.breakdown
.map((b) => ({
...b,
data: normalizeChartData(b.data),
}))
.filter((d) => d.label !== "N/A");
}

return result;
Expand Down

0 comments on commit 8b1b785

Please sign in to comment.