mirror of
https://github.com/escalante29/WealthySmart.git
synced 2026-07-17 17:08:47 +02:00
All checks were successful
Deploy to VPS / deploy (push) Successful in 28s
Replace custom markup across all pages and components with shadcn/ui primitives (Dialog, Sheet, Select, Card, Tabs, etc.). Add reusable DataTable component powered by @tanstack/react-table with sortable column headers and client-side pagination. Introduce TransactionList with responsive mobile cards and desktop DataTable, dashboard section customization (DashboardSection, SectionConfigDialog), and settings API types. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
63 lines
1.6 KiB
TypeScript
63 lines
1.6 KiB
TypeScript
import { useEffect, useState } from 'react';
|
|
import { Calendar } from 'lucide-react';
|
|
import api from '../api';
|
|
import {
|
|
Select,
|
|
SelectContent,
|
|
SelectItem,
|
|
SelectTrigger,
|
|
SelectValue,
|
|
} from '@/components/ui/select';
|
|
|
|
export interface CycleOption {
|
|
year: number;
|
|
month: number;
|
|
label: string;
|
|
count: number;
|
|
total: number;
|
|
}
|
|
|
|
interface Props {
|
|
value: { year: number; month: number } | null;
|
|
onChange: (cycle: { year: number; month: number } | null) => void;
|
|
}
|
|
|
|
export default function BillingCycleSelector({ value, onChange }: Props) {
|
|
const [cycles, setCycles] = useState<CycleOption[]>([]);
|
|
|
|
useEffect(() => {
|
|
api.get('/transactions/cycles').then((r) => setCycles(r.data));
|
|
}, []);
|
|
|
|
const selectedKey = value ? `${value.year}-${value.month}` : 'all';
|
|
|
|
return (
|
|
<div className="flex items-center gap-2">
|
|
<Calendar className="w-4 h-4 text-muted-foreground" />
|
|
<Select
|
|
value={selectedKey}
|
|
onValueChange={(val) => {
|
|
if (val === 'all') {
|
|
onChange(null);
|
|
} else {
|
|
const [y, m] = val.split('-').map(Number);
|
|
onChange({ year: y, month: m });
|
|
}
|
|
}}
|
|
>
|
|
<SelectTrigger className="w-[180px]">
|
|
<SelectValue />
|
|
</SelectTrigger>
|
|
<SelectContent>
|
|
<SelectItem value="all">All time</SelectItem>
|
|
{cycles.map((c) => (
|
|
<SelectItem key={`${c.year}-${c.month}`} value={`${c.year}-${c.month}`}>
|
|
{c.label} ({c.count})
|
|
</SelectItem>
|
|
))}
|
|
</SelectContent>
|
|
</Select>
|
|
</div>
|
|
);
|
|
}
|