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'; import DateInput from './DateInput'; import InvestmentTable from './YatırımTable'; const BASE_URL = "http://localhost:8000/api"; const YatırımContent = () => { 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 [selectedDate, setSelectedDate] = useState(''); const [filterConfig, setFilterConfig] = useState({ accountId: '', minAmount: '', maxAmount: '', date: '', autoUpdate: true }); 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 handleAccountChange = (e) => { const accountId = e.target.value; setSelectedAccount(accountId); setFilterConfig(prev => ({ ...prev, accountId })); }; const handleMinAmountChange = (e) => { const value = e.target.value; setMinAmount(value); setFilterConfig(prev => ({ ...prev, minAmount: value })); }; const handleMaxAmountChange = (e) => { const value = e.target.value; setMaxAmount(value); setFilterConfig(prev => ({ ...prev, maxAmount: value })); }; const handleDateChange = (date) => { setSelectedDate(date); setFilterConfig(prev => ({ ...prev, date })); }; const toggleAutoUpdate = () => { setFilterConfig(prev => ({ ...prev, autoUpdate: !prev.autoUpdate })); }; const toggleFilterMenu = () => { setShowFilterMenu(prev => !prev); }; return (
{showModal && ( setShowModal(false)} /> )}
{!showFilterMenu && (
Banka Hesapları
{error && ( {error} )}

Tutar Aralığı

ve
)}
); }; export default YatırımContent;