Compare commits
10 Commits
a475c50b20
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7924acd23f | ||
|
|
223c2d3bd6 | ||
|
|
cb630b4c01 | ||
|
|
4e0409949c | ||
|
|
5380866af3 | ||
|
|
9ea671b57c | ||
|
|
5614894e49 | ||
|
|
14921074a5 | ||
|
|
410410bc85 | ||
|
|
4b17da42e8 |
@@ -17,12 +17,16 @@ import {
|
||||
Lock as KeyIcon,
|
||||
Visibility as EyeIcon,
|
||||
VisibilityOff as EyeOffIcon,
|
||||
Notifications as BellIcon
|
||||
Notifications as BellIcon,
|
||||
IntegrationInstructions as IntegrationIcon
|
||||
} from "@mui/icons-material";
|
||||
import AccountProfile from "../../components/AccountProfile";
|
||||
import AccountSecurity from "../../components/AccountSecurity";
|
||||
import AccountNotifications from "../../components/AccountNotifications";
|
||||
import AccountAgentTransactionSection from "../../components/AccountAgentTransactionSection";
|
||||
import TabsNav from "../../components/TabsNav";
|
||||
import AccountIntegration from "../../components/AccountIntegration";
|
||||
import Cookies from "js-cookie";
|
||||
|
||||
const initialNotifications = {
|
||||
emailNotifications: true,
|
||||
@@ -47,6 +51,7 @@ export default function AccountPage() {
|
||||
{ id: "security", label: "Безопасность", icon: <KeyIcon fontSize="small" /> },
|
||||
{ id: "notifications", label: "Уведомления", icon: <BellIcon fontSize="small" /> },
|
||||
{ id: "agent-transactions", label: "Транзакции агентов", icon: <WorkIcon fontSize="small" /> },
|
||||
{ id: "integration", label: "Интеграции", icon: <IntegrationIcon fontSize="small" /> },
|
||||
];
|
||||
|
||||
return (
|
||||
@@ -54,22 +59,7 @@ export default function AccountPage() {
|
||||
<div className={styles.dashboard}>
|
||||
<h1 className={styles.title}>Аккаунт</h1>
|
||||
<div className={accountStyles.accountTabsNav}>
|
||||
<nav className={accountStyles.accountTabsNav}>
|
||||
{tabs.map(tab => (
|
||||
<button
|
||||
key={tab.id}
|
||||
onClick={() => setActiveTab(tab.id)}
|
||||
className={
|
||||
activeTab === tab.id
|
||||
? `${accountStyles.accountTabsButton} ${accountStyles.accountTabsButtonActive}`
|
||||
: accountStyles.accountTabsButton
|
||||
}
|
||||
>
|
||||
{tab.icon}
|
||||
{tab.label}
|
||||
</button>
|
||||
))}
|
||||
</nav>
|
||||
<TabsNav activeTab={activeTab} setActiveTab={setActiveTab} tabs={tabs} />
|
||||
</div>
|
||||
{activeTab === "profile" && (
|
||||
<AccountProfile />
|
||||
@@ -83,6 +73,9 @@ export default function AccountPage() {
|
||||
{activeTab === "agent-transactions" && (
|
||||
<AccountAgentTransactionSection />
|
||||
)}
|
||||
{activeTab === "integration" && (
|
||||
<AccountIntegration />
|
||||
)}
|
||||
</div>
|
||||
</AuthGuard>
|
||||
);
|
||||
|
||||
15
src/app/category/page.tsx
Normal file
15
src/app/category/page.tsx
Normal file
@@ -0,0 +1,15 @@
|
||||
"use client";
|
||||
import SaleCategoriesTable from "../../components/SaleCategoriesTable";
|
||||
import AuthGuard from "../../components/AuthGuard";
|
||||
import styles from "../../styles/category.module.css";
|
||||
|
||||
export default function CategoryPage() {
|
||||
return (
|
||||
<AuthGuard>
|
||||
<div className={styles.categoryPage}>
|
||||
<h1 className={styles.categoryTitle}>Категории товаров</h1>
|
||||
<SaleCategoriesTable />
|
||||
</div>
|
||||
</AuthGuard>
|
||||
);
|
||||
}
|
||||
@@ -8,6 +8,7 @@ import styles from "../../styles/stat.module.css";
|
||||
import DateInput from "../../components/DateInput";
|
||||
import DateFilters from "../../components/DateFilters";
|
||||
import AuthGuard from "../../components/AuthGuard";
|
||||
import TabsNav from "../../components/TabsNav";
|
||||
|
||||
const tabs = [
|
||||
{ id: "agents", label: "Агенты" },
|
||||
@@ -40,17 +41,7 @@ export default function StatPage() {
|
||||
<h1 className={styles.title}>Статистика и аналитика</h1>
|
||||
{/* <button className={styles.exportBtn}>Экспорт</button> */}
|
||||
</div>
|
||||
<div className={styles.tabs}>
|
||||
{tabs.map((tab) => (
|
||||
<button
|
||||
key={tab.id}
|
||||
className={activeTab === tab.id ? styles.activeTab : styles.tab}
|
||||
onClick={() => setActiveTab(tab.id)}
|
||||
>
|
||||
{tab.label}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
<TabsNav activeTab={activeTab} setActiveTab={setActiveTab} tabs={tabs} />
|
||||
|
||||
<DateFilters
|
||||
dateStart={filters.dateStart}
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import { useState } from "react";
|
||||
import { useState, useEffect } from "react";
|
||||
import DateFilters from "./DateFilters";
|
||||
import AccountAgentTransactionTable from "./AccountAgentTransactionTable";
|
||||
import styles from "../styles/account.module.css";
|
||||
import Cookies from 'js-cookie';
|
||||
|
||||
export default function AccountAgentTransactionSection() {
|
||||
const [filters, setFilters] = useState({
|
||||
@@ -12,6 +13,33 @@ export default function AccountAgentTransactionSection() {
|
||||
const [autoConfirmEnabled, setAutoConfirmEnabled] = useState(false);
|
||||
const [showConfirmationUI, setShowConfirmationUI] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
const fetchAutoApproveSettings = async () => {
|
||||
const token = Cookies.get("access_token");
|
||||
if (!token) {
|
||||
console.warn("Токен авторизации не найден при загрузке настроек автоподтверждения.");
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const res = await fetch("/api/account/auto-approve", {
|
||||
headers: {
|
||||
'Authorization': `Bearer ${token}`
|
||||
}
|
||||
});
|
||||
if (!res.ok) {
|
||||
console.error('Ошибка при загрузке настроек автоподтверждения:', res.status, res.statusText);
|
||||
return;
|
||||
}
|
||||
const data = await res.json();
|
||||
setAutoConfirmEnabled(data.auto_approve_transactions);
|
||||
} catch (error) {
|
||||
console.error('Ошибка при загрузке настроек автоподтверждения:', error);
|
||||
}
|
||||
};
|
||||
|
||||
fetchAutoApproveSettings();
|
||||
}, []);
|
||||
|
||||
function handleApply() {
|
||||
setReloadKey(k => k + 1);
|
||||
}
|
||||
@@ -25,24 +53,72 @@ export default function AccountAgentTransactionSection() {
|
||||
if (isChecked) {
|
||||
setShowConfirmationUI(true);
|
||||
} else {
|
||||
updateAutoApproveSettings(false, false);
|
||||
setAutoConfirmEnabled(false);
|
||||
setShowConfirmationUI(false);
|
||||
console.log("Автоматическое подтверждение выключено.");
|
||||
}
|
||||
};
|
||||
|
||||
const handleConfirmYes = () => {
|
||||
setAutoConfirmEnabled(true);
|
||||
setShowConfirmationUI(false);
|
||||
console.log("Автоматическое подтверждение включено и текущие транзакции будут подтверждены.");
|
||||
// TODO: Добавить логику автоматического подтверждения текущих транзакций
|
||||
const updateAutoApproveSettings = async (auto_approve: boolean, apply_to_current: boolean = false) => {
|
||||
const token = Cookies.get("access_token");
|
||||
if (!token) {
|
||||
console.warn("Токен авторизации не найден при попытке обновить настройки автоподтверждения.");
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const res = await fetch("/api/account/auto-approve", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Authorization': `Bearer ${token}`
|
||||
},
|
||||
body: JSON.stringify({
|
||||
auto_approve: auto_approve,
|
||||
apply_to_current: apply_to_current,
|
||||
})
|
||||
});
|
||||
if (!res.ok) {
|
||||
const errorData = await res.json();
|
||||
console.error('Ошибка при обновлении настроек автоподтверждения:', res.status, res.statusText, errorData);
|
||||
return false;
|
||||
}
|
||||
const responseData = await res.json();
|
||||
console.log('Настройка автоподтверждения успешно обновлена:', responseData);
|
||||
if (apply_to_current) {
|
||||
setReloadKey(k => k + 1);
|
||||
}
|
||||
return true;
|
||||
} catch (error) {
|
||||
console.error('Ошибка при отправке запроса на обновление настроек автоподтверждения:', error);
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
const handleConfirmNo = () => {
|
||||
setAutoConfirmEnabled(true);
|
||||
setShowConfirmationUI(false);
|
||||
console.log("Автоматическое подтверждение включено для новых транзакций. Текущие остаются неподтвержденными.");
|
||||
// Текущие транзакции остаются в статусе waiting, ничего дополнительно делать не нужно
|
||||
const handleConfirmYes = async () => {
|
||||
const success = await updateAutoApproveSettings(true, true);
|
||||
if (success) {
|
||||
setAutoConfirmEnabled(true);
|
||||
setShowConfirmationUI(false);
|
||||
console.log("Автоматическое подтверждение включено и текущие транзакции будут подтверждены.");
|
||||
} else {
|
||||
setAutoConfirmEnabled(false);
|
||||
setShowConfirmationUI(false);
|
||||
console.log("Включение автоматического подтверждения не удалось.");
|
||||
}
|
||||
};
|
||||
|
||||
const handleConfirmNo = async () => {
|
||||
const success = await updateAutoApproveSettings(true, false);
|
||||
if (success) {
|
||||
setAutoConfirmEnabled(true);
|
||||
setShowConfirmationUI(false);
|
||||
console.log("Автоматическое подтверждение включено для новых транзакций. Текущие остаются неподтвержденными.");
|
||||
} else {
|
||||
setAutoConfirmEnabled(false);
|
||||
setShowConfirmationUI(false);
|
||||
console.log("Включение автоматического подтверждения не удалось.");
|
||||
}
|
||||
};
|
||||
|
||||
const handleConfirmCancel = () => {
|
||||
@@ -67,6 +143,7 @@ export default function AccountAgentTransactionSection() {
|
||||
checked={autoConfirmEnabled}
|
||||
onChange={handleToggleChange}
|
||||
className={styles.notificationsSwitchInput}
|
||||
disabled={showConfirmationUI}
|
||||
/>
|
||||
<span
|
||||
className={
|
||||
@@ -116,7 +193,7 @@ export default function AccountAgentTransactionSection() {
|
||||
onApply={handleApply}
|
||||
onClear={handleClear}
|
||||
/>
|
||||
<AccountAgentTransactionTable filters={filters} reloadKey={reloadKey} />
|
||||
<AccountAgentTransactionTable filters={filters} reloadKey={reloadKey} setReloadKey={setReloadKey} />
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -13,6 +13,7 @@ const STATUS_COLORS: Record<string, string> = {
|
||||
"error": "#EF4444", // Красный
|
||||
"process": "#3B82F6", // Синий
|
||||
"reject": "#800080", // Фиолетовый
|
||||
"new": "#E30B5C", // Малиновый
|
||||
};
|
||||
|
||||
function formatCurrency(amount: number) {
|
||||
@@ -23,13 +24,15 @@ function formatCurrency(amount: number) {
|
||||
}) ?? "";
|
||||
}
|
||||
|
||||
export default function AccountAgentTransactionTable({ filters, reloadKey }: { filters: { dateStart: string, dateEnd: string }, reloadKey: number }) {
|
||||
export default function AccountAgentTransactionTable({ filters, reloadKey, setReloadKey }: { filters: { dateStart: string, dateEnd: string }, reloadKey: number, setReloadKey: React.Dispatch<React.SetStateAction<number>> }) {
|
||||
const [data, setData] = useState<any[]>([]);
|
||||
const [isLoading, setIsLoading] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
const token = Cookies.get("access_token");
|
||||
|
||||
if (token) {
|
||||
setIsLoading(true);
|
||||
const params = new URLSearchParams();
|
||||
if (filters.dateStart) params.append('date_start', filters.dateStart);
|
||||
if (filters.dateEnd) params.append('date_end', filters.dateEnd);
|
||||
@@ -57,6 +60,9 @@ export default function AccountAgentTransactionTable({ filters, reloadKey }: { f
|
||||
.catch(error => {
|
||||
console.error('Ошибка при загрузке данных транзакций агентов:', error);
|
||||
setData([]);
|
||||
})
|
||||
.finally(() => {
|
||||
setIsLoading(false);
|
||||
});
|
||||
} else {
|
||||
console.warn('Токен авторизации не найден в куках.');
|
||||
@@ -74,7 +80,7 @@ export default function AccountAgentTransactionTable({ filters, reloadKey }: { f
|
||||
Cell: ({ cell }) => {
|
||||
const status = cell.getValue() as string;
|
||||
const color = STATUS_COLORS[status] || '#A3A3A3';
|
||||
return <span style={{ color: color }}>{status}</span>;
|
||||
return <span style={{ color: color, fontWeight: 600 }}>{status}</span>;
|
||||
}
|
||||
},
|
||||
{ accessorKey: 'create_dttm', header: 'Дата создания', Cell: ({ cell }) => new Date(cell.getValue() as string).toLocaleDateString() },
|
||||
@@ -93,16 +99,55 @@ export default function AccountAgentTransactionTable({ filters, reloadKey }: { f
|
||||
columns,
|
||||
data,
|
||||
enableRowSelection: true,
|
||||
state: {
|
||||
isLoading: isLoading,
|
||||
},
|
||||
renderTopToolbarCustomActions: ({ table }) => (
|
||||
<Box sx={{ display: 'flex', gap: 2, p: 1, flexWrap: 'wrap' }}>
|
||||
<Button
|
||||
onClick={() => {
|
||||
onClick={async () => {
|
||||
const selectedRows = table.getSelectedRowModel().rows;
|
||||
console.log('Выбранные строки для выплаты:', selectedRows.map(row => row.original));
|
||||
// Здесь будет логика для отправки запроса на выплату
|
||||
const transactionIdsToApprove = selectedRows.map(row => row.original.transaction_group);
|
||||
|
||||
if (transactionIdsToApprove.length === 0) {
|
||||
console.warn('Выберите транзакции для выплаты.');
|
||||
return;
|
||||
}
|
||||
|
||||
const token = Cookies.get("access_token");
|
||||
if (!token) {
|
||||
console.warn('Токен авторизации не найден. Пожалуйста, войдите снова.');
|
||||
return;
|
||||
}
|
||||
|
||||
setIsLoading(true);
|
||||
try {
|
||||
const response = await fetch('/api/account/approve-transactions', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Authorization': `Bearer ${token}`
|
||||
},
|
||||
body: JSON.stringify({ transaction_ids: transactionIdsToApprove }),
|
||||
});
|
||||
|
||||
const result = await response.json();
|
||||
|
||||
if (response.ok) {
|
||||
console.log(result.msg || `Успешно утверждено ${result.approved_count || 0} транзакций.`);
|
||||
table.toggleAllRowsSelected(false);
|
||||
setReloadKey(prev => prev + 1);
|
||||
} else {
|
||||
console.error('Ошибка утверждения транзакций:', result);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Ошибка запроса утверждения транзакций:', error);
|
||||
} finally {
|
||||
setIsLoading(false);
|
||||
}
|
||||
}}
|
||||
startIcon={<PaymentIcon />}
|
||||
disabled={!table.getSelectedRowModel().rows.length}
|
||||
disabled={!table.getSelectedRowModel().rows.length || isLoading}
|
||||
variant="contained"
|
||||
color="primary"
|
||||
>
|
||||
|
||||
208
src/components/AccountIntegration.tsx
Normal file
208
src/components/AccountIntegration.tsx
Normal file
@@ -0,0 +1,208 @@
|
||||
"use client";
|
||||
import React, { useState, useMemo, useEffect } from "react";
|
||||
import {
|
||||
Box,
|
||||
Button,
|
||||
Typography,
|
||||
Dialog,
|
||||
DialogActions,
|
||||
DialogContent,
|
||||
DialogContentText,
|
||||
DialogTitle,
|
||||
IconButton
|
||||
} from "@mui/material";
|
||||
import CreateTokenDialog from "./CreateTokenDialog";
|
||||
import IntegrationTokensTable from "./IntegrationTokensTable";
|
||||
import styles from "../styles/account.module.css";
|
||||
import Cookies from "js-cookie";
|
||||
import { Token } from "../types/tokens";
|
||||
|
||||
// Компонент для управления интеграциями и токенами
|
||||
// interface Token {
|
||||
// description: string;
|
||||
// masked_token: string;
|
||||
// rawToken?: string;
|
||||
// create_dttm: string;
|
||||
// use_dttm?: string;
|
||||
// }
|
||||
|
||||
const AccountIntegration = () => {
|
||||
const [tokens, setTokens] = useState<Token[]>([]);
|
||||
const [openCreateDialog, setOpenCreateDialog] = useState(false);
|
||||
const [showTokenCreatedSuccess, setShowTokenCreatedSuccess] = useState(false);
|
||||
const [createdRawToken, setCreatedRawToken] = useState<string | null>(null);
|
||||
const [openEditDialog, setOpenEditDialog] = useState(false);
|
||||
const [editingToken, setEditingToken] = useState<Token | null>(null);
|
||||
|
||||
const fetchTokens = async () => {
|
||||
try {
|
||||
const token = Cookies.get("access_token");
|
||||
if (!token) {
|
||||
console.error("Access token not found");
|
||||
return;
|
||||
}
|
||||
const res = await fetch("/api/account/integration-tokens", {
|
||||
method: "GET",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
"Authorization": `Bearer ${token}`
|
||||
},
|
||||
});
|
||||
if (!res.ok) {
|
||||
throw new Error(`HTTP error! status: ${res.status}`);
|
||||
}
|
||||
const data: Token[] = await res.json();
|
||||
setTokens(data);
|
||||
} catch (error) {
|
||||
console.error("Failed to fetch tokens:", error);
|
||||
}
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
fetchTokens();
|
||||
}, []);
|
||||
|
||||
const handleOpenCreateDialog = () => {
|
||||
setOpenCreateDialog(true);
|
||||
setCreatedRawToken(null);
|
||||
};
|
||||
|
||||
const handleCloseCreateDialog = () => {
|
||||
setOpenCreateDialog(false);
|
||||
};
|
||||
|
||||
const handleOpenEditDialog = (token: Token) => {
|
||||
setEditingToken(token);
|
||||
setOpenEditDialog(true);
|
||||
};
|
||||
|
||||
const handleCloseEditDialog = () => {
|
||||
setOpenEditDialog(false);
|
||||
setEditingToken(null);
|
||||
};
|
||||
|
||||
const handleTokenGenerate = async (description: string) => {
|
||||
try {
|
||||
const authToken = Cookies.get("access_token");
|
||||
if (!authToken) {
|
||||
console.error("Access token not found");
|
||||
return;
|
||||
}
|
||||
|
||||
const res = await fetch("/api/account/integration-tokens", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
"Authorization": `Bearer ${authToken}`
|
||||
},
|
||||
body: JSON.stringify({ description: description })
|
||||
});
|
||||
|
||||
if (!res.ok) {
|
||||
const errorData = await res.json();
|
||||
throw new Error(errorData.detail || "Ошибка генерации токена");
|
||||
}
|
||||
|
||||
const newTokenData: Token = await res.json();
|
||||
|
||||
await fetchTokens();
|
||||
|
||||
setCreatedRawToken(newTokenData.rawToken || null);
|
||||
setShowTokenCreatedSuccess(true);
|
||||
setTimeout(() => setShowTokenCreatedSuccess(false), 3000);
|
||||
} catch (error: any) {
|
||||
console.error("Ошибка при генерации токена:", error.message);
|
||||
}
|
||||
};
|
||||
|
||||
const handleTokenUpdate = async (id: number, updatedDescription: string) => {
|
||||
try {
|
||||
const authToken = Cookies.get("access_token");
|
||||
if (!authToken) {
|
||||
console.error("Access token not found");
|
||||
return;
|
||||
}
|
||||
|
||||
const res = await fetch("/api/account/integration-tokens/update-description", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
"Authorization": `Bearer ${authToken}`
|
||||
},
|
||||
body: JSON.stringify({ id: id, description: updatedDescription })
|
||||
});
|
||||
|
||||
if (!res.ok) {
|
||||
const errorData = await res.json();
|
||||
throw new Error(errorData.detail || "Ошибка обновления описания токена");
|
||||
}
|
||||
|
||||
// После успешного обновления, обновим список токенов
|
||||
await fetchTokens();
|
||||
setOpenEditDialog(false);
|
||||
setEditingToken(null);
|
||||
} catch (error: any) {
|
||||
console.error("Ошибка при обновлении токена:", error.message);
|
||||
}
|
||||
};
|
||||
|
||||
const handleDeleteToken = async (id: number) => {
|
||||
try {
|
||||
const authToken = Cookies.get("access_token");
|
||||
if (!authToken) {
|
||||
console.error("Access token not found");
|
||||
return;
|
||||
}
|
||||
|
||||
const res = await fetch(`/api/account/integration-tokens/${id}`, {
|
||||
method: "DELETE",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
"Authorization": `Bearer ${authToken}`
|
||||
},
|
||||
});
|
||||
|
||||
if (!res.ok) {
|
||||
const errorData = await res.json();
|
||||
throw new Error(errorData.detail || "Ошибка удаления токена");
|
||||
}
|
||||
|
||||
await fetchTokens();
|
||||
} catch (error: any) {
|
||||
console.error("Ошибка при удалении токена:", error.message);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<Box sx={{ padding: 2 }}>
|
||||
<Typography variant="h5" gutterBottom>
|
||||
Управление токенами интеграции
|
||||
</Typography>
|
||||
|
||||
<IntegrationTokensTable
|
||||
tokens={tokens}
|
||||
onOpenCreateDialog={handleOpenCreateDialog}
|
||||
onOpenEditDialog={handleOpenEditDialog}
|
||||
onDeleteToken={handleDeleteToken}
|
||||
/>
|
||||
|
||||
<CreateTokenDialog
|
||||
open={openCreateDialog}
|
||||
onClose={handleCloseCreateDialog}
|
||||
onTokenGenerate={handleTokenGenerate}
|
||||
generatedToken={createdRawToken}
|
||||
/>
|
||||
|
||||
<CreateTokenDialog
|
||||
open={openEditDialog}
|
||||
onClose={handleCloseEditDialog}
|
||||
isEditMode={true}
|
||||
initialDescription={editingToken?.description || ""}
|
||||
editingTokenId={editingToken?.id || 0}
|
||||
onTokenUpdate={handleTokenUpdate}
|
||||
/>
|
||||
</Box>
|
||||
);
|
||||
};
|
||||
|
||||
export default AccountIntegration;
|
||||
@@ -32,7 +32,7 @@ const AccountProfileCompany: React.FC<AccountProfileCompanyProps> = ({
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<label className={styles.label}>Процент комиссии</label>
|
||||
<label className={styles.label}>Процент комиссии компании</label>
|
||||
<div className={styles.commissionValue}>{commissionRate}%</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
"use client";
|
||||
import { ResponsiveContainer, BarChart, Bar, XAxis, YAxis, CartesianGrid, Tooltip, LabelList, Label } from "recharts";
|
||||
import { useEffect, useState } from "react";
|
||||
import Cookies from 'js-cookie';
|
||||
|
||||
interface AgentBarData {
|
||||
name: string;
|
||||
@@ -28,13 +29,25 @@ const AgentsBarChart: React.FC = () => {
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
|
||||
useEffect(() => {
|
||||
fetch("/api/dashboard/chart/agent")
|
||||
const token = Cookies.get("access_token");
|
||||
if (!token) {
|
||||
console.warn("Токен авторизации не найден.");
|
||||
setError("Токен авторизации не найден.");
|
||||
setLoading(false);
|
||||
return;
|
||||
}
|
||||
|
||||
fetch("/api/dashboard/chart/agent", {
|
||||
headers: {
|
||||
'Authorization': `Bearer ${token}`
|
||||
}
|
||||
})
|
||||
.then((res) => {
|
||||
if (!res.ok) throw new Error("Ошибка загрузки данных");
|
||||
return res.json();
|
||||
})
|
||||
.then((data) => {
|
||||
setData(data);
|
||||
setData(data.items);
|
||||
setLoading(false);
|
||||
})
|
||||
.catch((err) => {
|
||||
|
||||
@@ -4,6 +4,7 @@ import styles from "../styles/stat.module.css";
|
||||
import { Box, Button } from '@mui/material';
|
||||
import FileDownloadIcon from '@mui/icons-material/FileDownload';
|
||||
import { mkConfig, generateCsv, download } from 'export-to-csv';
|
||||
import Cookies from 'js-cookie';
|
||||
|
||||
function formatCurrency(amount: number) {
|
||||
return amount?.toLocaleString("ru-RU", {
|
||||
@@ -20,9 +21,21 @@ export default function AgentsTable({ filters, reloadKey }: { filters: { dateSta
|
||||
const params = new URLSearchParams();
|
||||
if (filters.dateStart) params.append('date_start', filters.dateStart);
|
||||
if (filters.dateEnd) params.append('date_end', filters.dateEnd);
|
||||
fetch(`/api/stat/agents?${params.toString()}`)
|
||||
|
||||
const token = Cookies.get("access_token");
|
||||
if (!token) {
|
||||
console.warn("Токен авторизации не найден.");
|
||||
setData([]); // Очистить данные, если токен отсутствует
|
||||
return;
|
||||
}
|
||||
|
||||
fetch(`/api/stat/agents?${params.toString()}`, {
|
||||
headers: {
|
||||
'Authorization': `Bearer ${token}`
|
||||
}
|
||||
})
|
||||
.then(res => res.json())
|
||||
.then(setData)
|
||||
.then(apiData => setData(apiData.items))
|
||||
.catch(() => setData([]));
|
||||
}, [filters.dateStart, filters.dateEnd, reloadKey]);
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import MetricCard from "./MetricCard";
|
||||
import styles from "../styles/billing.module.css";
|
||||
import React, { useEffect, useState } from "react";
|
||||
import Cookies from 'js-cookie';
|
||||
|
||||
interface BillingCardsData {
|
||||
cost: number;
|
||||
@@ -22,7 +23,19 @@ const BillingMetricCards: React.FC = () => {
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
fetch("/api/billing/cards")
|
||||
const token = Cookies.get("access_token");
|
||||
if (!token) {
|
||||
console.warn("Токен авторизации не найден.");
|
||||
setError("Токен авторизации не найден.");
|
||||
setLoading(false);
|
||||
return;
|
||||
}
|
||||
|
||||
fetch("/api/billing/cards", {
|
||||
headers: {
|
||||
'Authorization': `Bearer ${token}`
|
||||
}
|
||||
})
|
||||
.then((res) => {
|
||||
if (!res.ok) throw new Error("Ошибка загрузки данных");
|
||||
return res.json();
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
import { useMemo } from 'react';
|
||||
import { useMemo, useState, useEffect } from 'react';
|
||||
import { MaterialReactTable, MRT_ColumnDef, MRT_Row, useMaterialReactTable } from 'material-react-table';
|
||||
import mockData from '../data/mockData';
|
||||
import { Box, Button } from '@mui/material';
|
||||
import FileDownloadIcon from '@mui/icons-material/FileDownload';
|
||||
import { mkConfig, generateCsv, download } from 'export-to-csv';
|
||||
import Cookies from 'js-cookie';
|
||||
|
||||
function formatCurrency(amount: number) {
|
||||
return amount?.toLocaleString('ru-RU', {
|
||||
@@ -14,24 +15,67 @@ function formatCurrency(amount: number) {
|
||||
}
|
||||
|
||||
const statusColor: Record<string, string> = {
|
||||
'Завершена': '#4caf50',
|
||||
'Ожидается': '#ff9800',
|
||||
'Ошибка': '#f44336',
|
||||
'done': '#10B981', // green
|
||||
'waiting': '#F59E0B', // orange
|
||||
'error': '#EF4444', // red
|
||||
'process': '#3B82F6', // blue
|
||||
'reject': '#800080', // purple
|
||||
'new': '#E30B5C', // pink
|
||||
};
|
||||
|
||||
const csvConfig = mkConfig({
|
||||
fieldSeparator: ',',
|
||||
decimalSeparator: '.',
|
||||
decimalSeparator: '.', // This should be '.' for CSV regardless of locale for parsing.
|
||||
useKeysAsHeaders: true,
|
||||
});
|
||||
|
||||
export default function BillingPayoutsTable() {
|
||||
export default function BillingPayoutsTable({ filters, reloadKey }: { filters: { dateStart: string, dateEnd: string }, reloadKey: number }) {
|
||||
const [data, setData] = useState<any[]>([]);
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
|
||||
useEffect(() => {
|
||||
const params = new URLSearchParams();
|
||||
if (filters.dateStart) params.append('date_start', filters.dateStart);
|
||||
if (filters.dateEnd) params.append('date_end', filters.dateEnd);
|
||||
|
||||
const token = Cookies.get("access_token");
|
||||
if (!token) {
|
||||
console.warn("Токен авторизации не найден.");
|
||||
setError("Токен авторизации не найден.");
|
||||
setLoading(false);
|
||||
setData([]);
|
||||
return;
|
||||
}
|
||||
|
||||
fetch(`/api/billing/payouts/transactions?${params.toString()}`, {
|
||||
headers: {
|
||||
'Authorization': `Bearer ${token}`
|
||||
}
|
||||
})
|
||||
.then(res => {
|
||||
if (!res.ok) {
|
||||
throw new Error(`Ошибка загрузки данных: ${res.status} ${res.statusText}`);
|
||||
}
|
||||
return res.json();
|
||||
})
|
||||
.then(apiData => {
|
||||
setData(apiData.items);
|
||||
setLoading(false);
|
||||
})
|
||||
.catch(err => {
|
||||
setError(err.message);
|
||||
setLoading(false);
|
||||
setData([]);
|
||||
});
|
||||
}, [filters.dateStart, filters.dateEnd, reloadKey]);
|
||||
|
||||
const columns = useMemo<MRT_ColumnDef<any>[]>(
|
||||
() => [
|
||||
{ accessorKey: 'id', header: 'ID' },
|
||||
{ accessorKey: 'amount', header: 'Сумма',
|
||||
Cell: ({ cell }) => formatCurrency(cell.getValue() as number) },
|
||||
{ accessorKey: 'date', header: 'Дата' },
|
||||
{ accessorKey: 'agent', header: 'Агент' }, // Добавлено поле для имени агента
|
||||
{ accessorKey: 'status', header: 'Статус',
|
||||
Cell: ({ cell }) => (
|
||||
<span style={{ color: statusColor[cell.getValue() as string] || '#333', fontWeight: 600 }}>
|
||||
@@ -39,14 +83,17 @@ export default function BillingPayoutsTable() {
|
||||
</span>
|
||||
)
|
||||
},
|
||||
{ accessorKey: 'method', header: 'Способ' },
|
||||
{ accessorKey: 'create_dttm', header: 'Дата создания',
|
||||
Cell: ({ cell }) => new Date(cell.getValue() as string).toLocaleDateString("ru-RU") },
|
||||
{ accessorKey: 'update_dttm', header: 'Дата обновления',
|
||||
Cell: ({ cell }) => new Date(cell.getValue() as string).toLocaleDateString("ru-RU") },
|
||||
],
|
||||
[]
|
||||
);
|
||||
|
||||
const table = useMaterialReactTable({
|
||||
columns,
|
||||
data: mockData.payouts,
|
||||
data,
|
||||
enableRowSelection: false,
|
||||
renderTopToolbarCustomActions: ({ table }) => (
|
||||
<Box sx={{ display: 'flex', gap: 2, p: 1, flexWrap: 'wrap' }}>
|
||||
@@ -64,6 +111,10 @@ export default function BillingPayoutsTable() {
|
||||
muiTableBodyCellProps: { sx: { fontSize: 14 } },
|
||||
muiTableHeadCellProps: { sx: { fontWeight: 700 } },
|
||||
initialState: { pagination: { pageSize: 10, pageIndex: 0 } },
|
||||
state: { isLoading: loading, showAlertBanner: error !== null, showProgressBars: loading },
|
||||
renderEmptyRowsFallback: () => (
|
||||
<div>{error ? `Ошибка: ${error}` : (loading ? 'Загрузка данных...' : 'Данные не найдены.')}</div>
|
||||
)
|
||||
});
|
||||
|
||||
const handleExportRows = (rows: MRT_Row<any>[]) => {
|
||||
@@ -73,7 +124,7 @@ export default function BillingPayoutsTable() {
|
||||
};
|
||||
|
||||
const handleExportData = () => {
|
||||
const csv = generateCsv(csvConfig)(mockData.payouts);
|
||||
const csv = generateCsv(csvConfig)(data);
|
||||
download(csvConfig)(csv);
|
||||
};
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
import React, { useEffect, useState } from "react";
|
||||
import { PieChart, Pie, Cell, Tooltip, ResponsiveContainer } from "recharts";
|
||||
import styles from "../styles/billing.module.css";
|
||||
import Cookies from 'js-cookie';
|
||||
|
||||
const STATUS_COLORS: Record<string, string> = {
|
||||
"done": "#10B981",
|
||||
@@ -9,15 +10,26 @@ const STATUS_COLORS: Record<string, string> = {
|
||||
"error": "#EF4444",
|
||||
"process": "#3B82F6",
|
||||
"reject": "#800080",
|
||||
"new": "#E30B5C",
|
||||
};
|
||||
|
||||
const BillingPieChart: React.FC = () => {
|
||||
const [data, setData] = useState<{ name: string; value: number; fill: string }[]>([]);
|
||||
useEffect(() => {
|
||||
fetch("/api/billing/chart/pie")
|
||||
const token = Cookies.get("access_token");
|
||||
if (!token) {
|
||||
console.warn("Токен авторизации не найден.");
|
||||
return;
|
||||
}
|
||||
|
||||
fetch("/api/billing/chart/pie", {
|
||||
headers: {
|
||||
'Authorization': `Bearer ${token}`
|
||||
}
|
||||
})
|
||||
.then((res) => res.json())
|
||||
.then((apiData) => {
|
||||
const mapped = apiData.map((item: { status: string; count: number }) => ({
|
||||
const mapped = apiData.items.map((item: { status: string; count: number }) => ({
|
||||
name: item.status,
|
||||
value: item.count,
|
||||
fill: STATUS_COLORS[item.status] || "#A3A3A3",
|
||||
|
||||
@@ -4,6 +4,7 @@ import { useEffect, useState } from "react";
|
||||
import styles from "../styles/billing.module.css";
|
||||
import { TooltipProps } from "recharts";
|
||||
import { ValueType, NameType } from "recharts/types/component/DefaultTooltipContent";
|
||||
import Cookies from 'js-cookie';
|
||||
|
||||
const statusColors: Record<string, string> = {
|
||||
done: "#10B981",
|
||||
@@ -11,6 +12,7 @@ const statusColors: Record<string, string> = {
|
||||
waiting: "#F59E42",
|
||||
error: "#EF4444",
|
||||
reject: "#800080",
|
||||
new: "#E30B5C",
|
||||
};
|
||||
|
||||
const BillingStatChart: React.FC = () => {
|
||||
@@ -18,13 +20,23 @@ const BillingStatChart: React.FC = () => {
|
||||
const [statuses, setStatuses] = useState<string[]>([]);
|
||||
|
||||
useEffect(() => {
|
||||
fetch("/api/billing/chart/stat")
|
||||
const token = Cookies.get("access_token");
|
||||
if (!token) {
|
||||
console.warn("Токен авторизации не найден.");
|
||||
return;
|
||||
}
|
||||
|
||||
fetch("/api/billing/chart/stat", {
|
||||
headers: {
|
||||
'Authorization': `Bearer ${token}`
|
||||
}
|
||||
})
|
||||
.then(res => res.json())
|
||||
.then((apiData) => {
|
||||
// Собираем все уникальные даты и статусы
|
||||
const allDates = new Set<string>();
|
||||
const allStatuses = new Set<string>();
|
||||
apiData.forEach((item: any) => {
|
||||
apiData.items.forEach((item: any) => {
|
||||
allDates.add(item.date);
|
||||
allStatuses.add(item.status);
|
||||
});
|
||||
@@ -38,7 +50,7 @@ const BillingStatChart: React.FC = () => {
|
||||
grouped[date][status] = 0;
|
||||
});
|
||||
});
|
||||
apiData.forEach((item: any) => {
|
||||
apiData.items.forEach((item: any) => {
|
||||
grouped[item.date][item.status] = item.count;
|
||||
});
|
||||
const sorted = sortedDates.map(date => grouped[date]);
|
||||
|
||||
120
src/components/CreateTokenDialog.tsx
Normal file
120
src/components/CreateTokenDialog.tsx
Normal file
@@ -0,0 +1,120 @@
|
||||
"use client";
|
||||
import React, { useState, useEffect } from "react";
|
||||
import {
|
||||
Box,
|
||||
Button,
|
||||
TextField,
|
||||
Typography,
|
||||
Dialog,
|
||||
DialogActions,
|
||||
DialogContent,
|
||||
DialogTitle,
|
||||
} from "@mui/material";
|
||||
import styles from "../styles/account.module.css";
|
||||
import { Token } from "../types/tokens";
|
||||
|
||||
interface CreateTokenDialogProps {
|
||||
open: boolean;
|
||||
onClose: () => void;
|
||||
onTokenGenerate?: (description: string) => Promise<void>;
|
||||
isEditMode?: boolean;
|
||||
initialDescription?: string;
|
||||
editingTokenId?: number;
|
||||
onTokenUpdate?: (id: number, description: string) => void;
|
||||
generatedToken?: string | null;
|
||||
}
|
||||
|
||||
const CreateTokenDialog: React.FC<CreateTokenDialogProps> = ({
|
||||
open,
|
||||
onClose,
|
||||
onTokenGenerate,
|
||||
isEditMode = false,
|
||||
initialDescription = "",
|
||||
onTokenUpdate,
|
||||
generatedToken,
|
||||
editingTokenId,
|
||||
}) => {
|
||||
const [description, setDescription] = useState(initialDescription);
|
||||
const [showWarning, setShowWarning] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
if (open) {
|
||||
setDescription(initialDescription);
|
||||
setShowWarning(false);
|
||||
}
|
||||
}, [open, initialDescription]);
|
||||
|
||||
const handleGenerateClick = async () => {
|
||||
if (description.trim() === "") {
|
||||
setShowWarning(true);
|
||||
return;
|
||||
}
|
||||
await onTokenGenerate?.(description);
|
||||
};
|
||||
|
||||
const handleUpdateClick = () => {
|
||||
if (description.trim() === "") {
|
||||
setShowWarning(true);
|
||||
return;
|
||||
}
|
||||
console.log("Attempting to update token. editingTokenId:", editingTokenId, "Description:", description);
|
||||
if (onTokenUpdate && typeof editingTokenId === 'number') {
|
||||
onTokenUpdate(editingTokenId, description);
|
||||
onClose();
|
||||
} else {
|
||||
console.error("Cannot update token: onTokenUpdate is missing or editingTokenId is invalid.", {onTokenUpdateExists: !!onTokenUpdate, editingTokenIdValue: editingTokenId});
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<Dialog open={open} onClose={onClose} maxWidth="sm" fullWidth>
|
||||
<DialogTitle>{isEditMode ? "Редактировать токен" : "Создать новый токен"}</DialogTitle>
|
||||
<DialogContent>
|
||||
{showWarning && (
|
||||
<Typography color="error" variant="body2" sx={{ mb: 2 }}>
|
||||
Пожалуйста, введите описание токена.
|
||||
</Typography>
|
||||
)}
|
||||
<TextField
|
||||
autoFocus
|
||||
margin="dense"
|
||||
label="Описание токена"
|
||||
type="text"
|
||||
fullWidth
|
||||
variant="outlined"
|
||||
value={description}
|
||||
onChange={(e) => setDescription(e.target.value)}
|
||||
error={showWarning}
|
||||
helperText={showWarning ? "Описание не может быть пустым" : ""}
|
||||
/>
|
||||
{!isEditMode && generatedToken && (
|
||||
<Box sx={{ mt: 2, p: 2, border: '1px solid #ccc', borderRadius: '4px', backgroundColor: '#f0f0f0'}}>
|
||||
<Typography variant="subtitle2">Созданный токен:</Typography>
|
||||
<Box sx={{ display: 'flex', alignItems: 'center', gap: '8px'}}>
|
||||
<Typography variant="body2" sx={{ wordBreak: 'break-all'}}>
|
||||
{generatedToken}
|
||||
</Typography>
|
||||
</Box>
|
||||
<Typography variant="caption" color="textSecondary">
|
||||
Скопируйте этот токен. Он будет виден только сейчас.
|
||||
</Typography>
|
||||
</Box>
|
||||
)}
|
||||
</DialogContent>
|
||||
<DialogActions>
|
||||
{!generatedToken && <Button onClick={onClose}>Отмена</Button>}
|
||||
{isEditMode ? (
|
||||
<Button onClick={handleUpdateClick} variant="contained">
|
||||
Сохранить
|
||||
</Button>
|
||||
) : (
|
||||
<Button onClick={generatedToken ? onClose : handleGenerateClick} variant="contained">
|
||||
{generatedToken ? "ОК" : "Создать"}
|
||||
</Button>
|
||||
)}
|
||||
</DialogActions>
|
||||
</Dialog>
|
||||
);
|
||||
};
|
||||
|
||||
export default CreateTokenDialog;
|
||||
@@ -1,4 +1,6 @@
|
||||
import React from "react";
|
||||
import { CalendarToday } from "@mui/icons-material";
|
||||
import styles from "../styles/dateinput.module.css";
|
||||
|
||||
interface DateInputProps {
|
||||
label: string;
|
||||
@@ -11,13 +13,28 @@ interface DateInputProps {
|
||||
const DateInput: React.FC<DateInputProps> = ({ label, value, onChange, min, max }) => (
|
||||
<div>
|
||||
<label>{label}</label>
|
||||
<input
|
||||
type="date"
|
||||
value={value}
|
||||
onChange={onChange}
|
||||
min={min}
|
||||
max={max}
|
||||
/>
|
||||
<div style={{ position: "relative" }}>
|
||||
<input
|
||||
type="date"
|
||||
value={value}
|
||||
onChange={onChange}
|
||||
min={min}
|
||||
max={max}
|
||||
className={`${styles.dateInputHiddenIcon} ${styles.dateInputBase}`}
|
||||
/>
|
||||
<CalendarToday
|
||||
className={styles.dateIcon}
|
||||
fontSize="small"
|
||||
onClick={(e) => {
|
||||
const inputElement = e.currentTarget.previousElementSibling as HTMLInputElement;
|
||||
if (inputElement && typeof inputElement.showPicker === 'function') {
|
||||
inputElement.showPicker();
|
||||
} else {
|
||||
inputElement.focus();
|
||||
}
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
||||
|
||||
95
src/components/IntegrationTokensTable.tsx
Normal file
95
src/components/IntegrationTokensTable.tsx
Normal file
@@ -0,0 +1,95 @@
|
||||
"use client";
|
||||
import React, { useMemo } from "react";
|
||||
import {
|
||||
Box,
|
||||
Button,
|
||||
Typography,
|
||||
IconButton
|
||||
} from "@mui/material";
|
||||
import { MaterialReactTable, type MRT_ColumnDef, useMaterialReactTable } from "material-react-table";
|
||||
import { Add as AddIcon, Edit as EditIcon, Delete as DeleteIcon } from "@mui/icons-material";
|
||||
import { Token } from "../types/tokens";
|
||||
|
||||
interface IntegrationTokensTableProps {
|
||||
tokens: Token[];
|
||||
onOpenCreateDialog: () => void;
|
||||
onOpenEditDialog: (token: Token) => void;
|
||||
onDeleteToken: (id: number) => void;
|
||||
}
|
||||
|
||||
const IntegrationTokensTable: React.FC<IntegrationTokensTableProps> = ({
|
||||
tokens,
|
||||
onOpenCreateDialog,
|
||||
onOpenEditDialog,
|
||||
onDeleteToken,
|
||||
}) => {
|
||||
const columns = useMemo<MRT_ColumnDef<Token>[]>(
|
||||
() => [
|
||||
{
|
||||
accessorKey: "description",
|
||||
header: "Описание",
|
||||
size: 200,
|
||||
},
|
||||
{
|
||||
accessorKey: "masked_token",
|
||||
header: "Токен",
|
||||
size: 250,
|
||||
Cell: ({ cell }) => (
|
||||
<Box sx={{ display: 'flex', alignItems: 'center', gap: '8px'}}>
|
||||
<Typography variant="body2">
|
||||
{cell.getValue<string>()}
|
||||
</Typography>
|
||||
</Box>
|
||||
)
|
||||
},
|
||||
{
|
||||
accessorKey: "create_dttm",
|
||||
header: "Дата создания",
|
||||
size: 150,
|
||||
Cell: ({ cell }) => new Date(cell.getValue<string>()).toLocaleString(),
|
||||
},
|
||||
{
|
||||
accessorKey: "use_dttm",
|
||||
header: "Дата последнего использования",
|
||||
size: 200,
|
||||
Cell: ({ cell }) => cell.getValue() ? new Date(cell.getValue<string>()).toLocaleString() : "Никогда",
|
||||
},
|
||||
],
|
||||
[],
|
||||
);
|
||||
|
||||
const table = useMaterialReactTable({
|
||||
columns,
|
||||
data: tokens,
|
||||
enableRowActions: true,
|
||||
positionActionsColumn: "last",
|
||||
renderRowActions: ({ row }) => (
|
||||
<Box sx={{ display: "flex", flexWrap: "nowrap", gap: "8px" }}>
|
||||
<IconButton
|
||||
color="primary"
|
||||
onClick={() => onOpenEditDialog(row.original)}
|
||||
>
|
||||
<EditIcon />
|
||||
</IconButton>
|
||||
<IconButton
|
||||
color="error"
|
||||
onClick={() => onDeleteToken(row.original.id)}
|
||||
>
|
||||
<DeleteIcon />
|
||||
</IconButton>
|
||||
</Box>
|
||||
),
|
||||
renderTopToolbarCustomActions: () => (
|
||||
<Button
|
||||
onClick={onOpenCreateDialog}
|
||||
variant="contained"
|
||||
>
|
||||
Создать новый токен
|
||||
</Button>
|
||||
),
|
||||
});
|
||||
|
||||
return <MaterialReactTable table={table} />;
|
||||
};
|
||||
|
||||
export default IntegrationTokensTable;
|
||||
@@ -2,6 +2,7 @@
|
||||
import MetricCard from "./MetricCard";
|
||||
import styles from "../styles/dashboard.module.css";
|
||||
import React, { useEffect, useState } from "react";
|
||||
import Cookies from 'js-cookie';
|
||||
|
||||
function formatCurrency(amount: number) {
|
||||
return amount.toLocaleString("ru-RU", {
|
||||
@@ -25,7 +26,19 @@ export default function MetricCards() {
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
|
||||
useEffect(() => {
|
||||
fetch("/api/dashboard/cards")
|
||||
const token = Cookies.get("access_token");
|
||||
if (!token) {
|
||||
console.warn("Токен авторизации не найден.");
|
||||
setError("Токен авторизации не найден.");
|
||||
setLoading(false);
|
||||
return;
|
||||
}
|
||||
|
||||
fetch("/api/dashboard/cards", {
|
||||
headers: {
|
||||
'Authorization': `Bearer ${token}`
|
||||
}
|
||||
})
|
||||
.then((res) => {
|
||||
if (!res.ok) throw new Error("Ошибка загрузки данных");
|
||||
return res.json();
|
||||
|
||||
@@ -5,6 +5,8 @@ import styles from "../styles/navigation.module.css";
|
||||
import Cookies from "js-cookie";
|
||||
import { useEffect, useState } from "react";
|
||||
import { useUser } from "./UserContext";
|
||||
import TabsNav from "./TabsNav";
|
||||
import { useRouter } from "next/navigation";
|
||||
|
||||
interface NavItem {
|
||||
id: string;
|
||||
@@ -16,12 +18,14 @@ const navItems: NavItem[] = [
|
||||
{ id: "home", label: "Дашборд", href: "/" },
|
||||
{ id: "stat", label: "Статистика", href: "/stat" },
|
||||
{ id: "billing", label: "Финансы", href: "/billing" },
|
||||
{ id: "category", label: "Категории товаров", href: "/category" },
|
||||
];
|
||||
|
||||
const Navigation: React.FC = () => {
|
||||
const pathname = usePathname();
|
||||
const [login, setLogin] = useState<string>("");
|
||||
const { firstName, surname } = useUser();
|
||||
const router = useRouter();
|
||||
|
||||
useEffect(() => {
|
||||
if (typeof document !== "undefined") {
|
||||
@@ -30,25 +34,21 @@ const Navigation: React.FC = () => {
|
||||
}
|
||||
}, []);
|
||||
|
||||
const handleNavigationChange = (tabId: string) => {
|
||||
if (tabId === "home") {
|
||||
router.push("/");
|
||||
} else if (tabId === "stat") {
|
||||
router.push("/stat");
|
||||
} else if (tabId === "billing") {
|
||||
router.push("/billing");
|
||||
}
|
||||
};
|
||||
|
||||
if (pathname === "/auth") return null;
|
||||
return (
|
||||
<nav className={styles.nav}>
|
||||
<div className={styles.logo}>RE:Premium Partner</div>
|
||||
<div className={styles.links}>
|
||||
{navItems.map((item) => (
|
||||
<Link
|
||||
key={item.id}
|
||||
href={item.href}
|
||||
className={
|
||||
pathname === item.href
|
||||
? styles.active
|
||||
: styles.link
|
||||
}
|
||||
>
|
||||
{item.label}
|
||||
</Link>
|
||||
))}
|
||||
</div>
|
||||
<TabsNav activeTab={pathname} setActiveTab={handleNavigationChange} tabs={navItems} />
|
||||
<div className={styles.profile}>
|
||||
<Link href="/account" style={{ display: 'flex', alignItems: 'center', gap: 12, textDecoration: 'none' }}>
|
||||
<div className={styles.avatar}>
|
||||
|
||||
@@ -4,6 +4,7 @@ import styles from "../styles/billing.module.css";
|
||||
import { Box, Button } from '@mui/material';
|
||||
import FileDownloadIcon from '@mui/icons-material/FileDownload';
|
||||
import { mkConfig, generateCsv, download } from 'export-to-csv';
|
||||
import Cookies from 'js-cookie';
|
||||
|
||||
|
||||
function formatCurrency(amount: number) {
|
||||
@@ -20,20 +21,56 @@ const statusColor: Record<string, string> = {
|
||||
'process': '#2196f3',
|
||||
'error': '#f44336',
|
||||
'reject': '#800080',
|
||||
'new': '#E30B5C',
|
||||
};
|
||||
|
||||
export default function PayoutsTransactionsTable({ filters, reloadKey }: { filters: { dateStart: string, dateEnd: string }, reloadKey: number }) {
|
||||
const [data, setData] = useState<any[]>([]);
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
|
||||
useEffect(() => {
|
||||
const params = new URLSearchParams();
|
||||
if (filters.dateStart) params.append('date_start', filters.dateStart);
|
||||
if (filters.dateEnd) params.append('date_end', filters.dateEnd);
|
||||
fetch(`/api/billing/payouts/transactions?${params.toString()}`)
|
||||
.then(res => res.json())
|
||||
.then(setData)
|
||||
.catch(() => setData([]));
|
||||
|
||||
const token = Cookies.get("access_token");
|
||||
if (!token) {
|
||||
console.warn("Токен авторизации не найден.");
|
||||
setError("Токен авторизации не найден.");
|
||||
setLoading(false);
|
||||
setData([]);
|
||||
return;
|
||||
}
|
||||
|
||||
setLoading(true);
|
||||
setError(null);
|
||||
|
||||
fetch(`/api/billing/payouts/transactions?${params.toString()}`, {
|
||||
headers: {
|
||||
'Authorization': `Bearer ${token}`
|
||||
}
|
||||
})
|
||||
.then(res => {
|
||||
if (!res.ok) {
|
||||
throw new Error(`Ошибка загрузки данных: ${res.status} ${res.statusText}`);
|
||||
}
|
||||
return res.json();
|
||||
})
|
||||
.then(apiData => {
|
||||
setData(apiData.items);
|
||||
setLoading(false);
|
||||
})
|
||||
.catch(err => {
|
||||
setError(err.message);
|
||||
setLoading(false);
|
||||
setData([]);
|
||||
});
|
||||
}, [filters.dateStart, filters.dateEnd, reloadKey]);
|
||||
|
||||
useEffect(() => {
|
||||
}, [data]);
|
||||
|
||||
const columns = useMemo<MRT_ColumnDef<any>[]>(
|
||||
() => [
|
||||
{ accessorKey: 'id', header: 'ID' },
|
||||
@@ -81,6 +118,10 @@ export default function PayoutsTransactionsTable({ filters, reloadKey }: { filte
|
||||
muiTableBodyCellProps: { sx: { fontSize: 14 } },
|
||||
muiTableHeadCellProps: { sx: { fontWeight: 700 } },
|
||||
initialState: { pagination: { pageSize: 10, pageIndex: 0 } },
|
||||
state: { isLoading: loading, showAlertBanner: error !== null, showProgressBars: loading },
|
||||
renderEmptyRowsFallback: () => (
|
||||
<div>{error ? `Ошибка: ${error}` : (loading ? 'Загрузка данных...' : 'Данные не найдены.')}</div>
|
||||
)
|
||||
});
|
||||
|
||||
const handleExportRows = (rows: MRT_Row<any>[]) => {
|
||||
|
||||
@@ -4,6 +4,7 @@ import styles from "../styles/stat.module.css";
|
||||
import { Box, Button } from '@mui/material';
|
||||
import FileDownloadIcon from '@mui/icons-material/FileDownload';
|
||||
import { mkConfig, generateCsv, download } from 'export-to-csv';
|
||||
import Cookies from 'js-cookie';
|
||||
|
||||
function formatCurrency(amount: number) {
|
||||
return amount?.toLocaleString("ru-RU", {
|
||||
@@ -20,15 +21,28 @@ export default function ReferralsTable({ filters, reloadKey }: { filters: { date
|
||||
const params = new URLSearchParams();
|
||||
if (filters.dateStart) params.append('date_start', filters.dateStart);
|
||||
if (filters.dateEnd) params.append('date_end', filters.dateEnd);
|
||||
fetch(`/api/stat/referrals?${params.toString()}`)
|
||||
|
||||
const token = Cookies.get("access_token");
|
||||
if (!token) {
|
||||
console.warn("Токен авторизации не найден.");
|
||||
setData([]); // Очистить данные, если токен отсутствует
|
||||
return;
|
||||
}
|
||||
|
||||
fetch(`/api/stat/referrals?${params.toString()}`, {
|
||||
headers: {
|
||||
'Authorization': `Bearer ${token}`
|
||||
}
|
||||
})
|
||||
.then(res => res.json())
|
||||
.then(setData)
|
||||
.then(apiData => setData(apiData.items))
|
||||
.catch(() => setData([]));
|
||||
}, [filters.dateStart, filters.dateEnd, reloadKey]);
|
||||
|
||||
const columns = useMemo<MRT_ColumnDef<any>[]>(
|
||||
() => [
|
||||
{ accessorKey: 'ref', header: 'Ref' },
|
||||
{ accessorKey: 'promocode', header: 'Промокод' },
|
||||
{ accessorKey: 'agent', header: 'Агент' },
|
||||
{ accessorKey: 'description', header: 'Описание' },
|
||||
{ accessorKey: 'salesCount', header: 'Кол-во продаж' },
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
"use client";
|
||||
import { ResponsiveContainer, LineChart, Line, XAxis, YAxis, CartesianGrid, Tooltip, Label } from "recharts";
|
||||
import { useEffect, useState } from "react";
|
||||
import Cookies from 'js-cookie';
|
||||
|
||||
const formatCurrency = (amount: number) => {
|
||||
return amount.toLocaleString("ru-RU", {
|
||||
@@ -22,13 +23,25 @@ const RevenueChart: React.FC = () => {
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
|
||||
useEffect(() => {
|
||||
fetch("/api/dashboard/chart/total")
|
||||
const token = Cookies.get("access_token");
|
||||
if (!token) {
|
||||
console.warn("Токен авторизации не найден.");
|
||||
setError("Токен авторизации не найден.");
|
||||
setLoading(false);
|
||||
return;
|
||||
}
|
||||
|
||||
fetch("/api/dashboard/chart/total", {
|
||||
headers: {
|
||||
'Authorization': `Bearer ${token}`
|
||||
}
|
||||
})
|
||||
.then((res) => {
|
||||
if (!res.ok) throw new Error("Ошибка загрузки данных");
|
||||
return res.json();
|
||||
})
|
||||
.then((data) => {
|
||||
setData(data);
|
||||
setData(data.items);
|
||||
setLoading(false);
|
||||
})
|
||||
.catch((err) => {
|
||||
|
||||
239
src/components/SaleCategoriesTable.tsx
Normal file
239
src/components/SaleCategoriesTable.tsx
Normal file
@@ -0,0 +1,239 @@
|
||||
"use client";
|
||||
import React, { useMemo, useEffect, useState } from "react";
|
||||
import {
|
||||
Box,
|
||||
Button,
|
||||
IconButton,
|
||||
Tooltip
|
||||
} from "@mui/material";
|
||||
import { MaterialReactTable, type MRT_ColumnDef, useMaterialReactTable, type MRT_Row, type MRT_TableOptions } from "material-react-table";
|
||||
import { Add as AddIcon, Edit as EditIcon, Save as SaveIcon, Cancel as CancelIcon } from "@mui/icons-material";
|
||||
import Cookies from "js-cookie";
|
||||
|
||||
interface SaleCategory {
|
||||
id: number;
|
||||
category: string;
|
||||
description?: string;
|
||||
perc: number;
|
||||
create_dttm: string;
|
||||
update_dttm: string;
|
||||
}
|
||||
|
||||
const SaleCategoriesTable: React.FC = () => {
|
||||
const [categories, setCategories] = useState<SaleCategory[]>([]);
|
||||
const [validationErrors, setValidationErrors] = useState<Record<string, string | undefined>>({});
|
||||
const [creationKey, setCreationKey] = useState(0);
|
||||
|
||||
const fetchCategories = async () => {
|
||||
try {
|
||||
const token = Cookies.get("access_token");
|
||||
if (!token) return;
|
||||
const res = await fetch("/api/category", {
|
||||
method: "GET",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
"Authorization": `Bearer ${token}`
|
||||
},
|
||||
});
|
||||
if (!res.ok) throw new Error(`HTTP error! status: ${res.status}`);
|
||||
const data: SaleCategory[] = await res.json();
|
||||
setCategories(data);
|
||||
} catch (error) {
|
||||
console.error("Failed to fetch categories:", error);
|
||||
}
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
fetchCategories();
|
||||
}, []);
|
||||
|
||||
// CREATE
|
||||
const handleCreateCategory: MRT_TableOptions<SaleCategory>["onCreatingRowSave"] = async ({ values, table }) => {
|
||||
const token = Cookies.get("access_token");
|
||||
if (!token) return;
|
||||
try {
|
||||
const res = await fetch("/api/category", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
"Authorization": `Bearer ${token}`
|
||||
},
|
||||
body: JSON.stringify({
|
||||
category: values.category,
|
||||
description: values.description,
|
||||
perc: Number(values.perc)
|
||||
})
|
||||
});
|
||||
if (!res.ok) {
|
||||
if (res.status === 400) {
|
||||
const data = await res.json();
|
||||
setValidationErrors((prev) => ({ ...prev, category: data.detail || "Категория с таким именем уже существует" }));
|
||||
return;
|
||||
}
|
||||
throw new Error("Ошибка создания категории");
|
||||
}
|
||||
await fetchCategories();
|
||||
table.setCreatingRow(null);
|
||||
} catch (e) {
|
||||
alert("Ошибка создания категории");
|
||||
}
|
||||
};
|
||||
|
||||
// UPDATE
|
||||
const handleSaveCategory: MRT_TableOptions<SaleCategory>["onEditingRowSave"] = async ({ values, table }) => {
|
||||
const token = Cookies.get("access_token");
|
||||
if (!token) return;
|
||||
try {
|
||||
const res = await fetch("/api/category", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
"Authorization": `Bearer ${token}`
|
||||
},
|
||||
body: JSON.stringify({
|
||||
id: Number(values.id),
|
||||
category: values.category,
|
||||
description: values.description,
|
||||
perc: Number(values.perc)
|
||||
})
|
||||
});
|
||||
if (!res.ok) {
|
||||
if (res.status === 400) {
|
||||
const data = await res.json();
|
||||
setValidationErrors((prev) => ({ ...prev, category: data.detail || "Категория с таким именем уже существует" }));
|
||||
return;
|
||||
}
|
||||
throw new Error("Ошибка обновления категории");
|
||||
}
|
||||
await fetchCategories();
|
||||
table.setEditingRow(null);
|
||||
} catch (e) {
|
||||
alert("Ошибка обновления категории");
|
||||
}
|
||||
};
|
||||
|
||||
// Валидация (минимальная)
|
||||
const validateCategory = (values: Partial<SaleCategory>) => {
|
||||
return {
|
||||
category: !values.category ? "Обязательное поле" : undefined,
|
||||
perc: values.perc === undefined || isNaN(Number(values.perc)) ? "Введите число" : undefined
|
||||
};
|
||||
};
|
||||
|
||||
const columns = useMemo<MRT_ColumnDef<SaleCategory>[]>(
|
||||
() => [
|
||||
{
|
||||
accessorKey: "id",
|
||||
header: "",
|
||||
size: 1,
|
||||
enableEditing: false,
|
||||
enableHiding: false,
|
||||
enableColumnActions: false,
|
||||
enableSorting: false,
|
||||
enableColumnFilter: false,
|
||||
Cell: () => null,
|
||||
Edit: () => null,
|
||||
muiTableBodyCellProps: { sx: { display: 'none' } },
|
||||
muiTableHeadCellProps: { sx: { display: 'none' } },
|
||||
},
|
||||
{
|
||||
accessorKey: "category",
|
||||
header: "Категория",
|
||||
size: 200,
|
||||
muiEditTextFieldProps: {
|
||||
required: true,
|
||||
error: !!validationErrors?.category,
|
||||
helperText: validationErrors?.category,
|
||||
onFocus: () => setValidationErrors((prev) => ({ ...prev, category: undefined }))
|
||||
}
|
||||
},
|
||||
{
|
||||
accessorKey: "description",
|
||||
header: "Описание",
|
||||
size: 250,
|
||||
muiEditTextFieldProps: {
|
||||
onFocus: () => undefined
|
||||
}
|
||||
},
|
||||
{
|
||||
accessorKey: "perc",
|
||||
header: "% начисления",
|
||||
size: 100,
|
||||
muiEditTextFieldProps: {
|
||||
required: true,
|
||||
type: "number",
|
||||
error: !!validationErrors?.perc,
|
||||
helperText: validationErrors?.perc,
|
||||
onFocus: () => setValidationErrors((prev) => ({ ...prev, perc: undefined }))
|
||||
}
|
||||
},
|
||||
{
|
||||
accessorKey: "create_dttm",
|
||||
header: "Создана",
|
||||
size: 160,
|
||||
enableEditing: false,
|
||||
Cell: ({ cell }) => new Date(cell.getValue<string>()).toLocaleString(),
|
||||
},
|
||||
{
|
||||
accessorKey: "update_dttm",
|
||||
header: "Обновлена",
|
||||
size: 160,
|
||||
enableEditing: false,
|
||||
Cell: ({ cell }) => new Date(cell.getValue<string>()).toLocaleString(),
|
||||
},
|
||||
],
|
||||
[validationErrors],
|
||||
);
|
||||
|
||||
const table = useMaterialReactTable({
|
||||
columns,
|
||||
data: categories,
|
||||
createDisplayMode: "row",
|
||||
editDisplayMode: "row",
|
||||
enableEditing: true,
|
||||
enableRowActions: false,
|
||||
getRowId: (row) => String(row.id),
|
||||
onCreatingRowSave: async (props) => {
|
||||
const errors = validateCategory(props.values);
|
||||
setValidationErrors(errors);
|
||||
if (Object.values(errors).some(Boolean)) return;
|
||||
await handleCreateCategory(props);
|
||||
},
|
||||
onEditingRowSave: async (props) => {
|
||||
const errors = validateCategory(props.values);
|
||||
setValidationErrors(errors);
|
||||
if (Object.values(errors).some(Boolean)) return;
|
||||
props.values.id = Number(props.values.id);
|
||||
await handleSaveCategory(props);
|
||||
},
|
||||
onCreatingRowCancel: () => setValidationErrors({}),
|
||||
onEditingRowCancel: () => setValidationErrors({}),
|
||||
renderTopToolbarCustomActions: ({ table }) => (
|
||||
<Button
|
||||
onClick={() => {
|
||||
setValidationErrors({});
|
||||
table.setEditingRow(null);
|
||||
setCreationKey((k) => k + 1);
|
||||
table.setCreatingRow(true);
|
||||
}}
|
||||
variant="contained"
|
||||
startIcon={<AddIcon />}
|
||||
>
|
||||
Создать категорию
|
||||
</Button>
|
||||
),
|
||||
muiTableBodyCellProps: { sx: { fontSize: 14 } },
|
||||
muiTableHeadCellProps: { sx: { fontWeight: 700 } },
|
||||
initialState: {
|
||||
pagination: { pageSize: 10, pageIndex: 0 },
|
||||
},
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
setValidationErrors({});
|
||||
}, [table.getState().editingRow]);
|
||||
|
||||
return <MaterialReactTable key={creationKey} table={table} />;
|
||||
};
|
||||
|
||||
export default SaleCategoriesTable;
|
||||
@@ -4,6 +4,7 @@ import styles from "../styles/stat.module.css";
|
||||
import { Box, Button } from '@mui/material';
|
||||
import FileDownloadIcon from '@mui/icons-material/FileDownload';
|
||||
import { mkConfig, generateCsv, download } from 'export-to-csv';
|
||||
import Cookies from 'js-cookie';
|
||||
|
||||
function formatCurrency(amount: number) {
|
||||
return amount?.toLocaleString("ru-RU", {
|
||||
@@ -20,9 +21,21 @@ export default function SalesTable({ filters, reloadKey }: { filters: { dateStar
|
||||
const params = new URLSearchParams();
|
||||
if (filters.dateStart) params.append('date_start', filters.dateStart);
|
||||
if (filters.dateEnd) params.append('date_end', filters.dateEnd);
|
||||
fetch(`/api/stat/sales?${params.toString()}`)
|
||||
|
||||
const token = Cookies.get("access_token");
|
||||
if (!token) {
|
||||
console.warn("Токен авторизации не найден.");
|
||||
setData([]); // Очистить данные, если токен отсутствует
|
||||
return;
|
||||
}
|
||||
|
||||
fetch(`/api/stat/sales?${params.toString()}`, {
|
||||
headers: {
|
||||
'Authorization': `Bearer ${token}`
|
||||
}
|
||||
})
|
||||
.then(res => res.json())
|
||||
.then(setData)
|
||||
.then(apiData => setData(apiData.items))
|
||||
.catch(() => setData([]));
|
||||
}, [filters.dateStart, filters.dateEnd, reloadKey]);
|
||||
|
||||
|
||||
71
src/components/TabsNav.tsx
Normal file
71
src/components/TabsNav.tsx
Normal file
@@ -0,0 +1,71 @@
|
||||
import React from "react";
|
||||
import Link from "next/link";
|
||||
import defaultTabsStyles from "../styles/tabs.module.css";
|
||||
|
||||
interface TabItem {
|
||||
id: string;
|
||||
label: string;
|
||||
href?: string;
|
||||
icon?: React.ReactNode;
|
||||
}
|
||||
|
||||
interface TabsNavProps {
|
||||
activeTab: string;
|
||||
setActiveTab: (tabId: string) => void;
|
||||
tabs: TabItem[];
|
||||
tabStyles?: {
|
||||
nav: string;
|
||||
button: string;
|
||||
buttonActive: string;
|
||||
};
|
||||
}
|
||||
|
||||
const TabsNav: React.FC<TabsNavProps> = ({
|
||||
activeTab,
|
||||
setActiveTab,
|
||||
tabs,
|
||||
tabStyles,
|
||||
}) => {
|
||||
const currentTabStyles = tabStyles || {
|
||||
nav: defaultTabsStyles.tabsNav,
|
||||
button: defaultTabsStyles.tabButton,
|
||||
buttonActive: defaultTabsStyles.tabButtonActive,
|
||||
};
|
||||
|
||||
return (
|
||||
<nav className={currentTabStyles.nav}>
|
||||
{tabs.map((tab) => (
|
||||
tab.href ? (
|
||||
<Link
|
||||
key={tab.id}
|
||||
href={tab.href}
|
||||
onClick={() => setActiveTab(tab.id)}
|
||||
className={
|
||||
activeTab === tab.href
|
||||
? `${currentTabStyles.button} ${currentTabStyles.buttonActive}`
|
||||
: currentTabStyles.button
|
||||
}
|
||||
>
|
||||
{tab.icon}
|
||||
{tab.label}
|
||||
</Link>
|
||||
) : (
|
||||
<button
|
||||
key={tab.id}
|
||||
onClick={() => setActiveTab(tab.id)}
|
||||
className={
|
||||
activeTab === tab.id
|
||||
? `${currentTabStyles.button} ${currentTabStyles.buttonActive}`
|
||||
: currentTabStyles.button
|
||||
}
|
||||
>
|
||||
{tab.icon}
|
||||
{tab.label}
|
||||
</button>
|
||||
)
|
||||
))}
|
||||
</nav>
|
||||
);
|
||||
};
|
||||
|
||||
export default TabsNav;
|
||||
@@ -258,6 +258,7 @@
|
||||
font-weight: 500;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 8px;
|
||||
cursor: pointer;
|
||||
margin-top: 8px;
|
||||
@@ -273,6 +274,7 @@
|
||||
padding: 0;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
color: #6b7280;
|
||||
}
|
||||
|
||||
/* --- Стили для вкладки уведомлений --- */
|
||||
@@ -362,9 +364,11 @@
|
||||
left: 22px;
|
||||
}
|
||||
|
||||
/* --- Стили для табов и навигации из page.tsx --- */
|
||||
|
||||
.accountTabsNav {
|
||||
|
||||
/* Стили для табов и навигации из page.tsx */
|
||||
|
||||
/* .accountTabsNav {
|
||||
display: flex;
|
||||
gap: 32px;
|
||||
border-bottom: 1px solid #e5e7eb;
|
||||
@@ -389,51 +393,18 @@
|
||||
border-bottom: 2px solid #2563eb;
|
||||
color: #2563eb;
|
||||
font-weight: 600;
|
||||
}
|
||||
} */
|
||||
|
||||
/* Стили для кнопок подтверждения */
|
||||
.primaryButton {
|
||||
background-color: #2563eb; /* Синий */
|
||||
color: #ffffff;
|
||||
background: #2563eb;
|
||||
color: #fff;
|
||||
border: none;
|
||||
border-radius: 6px;
|
||||
padding: 8px 16px;
|
||||
padding: 8px 20px;
|
||||
font-weight: 500;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
cursor: pointer;
|
||||
transition: background-color 0.2s ease;
|
||||
}
|
||||
|
||||
.primaryButton:hover {
|
||||
background-color: #1d4ed8;
|
||||
}
|
||||
|
||||
.secondaryButton {
|
||||
background-color: #f3f4f6; /* Серый */
|
||||
color: #374151;
|
||||
border: 1px solid #d1d5db;
|
||||
border-radius: 6px;
|
||||
padding: 8px 16px;
|
||||
font-weight: 500;
|
||||
cursor: pointer;
|
||||
transition: background-color 0.2s ease;
|
||||
}
|
||||
|
||||
.secondaryButton:hover {
|
||||
background-color: #e5e7eb;
|
||||
}
|
||||
|
||||
.tertiaryButton {
|
||||
background: none;
|
||||
color: #6b7280; /* Темно-серый */
|
||||
border: none;
|
||||
padding: 8px 16px;
|
||||
font-weight: 500;
|
||||
cursor: pointer;
|
||||
transition: color 0.2s ease;
|
||||
}
|
||||
|
||||
.tertiaryButton:hover {
|
||||
color: #4b5563;
|
||||
}
|
||||
|
||||
/* ... можно добавить другие стили по необходимости ... */
|
||||
}
|
||||
19
src/styles/category.module.css
Normal file
19
src/styles/category.module.css
Normal file
@@ -0,0 +1,19 @@
|
||||
.categoryPage {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 32px;
|
||||
}
|
||||
.categoryTitle {
|
||||
font-size: 28px;
|
||||
font-weight: bold;
|
||||
color: #111827;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
@media (max-width: 600px) {
|
||||
.categoryPage {
|
||||
gap: 16px;
|
||||
}
|
||||
.categoryTitle {
|
||||
font-size: 16px;
|
||||
}
|
||||
}
|
||||
37
src/styles/dateinput.module.css
Normal file
37
src/styles/dateinput.module.css
Normal file
@@ -0,0 +1,37 @@
|
||||
.dateInputHiddenIcon {
|
||||
-webkit-appearance: none; /* Safari и Chrome */
|
||||
-moz-appearance: none; /* Firefox */
|
||||
appearance: none; /* Стандартное свойство */
|
||||
}
|
||||
|
||||
.dateInputHiddenIcon::-webkit-calendar-picker-indicator {
|
||||
display: none; /* Скрыть для WebKit-браузеров */
|
||||
}
|
||||
|
||||
.dateInputHiddenIcon::-moz-calendar-picker-indicator {
|
||||
display: none; /* Скрыть для Mozilla-браузеров */
|
||||
}
|
||||
|
||||
.dateInputHiddenIcon::-ms-calendar-picker-indicator {
|
||||
display: none; /* Скрыть для Internet Explorer/Edge */
|
||||
}
|
||||
|
||||
.dateInputBase {
|
||||
width: 100%;
|
||||
padding: 8px;
|
||||
border: 1px solid #e5e7eb;
|
||||
border-radius: 6px;
|
||||
margin-top: 4px;
|
||||
box-sizing: border-box;
|
||||
padding-right: 40px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.dateIcon {
|
||||
position: absolute;
|
||||
right: 8px;
|
||||
top: 50%;
|
||||
transform: translateY(-50%);
|
||||
cursor: pointer;
|
||||
color: #6b7280;
|
||||
}
|
||||
@@ -13,7 +13,7 @@
|
||||
font-weight: bold;
|
||||
color: #2563eb;
|
||||
}
|
||||
.links {
|
||||
/* .links {
|
||||
display: flex;
|
||||
gap: 32px;
|
||||
}
|
||||
@@ -34,7 +34,7 @@
|
||||
color: #2563eb;
|
||||
border-bottom: 2px solid #2563eb;
|
||||
font-weight: 600;
|
||||
}
|
||||
} */
|
||||
.profile {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
@@ -27,11 +27,14 @@
|
||||
.exportBtn:hover {
|
||||
background: #1d4ed8;
|
||||
}
|
||||
.tabs {
|
||||
/* Tabs */
|
||||
/* .tabs {
|
||||
display: flex;
|
||||
gap: 32px;
|
||||
border-bottom: 1.5px solid #e5e7eb;
|
||||
margin-bottom: 24px;
|
||||
}
|
||||
|
||||
.tab {
|
||||
background: none;
|
||||
border: none;
|
||||
@@ -43,17 +46,19 @@
|
||||
cursor: pointer;
|
||||
transition: color 0.2s, border 0.2s;
|
||||
}
|
||||
|
||||
.tab:hover {
|
||||
color: #2563eb;
|
||||
border-bottom: 2px solid #dbeafe;
|
||||
}
|
||||
|
||||
.activeTab {
|
||||
color: #2563eb;
|
||||
border: none;
|
||||
border-bottom: 2px solid #2563eb;
|
||||
font-weight: 600;
|
||||
background: none;
|
||||
}
|
||||
} */
|
||||
.filters {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(1, 1fr);
|
||||
|
||||
31
src/styles/tabs.module.css
Normal file
31
src/styles/tabs.module.css
Normal file
@@ -0,0 +1,31 @@
|
||||
.tabsNav {
|
||||
display: flex;
|
||||
gap: 32px;
|
||||
border-bottom: 1px solid #e5e7eb;
|
||||
margin-bottom: 24px;
|
||||
}
|
||||
|
||||
.tabButton {
|
||||
background: none;
|
||||
border: none;
|
||||
border-bottom: 2px solid transparent;
|
||||
color: #6b7280;
|
||||
font-weight: 500;
|
||||
font-size: 16px;
|
||||
padding: 8px 0;
|
||||
cursor: pointer;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.tabButton:hover {
|
||||
color: #2563eb;
|
||||
border-bottom: 2px solid #dbeafe;
|
||||
}
|
||||
|
||||
.tabButtonActive {
|
||||
border-bottom: 2px solid #2563eb;
|
||||
color: #2563eb;
|
||||
font-weight: 600;
|
||||
}
|
||||
9
src/types/tokens.ts
Normal file
9
src/types/tokens.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
export interface Token {
|
||||
id: number;
|
||||
description: string;
|
||||
masked_token: string;
|
||||
rawToken?: string;
|
||||
create_dttm: string;
|
||||
use_dttm?: string;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user