import { useEffect, useState } from 'react';
import Upload from './Upload';
import Chat from './Chat';
const storedToken = localStorage.getItem('token');
const Opportunities = () => {
const [token, setToken] = useState(storedToken);
const [isPopupOpen, setIsPopupOpen] = useState(false); //form popup
const [opportunities, setOpportunities] = useState([]);
useEffect(() => {
const storedToken = localStorage.getItem('token');
console.log('storedToken*******', storedToken)
fetch('/api/opportunities', {
method: 'GET',
headers: {
'Authorization': `Bearer ${storedToken}`,
'Content-Type': 'application/json'
}
}).then(response => response.json())
.then(data => {
/*if (!data.success) {
handleLogout();
return
}*/
console.log('data*******', data, !data.records || data.records.length === 0)
if (!data.records || data.records.length === 0) {
setIsPopupOpen(true);
} else {
console.log('data.records*******', data.records)
setOpportunities(data.records);
}
setToken(storedToken);
})
console.log('storedToken', storedToken)
}, [])
const handleLogout = () => {
localStorage.removeItem('token');
location = '/'
};
return (
<>
No opportunities found. Please upload a file to get started.
{e} | )}
{opportunity[key]} | ))}