diff --git a/resources/js/components/dashboard/top-categories-card.tsx b/resources/js/components/dashboard/top-categories-card.tsx index 406a85c9..2768af43 100644 --- a/resources/js/components/dashboard/top-categories-card.tsx +++ b/resources/js/components/dashboard/top-categories-card.tsx @@ -1,3 +1,4 @@ +import { index as transactionsIndex } from '@/actions/App/Http/Controllers/TransactionController'; import { AmountDisplay } from '@/components/ui/amount-display'; import { Card, @@ -12,7 +13,8 @@ import { cn } from '@/lib/utils'; import { SharedData } from '@/types'; import { Category, getCategoryColorClasses } from '@/types/category'; import { __ } from '@/utils/i18n'; -import { usePage } from '@inertiajs/react'; +import { Link, usePage } from '@inertiajs/react'; +import { format, subDays } from 'date-fns'; import * as Icons from 'lucide-react'; import { LucideIcon } from 'lucide-react'; import { PercentageTrendIndicator } from './percentage-trend-indicator'; @@ -60,6 +62,10 @@ export function TopCategoriesCard({ ); } + const now = new Date(); + const dateFrom = format(subDays(now, 30), 'yyyy-MM-dd'); + const dateTo = format(now, 'yyyy-MM-dd'); + return ( @@ -91,8 +97,20 @@ export function TopCategoriesCard({ index, ); + const categoryUrl = transactionsIndex({ + query: { + category_ids: item.category.id, + date_from: dateFrom, + date_to: dateTo, + }, + }).url; + return ( -
+
-
+ ); })} {categories.length === 0 && ( diff --git a/resources/js/components/ui/progress.tsx b/resources/js/components/ui/progress.tsx index 6219ad82..7dd92dde 100644 --- a/resources/js/components/ui/progress.tsx +++ b/resources/js/components/ui/progress.tsx @@ -16,7 +16,7 @@ const Progress = React.forwardRef<