diff --git a/src/components/Sidebar.jsx b/src/components/Sidebar.jsx index d3ebac9..54b56e9 100644 --- a/src/components/Sidebar.jsx +++ b/src/components/Sidebar.jsx @@ -22,7 +22,7 @@ const Sidebar = ({ isOpen, onToggle }) => { { name: 'Currency', href: '/currency', icon: DollarSign }, { name: 'Location', href: '/location', icon: MapPin }, { name: 'Issuer', href: '/issuer', icon: Building2 }, - // { name: 'Settings', href: '/settings', icon: Settings }, + { name: 'Settings', href: '/settings', icon: Settings }, ]; return ( diff --git a/src/pages/Currency.jsx b/src/pages/Currency.jsx index 4becde9..48e086b 100644 --- a/src/pages/Currency.jsx +++ b/src/pages/Currency.jsx @@ -1,7 +1,7 @@ import React, { useEffect, useMemo, useState, useCallback } from 'react'; import DataTable from '../components/DataTable'; import { currencyAPI } from '../services/api'; -import { Plus, Search, Power, Wrench, Settings, DollarSign, Shield } from 'lucide-react'; +import { Plus, Search, Power, Wrench, Settings, DollarSign, Shield, AlertTriangle, CheckCircle2 } from 'lucide-react'; import { ToastContainer, toast } from 'react-toastify'; import 'react-toastify/dist/ReactToastify.css'; import { getErrorMessage, getSuccessMessage } from '../utils/errorHandler'; @@ -49,12 +49,10 @@ const Currency = () => { voucherLimits: { min: null, max: null }, }); const [feesForm, setFeesForm] = useState({ - depositFee: { percent: 0, fixed: 0, minAmount: null, maxAmount: null }, - cashOutFee: { percent: 0, fixed: 0, minAmount: null, maxAmount: null }, - transferFee: { percent: 0, fixed: 0, minAmount: null, maxAmount: null }, - exchangeFee: { percent: 0, fixed: 0, minAmount: null, maxAmount: null }, - generateVoucherFee: { percent: 0, fixed: 0, minAmount: null, maxAmount: null }, - expireVoucherSystemFee: { percent: 0, fixed: 0, minAmount: null, maxAmount: null }, + depositLimits: { min: null, max: null }, + cashOutLimits: { min: null, max: null }, + transferLimits: { min: null, max: null }, + voucherLimits: { min: null, max: null }, }); // دریافت ارزها @@ -96,7 +94,7 @@ const Currency = () => { } // بررسی وجود ارز در لیست (برای جلوگیری از درخواست غیرضروری) - const exists = currencies.some(c => c.currencyCode?.code?.toUpperCase() === code); + const exists = currencies.some(c => c.currencyCode?.toUpperCase() === code); if (exists) { toast.error(`Currency ${code} already exists`); return; @@ -127,8 +125,12 @@ const Currency = () => { // --- فعال/غیرفعال کردن Maintenance --- const onEnableMaintenance = async (currencyCode, message = '') => { + if (!message || message.trim() === '') { + toast.error('Maintenance message is required'); + return; + } try { - const result = await currencyAPI.enableMaintenance(currencyCode, message || null); + const result = await currencyAPI.enableMaintenance(currencyCode, message); await fetchCurrencies(); setMaintenanceModal(null); setMaintenanceMessage(''); @@ -177,11 +179,25 @@ const Currency = () => { // --- بهروزرسانی Fees --- const onUpdateFees = async (currencyCode, fees) => { try { - const result = await currencyAPI.updateFees(currencyCode, fees); + // API PUT expects: depositFee, cashOutFee, transferFee, exchangeFee, generateVoucherByAgentFee, generateVoucherByUserFee, expireVoucherSystemFee + // But GET returns: depositLimits, cashOutLimits, transferLimits, voucherLimits + // Map our structure to API expected structure + const payload = { + depositFee: fees.depositLimits || { min: null, max: null }, + cashOutFee: fees.cashOutLimits || { min: null, max: null }, + transferFee: fees.transferLimits || { min: null, max: null }, + exchangeFee: { min: null, max: null }, // Required by API + generateVoucherByAgentFee: fees.voucherLimits || { min: null, max: null }, // Map voucherLimits to generateVoucherByAgentFee + generateVoucherByUserFee: { min: null, max: null }, // Required by API + expireVoucherSystemFee: { min: null, max: null }, // Required by API + }; + console.log('🔵 Currency - onUpdateFees payload:', payload); + const result = await currencyAPI.updateFees(currencyCode, payload); await fetchCurrencies(); setFeesModal(null); toast.success(getSuccessMessage(result) || 'Fees updated successfully'); } catch (err) { + console.error('🔴 Currency - onUpdateFees error:', err); toast.error(getErrorMessage(err)); } }; @@ -190,19 +206,11 @@ const Currency = () => { const columns = useMemo(() => [ { key: 'currencyCode', - header: 'Currency', + header: 'Currency Code', render: (val) => ( -