Skip to content

Commit

Permalink
Funcionalidade de ata de reunião alterada
Browse files Browse the repository at this point in the history
  • Loading branch information
julia-fortunato committed Jun 13, 2024
1 parent 6ca4a51 commit f7fedfa
Showing 1 changed file with 58 additions and 36 deletions.
94 changes: 58 additions & 36 deletions view/src/pages/Meeting/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ function Meeting() {
const [meetings, setMeetings] = useState([]);
const [showPopup, setShowPopup] = useState(false);
const [currentMeetingIndex, setCurrentMeetingIndex] = useState(null);
const [link, setLink] = useState('');
const [descricao, setDescricao] = useState('');
const [links, setLinks] = useState([]);

const handleAddMeeting = () => {
const newMeeting = {
Expand All @@ -18,6 +21,7 @@ function Meeting() {
]
};
setMeetings([...meetings, newMeeting]);
setLinks([...links, []]); // Adiciona uma nova lista vazia de links para a nova reunião
};

const handleImageClick = (index) => {
Expand All @@ -30,25 +34,6 @@ function Meeting() {
setCurrentMeetingIndex(null);
};

const handleFileChange = (e) => {
const updatedMeetings = [...meetings];
updatedMeetings[currentMeetingIndex].file = e.target.files[0];
updatedMeetings[currentMeetingIndex].fileName = e.target.files[0].name;
setMeetings(updatedMeetings);
};

const handleFileSubmit = (e) => {
e.preventDefault();
const updatedMeetings = [...meetings];
const currentMeeting = updatedMeetings[currentMeetingIndex];
if (currentMeeting.file && currentMeeting.fileName.trim() !== '') {
const dateAdded = new Date().toLocaleDateString();
currentMeeting.files.push({ file: currentMeeting.file, fileName: currentMeeting.fileName, dateAdded });
}
setShowPopup(false);
setMeetings(updatedMeetings);
};

const handleRemoveFile = (meetingIndex, fileIndex) => {
const updatedMeetings = [...meetings];
updatedMeetings[meetingIndex].files.splice(fileIndex, 1);
Expand All @@ -62,6 +47,32 @@ function Meeting() {
setMeetings(updatedMeetings);
};

const handleLinkChange = (e) => {
setLink(e.target.value);
};

const handleDescricaoChange = (e) => {
setDescricao(e.target.value);
};

const handleSubmit = (e) => {
e.preventDefault();
if (link.trim() !== '' && descricao.trim() !== '') {
const updatedLinks = [...links];
updatedLinks[currentMeetingIndex] = [...updatedLinks[currentMeetingIndex], { descricao, link }];
setLinks(updatedLinks);
}
setShowPopup(false);
setLink('');
setDescricao('');
};

const handleRemoveLink = (meetingIndex, linkIndex) => {
const updatedLinks = [...links];
updatedLinks[meetingIndex].splice(linkIndex, 1);
setLinks(updatedLinks);
};

return (
<>
<SideBar />
Expand Down Expand Up @@ -89,6 +100,21 @@ function Meeting() {
</div>
))}
</div>
<div className="displayed-links">
{links[meetingIndex] && links[meetingIndex].map((link, index) => (
<div key={index}>
<p>
<img
src="trash.svg"
alt="img-trash"
className='trash'
onClick={() => handleRemoveLink(meetingIndex, index)}
/>
<a href={link.link}>{link.descricao}</a>
</p>
</div>
))}
</div>
<table className="presence-table">
<thead>
<tr>
Expand Down Expand Up @@ -116,30 +142,26 @@ function Meeting() {
</div>
))}
{showPopup && (
<div className="popup">
<div className="popup" >
<div className="popup-content">
<span className="close" onClick={handleClosePopup}>&times;</span>
<form onSubmit={handleFileSubmit}>
<span className="close" onClick={handleClosePopup}>
&times; </span>
<form onSubmit={handleSubmit}>
<label className='caixa'>
Nome do Arquivo:
<input
className='caixa'
Insira o link:
<input className='caixa'
type="text"
value={meetings[currentMeetingIndex]?.fileName || ''}
onChange={(e) => {
const updatedMeetings = [...meetings];
updatedMeetings[currentMeetingIndex].fileName = e.target.value;
setMeetings(updatedMeetings);
}}
value={link}
onChange={handleLinkChange}
required
/>
</label>
<label className='caixa'>
Selecionar Arquivo:
<input
className='caixa'
type="file"
onChange={handleFileChange}
Descrição:
<input className='caixa'
type="text"
value={descricao}
onChange={handleDescricaoChange}
required
/>
</label>
Expand Down

0 comments on commit f7fedfa

Please sign in to comment.