import React, { useEffect, useState } from 'react'; import { HiBars3BottomLeft } from "react-icons/hi2"; import { FaCheck } from "react-icons/fa6"; import '../App.css'; import InvestmentForm from './YatırımForm'; import axios from 'axios'; const BASE_URL = "http://localhost:8000"; const YatırımContent = () => { const [showFilterMenu, setShowFilterMenu] = useState(true); const [showModal, setShowModal] = useState(false); const [bankAccounts, setBankAccounts] = useState([]); const [selectedAccounts, setSelectedAccounts] = useState([]); const [loading, setLoading] = useState(false); const [error, setError] = useState(null); const [minAmount, setMinAmount] = useState(''); const [maxAmount, setMaxAmount] = 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}` } }); setBankAccounts(response.data.data); } 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); }; const handleSelectAllAccounts = (e) => { if (e.target.checked) { setSelectedAccounts(bankAccounts.map(account => account.accountId)); } else { setSelectedAccounts([]); } }; const handleAccountSelection = (accountId) => { setSelectedAccounts(prev => { if (prev.includes(accountId)) { return prev.filter(id => id !== accountId); } else { return [...prev, accountId]; } }); }; return (
ve
{showModal && ( setShowModal(false)} /> )}
{!showFilterMenu && (
Banka Hesapları
Hepsini Seç
{loading ? (
Yükleniyor...
) : error ? (
{error}
) : ( bankAccounts.map(account => ( )) )}

Tutar Aralığı

setMinAmount(e.target.value)} className="rounded-sm text-center w-28 p-1 text-xs" /> ve setMaxAmount(e.target.value)} className="rounded-sm w-28 text-center p-1 text-xs" />
)}
); }; export default YatırımContent;