mirror of
https://github.com/felipegcoutinho/openmonetis.git
synced 2026-07-09 03:16:01 +00:00
feat(dashboard): vincula tendências às categorias
This commit is contained in:
@@ -6,6 +6,7 @@ import {
|
||||
RiHistoryLine,
|
||||
RiLineChartLine,
|
||||
} from "@remixicon/react";
|
||||
import Link from "next/link";
|
||||
import type { DashboardCategoryBreakdownItem } from "@/features/dashboard/categories/category-breakdown-helpers";
|
||||
import { dashboardWidgetListStyles as styles } from "@/features/dashboard/components/dashboard-widget-list-styles";
|
||||
import { PercentageChangeIndicator } from "@/features/dashboard/components/percentage-change-indicator";
|
||||
@@ -13,14 +14,18 @@ import { CategoryIconBadge } from "@/shared/components/entity-avatar";
|
||||
import MoneyValues from "@/shared/components/money-values";
|
||||
import { WidgetEmptyState } from "@/shared/components/widgets/widget-empty-state";
|
||||
import { formatPercentage } from "@/shared/utils/percentage";
|
||||
import { formatPeriodForUrl } from "@/shared/utils/period";
|
||||
|
||||
type CategoryTrendsWidgetProps = {
|
||||
categories: DashboardCategoryBreakdownItem[];
|
||||
period: string;
|
||||
};
|
||||
|
||||
export function CategoryTrendsWidget({
|
||||
categories,
|
||||
period,
|
||||
}: CategoryTrendsWidgetProps) {
|
||||
const periodParam = formatPeriodForUrl(period);
|
||||
const trending = categories
|
||||
.filter((c) => c.percentageChange !== null && c.previousAmount > 0)
|
||||
.sort(
|
||||
@@ -53,7 +58,12 @@ export function CategoryTrendsWidget({
|
||||
size="md"
|
||||
/>
|
||||
<div className={styles.textStack}>
|
||||
<p className={styles.title}>{category.categoryName}</p>
|
||||
<Link
|
||||
href={`/categories/${category.categoryId}?periodo=${periodParam}`}
|
||||
className={styles.titleLink}
|
||||
>
|
||||
<span className="truncate">{category.categoryName}</span>
|
||||
</Link>
|
||||
<p className={styles.meta}>
|
||||
<span
|
||||
className="inline-flex items-center gap-1"
|
||||
|
||||
@@ -174,9 +174,10 @@ export const widgetsConfig: WidgetConfig[] = [
|
||||
title: "Tendências de categorias",
|
||||
subtitle: "Top 10 maiores variações vs. mês anterior",
|
||||
icon: <RiLineChartLine className="size-4" />,
|
||||
component: ({ data }) => (
|
||||
component: ({ data, period }) => (
|
||||
<CategoryTrendsWidget
|
||||
categories={data.expensesByCategoryData.categories}
|
||||
period={period}
|
||||
/>
|
||||
),
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user