Skip to content

Commit

Permalink
Add Copy Email Confirm (non working
Browse files Browse the repository at this point in the history
  • Loading branch information
Pulkith committed Jul 16, 2024
1 parent 530d061 commit 27b3cf4
Showing 1 changed file with 56 additions and 1 deletion.
57 changes: 56 additions & 1 deletion client/src/Communications/CommunicationsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ interface DonorInfo {
function CommunicationsPage() {
const [unackDonoModalOpen, setUnackDonoModalOpen] = React.useState(false);
const [editGroupModalOpen, setEditGroupModalOpen] = React.useState(false);
const [didSendModalOpen, setDidSendModalOpen] = React.useState(false);
const [unacknowledgedDonations, setUnacknowledgedDonations] = useState<any[]>(
[],
);
Expand Down Expand Up @@ -112,7 +113,6 @@ function CommunicationsPage() {

const handleUnackDonoModalOpen = async () => {
try {
console.log('opened');
const temp = donations.filter(
(donation: IDonation) => !donation.acknowledged,
);
Expand Down Expand Up @@ -155,6 +155,10 @@ function CommunicationsPage() {
setOpenPopup(false);
};

const handleDidSendModalClose = () => {
setDidSendModalOpen(false);
};

// Define a function to extract the correct ID
const extractId = (id: string | { $oid: string }) => {
return typeof id === 'string' ? id : id.$oid;
Expand Down Expand Up @@ -234,6 +238,11 @@ function CommunicationsPage() {
navigator.clipboard.writeText(emailAsPasteFormat).then(
function () {
console.log('Async: Copying to clipboard was successful!');
setTimeout(() => {
if (emailAsPasteFormat.length > 0) {
setDidSendModalOpen(true);
}
}, 0);
},
function (err) {
console.error('Async: Could not copy text: ', err);
Expand Down Expand Up @@ -290,6 +299,11 @@ function CommunicationsPage() {
setOpenPopup(true);
};

const handleEmailsSent = () => {
setDidSendModalOpen(false);
setRows([]);
};

return (
<div className="max-width-wrapper">
<Box paddingTop={2} paddingLeft={4} marginBottom={2}>
Expand Down Expand Up @@ -523,6 +537,47 @@ function CommunicationsPage() {
<Button onClick={handleUnackDonoModalClose}>Close</Button>
</Box>
</Modal>

<Modal
open={didSendModalOpen}
onClose={handleDidSendModalClose}
aria-labelledby="Email Unacknowledged Donations Modal"
aria-describedby="Email Unacknowledged Donations Modal"
>
<Box sx={modalStyle}>
<Typography variant="h6" component="h6">
Emails copied Successfully. Did you send the emails?
</Typography>

<p>
If you sent the message to the copied emaisl, click the button
below to log the communication.
</p>

<div
style={{
display: 'flex',
width: '100%',
justifyContent: 'flex-end',
}}
>
<Button
variant="contained"
onClick={handleDidSendModalClose}
style={{ marginRight: '10px' }}
>
Cancel
</Button>
<Button
variant="contained"
color="success"
onClick={handleEmailsSent}
>
Emails Sent
</Button>
</div>
</Box>
</Modal>
</Box>
</div>
);
Expand Down

0 comments on commit 27b3cf4

Please sign in to comment.