diff --git a/components/HelpRequests.jsx b/components/HelpRequests.jsx
index a064b09..bdf7cb7 100644
--- a/components/HelpRequests.jsx
+++ b/components/HelpRequests.jsx
@@ -93,6 +93,24 @@ const HelpRequests = () => {
getData()
}, [])
+ const getMailtoLink = (helpRequestInfo) => {
+ const formattedBody =
+ `Hi [NAME],%0A%0A%0A%0A%0A%0A` +
+ `Best Regards,%0A` +
+ `[YOUR NAME]%0A` +
+ `Truth Sleuth Support Team%0A%0A` +
+ `---%0A%0AForwarded Help Request:%0A%0A` +
+ `User ID: ${helpRequestInfo.userID}%0A` +
+ `Email: ${helpRequestInfo.email}%0A` +
+ `Subject: ${helpRequestInfo.subject}%0A` +
+ `Message: ${helpRequestInfo.message}%0A` +
+ `Created Date: ${helpRequestInfo.createdDate}%0A` +
+ `Images: ${helpRequestInfo.images.join(', ')}%0A`
+
+ const mailtoLink = `mailto:${helpRequestInfo.email}?subject=${encodeURIComponent(helpRequestInfo.subject)}%20-%20Truth%20Sleuth%20Help%20Request&body=${formattedBody}`
+ return mailtoLink
+ }
+
return (
<>
@@ -130,50 +148,54 @@ const HelpRequests = () => {
)}
{helpRequests.length > 0 &&
- helpRequests.map((request) => (
-
{
- const { id, ...data } = request
- handleRequestModalShow(data)
- }}
- key={request.id}
- className={style.table_tr}>
- {request.subject} |
- {request.message} |
-
- {
- e.stopPropagation()
- }}
- className="underline"
- href={`mailto:${request.email}`}
- target="_blank">
- {request.email}
-
- |
- {request.createdDate} |
- e.stopPropagation()}>
-
- |
-
- ))}
+ helpRequests
+ .sort(
+ (a, b) => new Date(b.createdDate) - new Date(a.createdDate),
+ )
+ .map((request) => (
+ {
+ const { id, ...data } = request
+ handleRequestModalShow(data)
+ }}
+ key={request.id}
+ className={style.table_tr}>
+ {request.subject} |
+ {request.message} |
+
+ {
+ e.stopPropagation()
+ }}
+ className="underline"
+ href={getMailtoLink(request)}
+ target="_blank">
+ {request.email}
+
+ |
+ {request.createdDate} |
+ e.stopPropagation()}>
+
+ |
+
+ ))}
@@ -183,6 +205,7 @@ const HelpRequests = () => {
)}
>
diff --git a/components/modals/HelpRequestsModal.jsx b/components/modals/HelpRequestsModal.jsx
index 00a4ef3..0548fe4 100644
--- a/components/modals/HelpRequestsModal.jsx
+++ b/components/modals/HelpRequestsModal.jsx
@@ -1,3 +1,4 @@
+import { Button } from '@material-tailwind/react'
import Image from 'next/image'
import Link from 'next/link'
import React, { Fragment } from 'react'
@@ -34,7 +35,7 @@ const formatLabel = (label) => {
return label.replace(/([a-z])([A-Z])/g, '$1 $2')
}
-const HelpRequestsModal = ({ helpRequestInfo, handleClose }) => {
+const HelpRequestsModal = ({ helpRequestInfo, handleClose, mailtoLink }) => {
return (
@@ -50,7 +51,7 @@ const HelpRequestsModal = ({ helpRequestInfo, handleClose }) => {
-
+
+
+
+