diff --git a/locales/ar/common.json b/locales/ar/common.json
index 8585414..266d8dc 100644
--- a/locales/ar/common.json
+++ b/locales/ar/common.json
@@ -118,5 +118,6 @@
"missing-translation": "عذرا ، لا توجد نسخة باللغة الإنجليزية لهذه الصفحة في الوقت الحالي",
"error-404-t": "خطأ 404",
"error-404-m": "الصفحة التي تبحث عنها لا يمكن العثور عليها",
- "error-404-l": "اضغط هنا للرجوع"
+ "error-404-l": "اضغط هنا للرجوع",
+ "view-legislation": "عرض التشريعات"
}
diff --git a/locales/en/common.json b/locales/en/common.json
index acb8c65..1d884b2 100644
--- a/locales/en/common.json
+++ b/locales/en/common.json
@@ -118,5 +118,6 @@
"missing-translation": "Sorry, there is no English version for this page right now",
"error-404-t": "Error 404",
"error-404-m": "The page you are looking for could not be found",
- "error-404-l": "Click here to go back"
+ "error-404-l": "Click here to go back",
+ "view-legislation": "View Legislations"
}
diff --git a/pages/api/contact.js b/pages/api/contact.js
index a0d994d..c7e41e8 100644
--- a/pages/api/contact.js
+++ b/pages/api/contact.js
@@ -18,8 +18,12 @@ export default async (req, res) => {
}
try {
-
- console.log("MAIL_SERVER, MAIL_ACCOUNT, MAIL_PASSWORD", MAIL_SERVER, MAIL_ACCOUNT, MAIL_PASSWORD)
+ console.log(
+ 'MAIL_SERVER, MAIL_ACCOUNT, MAIL_PASSWORD',
+ MAIL_SERVER,
+ MAIL_ACCOUNT,
+ MAIL_PASSWORD
+ );
const transporter = nodemailer.createTransport({
port: MAIL_PORT,
host: MAIL_SERVER,
@@ -29,6 +33,10 @@ export default async (req, res) => {
},
secure: false,
connectionTimeout: 100 * 1000,
+ requireTLS: true, // Enforces STARTTLS
+ tls: {
+ ciphers: 'SSLv3',
+ },
});
const mailData = {
@@ -40,19 +48,18 @@ export default async (req, res) => {
text: `Name of Sender: ${name}\n\nEmail of Sender: ${email}\n\n\nDetails/Content: ${message}`,
};
- console.log(mailData);
-
- transporter.sendMail(mailData, function (err, info) {
- console.log('Email sent');
- if (err) {
- console.log(err);
- return res.status(400).send({
- error: `There was an error sending this email, please contact us at `,
- });
- } else {
- return res.status(200).send();
- }
+ await new Promise((resolve, reject) => {
+ transporter.sendMail(mailData, (err, info) => {
+ if (err) {
+ console.error(err);
+ return reject(err);
+ } else {
+ console.log('Email sent', info);
+ return resolve(info);
+ }
+ });
});
+ return res.status(200).send({ success: true });
} catch (error) {
return res.status(500).send({ error: error.message || error.toString() });
}
diff --git a/pages/topic/[topic].tsx b/pages/topic/[topic].tsx
index 32fb1ad..c81de80 100644
--- a/pages/topic/[topic].tsx
+++ b/pages/topic/[topic].tsx
@@ -28,7 +28,11 @@ import ScrollIndicator from '../../components/_shared/ScrollIndicator';
import { fixTranslations } from '../../hooks/locale';
import useTranslation from 'next-translate/useTranslation';
-const Topic: React.FC
= ({ variables, topicsConfigs }) => {
+const Topic: React.FC = ({
+ variables,
+ topicsConfigs,
+ topicLinksConfig,
+}) => {
const { t } = useTranslation('common');
const router = useRouter();
// eslint-disable-next-line prefer-const
@@ -108,6 +112,7 @@ const Topic: React.FC = ({ variables, topicsConfigs }) => {
searchPage={searchPage}
setActiveTopic={setActiveTopic}
configs={topicsConfigs}
+ topicLinksConfig={topicLinksConfig}
>
{
return JSON.parse(data)?.topics;
};
+ const getTopicLinks = async () => {
+ const filePath = path.join(
+ process.cwd(),
+ '/public/configs/topic-links.json'
+ );
+ const data = await fsPromises.readFile(filePath, 'utf8');
+ return JSON.parse(data);
+ };
+
const apolloClient = initializeApollo();
await apolloClient.query({
@@ -154,11 +168,14 @@ export const getServerSideProps: GetServerSideProps = async () => {
variables,
});
+ console.log('TOPIC LINK', await getTopicLinks());
+
return {
props: {
initialApolloState: apolloClient.cache.extract(),
variables,
topicsConfigs: await getTopicsConfigs(),
+ topicLinksConfig: await getTopicLinks(),
},
};
};
diff --git a/public/configs/topic-links.json b/public/configs/topic-links.json
new file mode 100644
index 0000000..72c8c0a
--- /dev/null
+++ b/public/configs/topic-links.json
@@ -0,0 +1,17 @@
+{
+ "defaultLink": "https://uaelegislation.gov.ae",
+ "topicLinks": {
+ "economy": "https://uaelegislation.gov.ae/en/economy",
+ "food-security": "https://uaelegislation.gov.ae/en/food-security",
+ "education": "https://uaelegislation.gov.ae/en/education",
+ "environment": "https://uaelegislation.gov.ae/en/environment",
+ "social": "https://uaelegislation.gov.ae/en/social",
+ "health-care": "https://uaelegislation.gov.ae/en/health-care",
+ "sport": "https://uaelegislation.gov.ae/en/sport",
+ "government": "https://uaelegislation.gov.ae/en/government",
+ "technology": "https://uaelegislation.gov.ae/en/technology",
+ "transport": "https://uaelegislation.gov.ae/en/transport",
+ "infrastructure": "https://uaelegislation.gov.ae/en/infrastructure",
+ "housing": "https://uaelegislation.gov.ae/housing"
+ }
+}
\ No newline at end of file