import React, { useEffect, useState } from 'react'; import { HiBars3BottomLeft } from "react-icons/hi2"; import { FaCheck } from "react-icons/fa6"; import '../App.css'; import WithdrawalForm from './Cekimform'; import axios from 'axios'; const BASE_URL = "http://localhost:8000"; const WithdrawalContent = () => { const [showFilterMenu, setShowFilterMenu] = useState(true); const [showModal, setShowModal] = useState(false); const [bankAccounts, setBankAccounts] = useState([]); const [selectedAccount, setSelectedAccount] = useState(''); const [loading, setLoading] = useState(false); const [error, setError] = useState(null); const [minAmount, setMinAmount] = useState(''); const [maxAmount, setMaxAmount] = useState(''); const [startDate, setStartDate] = useState(''); const [endDate, setEndDate] = useState(''); useEffect(() => { fetchBankAccounts(); }, []); const fetchBankAccounts = async () => { const token = localStorage.getItem('token'); setLoading(true); try { const response = await axios.get(`${BASE_URL}/bank/accounts`, { headers: { 'Authorization': `Bearer ${token}` } }); // Filter accounts that allow withdrawals (isPull is true) const withdrawalAccounts = response.data.data.filter(account => account.isPull); setBankAccounts(withdrawalAccounts); } catch (err) { setError('Banka hesapları yüklenirken bir hata oluştu'); console.error('Error fetching bank accounts:', err); } finally { setLoading(false); } }; const toggleFilterMenu = () => { setShowFilterMenu(prevState => !prevState); }; return (
setStartDate(e.target.value)} className="p-1 rounded-md text-xs border border-gray-300 focus:outline-none focus:ring-2 focus:ring-emerald-500" /> ve setEndDate(e.target.value)} className="p-1 rounded-md text-xs border border-gray-300 focus:outline-none focus:ring-2 focus:ring-emerald-500" />
{showModal && ( setShowModal(false)} /> )}
{!showFilterMenu && (
Banka Hesapları
{error && ( {error} )}

Tutar Aralığı

setMinAmount(e.target.value)} className="rounded-sm text-center w-28 p-1 text-xs border border-gray-300 focus:outline-none focus:ring-2 focus:ring-emerald-500" /> ve setMaxAmount(e.target.value)} className="rounded-sm w-28 text-center p-1 text-xs border border-gray-300 focus:outline-none focus:ring-2 focus:ring-emerald-500" />
)}
); }; export default WithdrawalContent;