diff --git a/src/app/(dashboard)/corporate-dashboard/page.tsx b/src/app/(dashboard)/corporate-dashboard/page.tsx index e69de29..ca8ed83 100644 --- a/src/app/(dashboard)/corporate-dashboard/page.tsx +++ b/src/app/(dashboard)/corporate-dashboard/page.tsx @@ -0,0 +1,308 @@ +'use client'; + +import { format, subMonths } from 'date-fns'; +import { ru } from 'date-fns/locale'; +import { Building2, CalendarIcon, LogOut, Wallet } from 'lucide-react'; +import { useState } from 'react'; + +import { Button } from '@/shared/shadcn-ui/button'; +import { Calendar } from '@/shared/shadcn-ui/calendar'; +import { + Card, + CardContent, + CardDescription, + CardHeader, + CardTitle, +} from '@/shared/shadcn-ui/card'; +import { Label } from '@/shared/shadcn-ui/label'; +import { + Popover, + PopoverContent, + PopoverTrigger, +} from '@/shared/shadcn-ui/popover'; +import { + Table, + TableBody, + TableCell, + TableHead, + TableHeader, + TableRow, +} from '@/shared/shadcn-ui/table'; + +// import { CardsList } from '@/widgets/cards-list'; + +// Sample company data +const companyData = { + companyName: 'ООО «ТаджикТранс»', + numberOfCards: 12, + fund: 25000, + overdraft: 5000, + totalFund: 30000, + registrationDate: '10.03.2019', +}; + +// Sample transaction data +const generateTransactions = () => { + const stations = [ + 'АЗС Душанбе-Центр', + 'АЗС Душанбе-Запад', + 'АЗС Душанбе-Восток', + 'АЗС Худжанд', + 'АЗС Куляб', + ]; + + const products = [ + { name: 'ДТ', price: 8.5 }, + { name: 'АИ-92', price: 9.2 }, + { name: 'АИ-95', price: 10.5 }, + { name: 'Z-100 Power', price: 11.8 }, + { name: 'Пропан', price: 6.3 }, + ]; + + const transactions = []; + + // Generate 50 random transactions over the last 6 months + for (let i = 0; i < 50; i++) { + const date = subMonths(new Date(), Math.random() * 6); + const station = stations[Math.floor(Math.random() * stations.length)]; + const product = products[Math.floor(Math.random() * products.length)]; + const quantity = Math.floor(Math.random() * 40) + 10; // 10-50 liters + const cost = product.price; + const total = quantity * cost; + + transactions.push({ + id: i + 1, + date, + station, + product: product.name, + quantity, + cost, + total, + }); + } + + // Sort by date (newest first) + return transactions.sort((a, b) => b.date.getTime() - a.date.getTime()); +}; + +const transactions = generateTransactions(); + +export default function CorporateDashboard() { + const [startDate, setStartDate] = useState( + subMonths(new Date(), 1), + ); + const [endDate, setEndDate] = useState(new Date()); + const [filteredTransactions, setFilteredTransactions] = + useState(transactions); + + // Filter transactions by date range + const filterTransactions = () => { + if (!startDate || !endDate) return; + + const filtered = transactions.filter((transaction) => { + const transactionDate = new Date(transaction.date); + return transactionDate >= startDate && transactionDate <= endDate; + }); + + setFilteredTransactions(filtered); + }; + + return ( +
+
+
+
+

Корпоративный кабинет

+ +
+ +
+ {/* Company Card */} + + + + + Информация о компании + + + +
+
+
+

Название компании

+

{companyData.companyName}

+
+
+

Количество карт

+

{companyData.numberOfCards}

+
+
+

Дата регистрации

+

+ {companyData.registrationDate} +

+
+
+
+
+

Фонд

+

+ {companyData.fund.toLocaleString()} сомони +

+
+
+

Овердрафт

+

+ {companyData.overdraft.toLocaleString()} сомони +

+
+
+
+
+
+ + {/* Fund Card */} + + + + + Общий фонд + + + Доступные средства + + + +
+

+ {companyData.totalFund.toLocaleString()} +

+

сомони

+
+
+
+
+ + {/* */} + + {/* Transactions */} +
+
+

История операций

+ +
+
+
+ + + + + + + + + +
+ +
+ + + + + + + + + +
+
+ + +
+
+ +
+ + + + Дата + Станция + Продукт + Кол-во (л) + Стоимость + Сумма + + + + {filteredTransactions.length > 0 ? ( + filteredTransactions.map((transaction) => ( + + + {format(transaction.date, 'dd.MM.yyyy')} + + {transaction.station} + {transaction.product} + + {transaction.quantity} + + + {transaction.cost.toFixed(2)} сомони + + + {transaction.total.toFixed(2)} сомони + + + )) + ) : ( + + + Нет операций за выбранный период + + + )} + +
+
+
+
+
+
+ ); +} diff --git a/src/widgets/cards-list.tsx b/src/widgets/cards-list.tsx new file mode 100644 index 0000000..0c71a56 --- /dev/null +++ b/src/widgets/cards-list.tsx @@ -0,0 +1,76 @@ +'use client'; + +import { BarChart, CreditCard, Download, FileText } from 'lucide-react'; + +import { Button } from '@/shared/shadcn-ui/button'; +import { Card, CardContent } from '@/shared/shadcn-ui/card'; + +interface CardsListProps { + totalCards: number; +} + +export const CardsList = ({ totalCards }: CardsListProps) => { + return ( +
+
+

Топливные карты

+
+ + + +
+
+
+ {Array.from({ length: 4 }).map((_, index) => ( + + +
+
+
+

+ Карта #{index + 1} +

+

**** **** **** {1000 + index}

+
+ +
+
+
+
+

Лимит:

+

+ {(5000 * (index + 1)).toLocaleString()} сомони +

+
+
+

Статус:

+ + Активна + +
+
+
+
+ ))} + {/* Show more cards button */} + {totalCards > 4 && ( + + )} +
+
+ ); +};