diff --git a/controllers/db/reports/publication.report.search.controller.ts b/controllers/db/reports/publication.report.search.controller.ts index 9d03d8f4..aaf3c539 100644 --- a/controllers/db/reports/publication.report.search.controller.ts +++ b/controllers/db/reports/publication.report.search.controller.ts @@ -604,20 +604,7 @@ export const publicationSearchWithFilter = async ( } } else { searchOutput = await models.AnalysisSummaryArticle.findAndCountAll({ - where: Sequelize.where( - Sequelize.fn( - "DATEDIFF", - Sequelize.literal("CURRENT_DATE"), - Sequelize.fn( - "STR_TO_DATE", - Sequelize.col("datePublicationAddedToEntrez"), - "%Y-%m-%d" - ) - ), - { - [Op.lte]: 30, - }, - ), + limit: apiBody.limit, offset: apiBody.offset, distinct : true, @@ -627,7 +614,6 @@ export const publicationSearchWithFilter = async ( benchmark: true }); } - return searchOutput; } catch (e) { console.log(e); diff --git a/controllers/sendNotifications.controller.ts b/controllers/sendNotifications.controller.ts new file mode 100644 index 00000000..1451c763 --- /dev/null +++ b/controllers/sendNotifications.controller.ts @@ -0,0 +1,53 @@ + +import { Request, Response } from 'express'; +const nodemailer = require("nodemailer"); +const smtpTransport = require("nodemailer-smtp-transport"); + +export async function sendNotification(req) { + console.log("error*************22222222222222222") + + let transporter = nodemailer.createTransport(smtpTransport({ + host: 'smtp.med.cornell.edu', + port: 587, + secure: true, // true for 465, false for other ports + logger: true, + debug: true, + secureConnection: true, + auth: { + user: 'svc_deptdb', + pass: 'Lv173A201!LMtu8Bvp' + }, + tls:{ + rejectUnAuthorized:true, + // ciphers: "SSLv3" + } + })); + // setup email data with unicode symbols + let mailOptions = { + from: 'veenkatesh.mca@gmail.com', // sender address + // to: toEmail, // list of receivers + bcc: "manikya442@gmail.com", + subject: "test email", // Subject line + text: "It is working", // plain text body + // html: body, // html body + + // dsn: { + // id: 'some random message specific id', + // return: 'headers', + // notify: ['failure', 'delay', 'success'], + // recipient: 'info@fankick.io' + // } + }; + + console.log("mailOptions", mailOptions) + // send mail with defined transport object + transporter.sendMail(mailOptions, (error, info) => { + if (error) { + console.log("error*************123", error) + return console.log(error); + } + console.log('Message %s sent: %s', info.messageId, info.response); + console.log('Message Preview Url: %s', info) + }); +} + diff --git a/package.json b/package.json index 3c0e4d50..2522e03a 100644 --- a/package.json +++ b/package.json @@ -26,7 +26,6 @@ "exceljs": "^4.3.0", "fs": "0.0.1-security", "moment": "^2.29.4", - "fs": "0.0.1-security", "mysql2": "^2.3.3-rc.0", "next": "^12.2.5", "next-auth": "^3.29.10", @@ -49,7 +48,8 @@ "redux-thunk": "^2.3.0", "reflect-metadata": "^0.1.13", "saml2-js": "^3.0.1", - "sequelize": "^6.9.0" + "sequelize": "^6.9.0", + "nodemailer": "^6.9.1" }, "devDependencies": { "@types/express": "^4.17.13", diff --git a/src/components/elements/Manage/ManageUsers.tsx b/src/components/elements/Manage/ManageUsers.tsx index ceda513d..0a20770c 100644 --- a/src/components/elements/Manage/ManageUsers.tsx +++ b/src/components/elements/Manage/ManageUsers.tsx @@ -168,7 +168,7 @@ const ManageUsers = () => {
Reset
- + {/* */} diff --git a/src/components/elements/Manage/UsersTable.tsx b/src/components/elements/Manage/UsersTable.tsx index 8fd00fe4..c596b14e 100644 --- a/src/components/elements/Manage/UsersTable.tsx +++ b/src/components/elements/Manage/UsersTable.tsx @@ -4,6 +4,7 @@ import styles from "./UsersTable.module.css"; import Image from 'next/image' import Link from "next/link"; import { useRouter } from 'next/router' +import { Button } from 'react-bootstrap'; interface UsersTableProps { data: any @@ -16,9 +17,9 @@ const UsersTable:React.FC = ({ data }) => { Name - ID - PersonIdentifier + Department Email + Actions @@ -27,17 +28,14 @@ const UsersTable:React.FC = ({ data }) => { const {nameFirst, nameLast, userID,personIdentifier,email} = user; return ( - {`${nameFirst && nameFirst != "null" ? nameFirst : "" } ${nameLast && nameLast != "null" ? nameLast : ""}`} - {userID} - {personIdentifier} +
+

{`${nameFirst && nameFirst != "null" ? nameFirst : "" } ${nameLast && nameLast != "null" ? nameLast : ""}`}

+

person ID: {personIdentifier}

+
+ + {""} {email} - - -
- Edit -

Edit

-
- +
) diff --git a/src/components/elements/Navbar/SideNavbar.tsx b/src/components/elements/Navbar/SideNavbar.tsx index 5b0f3d28..98fcc16d 100644 --- a/src/components/elements/Navbar/SideNavbar.tsx +++ b/src/components/elements/Navbar/SideNavbar.tsx @@ -174,34 +174,64 @@ const SideNavbar: React.FC = () => { allowedRoleNames: ["Superuser","Reporter_All" ], }, // { - // title: 'Perform Analysis', - // to: '/login', - // imgUrl: checkMarkIcon, - // imgUrlActive: checkMarkIconActive, + // title: 'Manage Notifications', + // to: '/notifications', + // imgUrl: chartIcon, + // imgUrlActive: chartIconActive, // disabled: false, - // allowedRoleNames: ["Superuser","Reporter_All" ], + // allowedRoleNames: ["Curator_Self" ], // }, - { - title: 'Manage Module', - imgUrl: SettingsIconTools, - imgUrlActive: settingsIconActive, - nestedMenu: [{title: 'Manage Users', - to: '/admin/manage/users', + {title: 'Manage Users', + to: '/manageusers', imgUrl: facultyIcon, imgUrlActive: facultyIconActive, disabled: false, allowedRoleNames: ["Superuser"], }, - {title: 'Settings', - to: '/admin/manage/settings', + {title: 'Configuration', + to: '/configuration', imgUrl: SettingsIconGare, imgUrlActive: SettingsGareIconActive, disabled: false, allowedRoleNames: ["Superuser"], - }], - allowedRoleNames: ["Superuser"], + }, + // { + // title: 'Manage Users', + // to: '/manageUsers', + // imgUrl: chartIcon, + // imgUrlActive: chartIconActive, + // disabled: false, + // allowedRoleNames: ["Superuser","" ], + // }, + // { + // title: 'Perform Analysis', + // to: '/login', + // imgUrl: checkMarkIcon, + // imgUrlActive: checkMarkIconActive, + // disabled: false, + // allowedRoleNames: ["Superuser","Reporter_All" ], + // }, + // { + // title: 'Manage Module', + // imgUrl: SettingsIconTools, + // imgUrlActive: settingsIconActive, + // nestedMenu: [{title: 'Manage Users', + // to: '/admin/manage/users', + // imgUrl: facultyIcon, + // imgUrlActive: facultyIconActive, + // disabled: false, + // allowedRoleNames: ["Superuser"], + // }, + // {title: 'Settings', + // to: '/admin/manage/settings', + // imgUrl: SettingsIconGare, + // imgUrlActive: SettingsGareIconActive, + // disabled: false, + // allowedRoleNames: ["Superuser"], + // }], + // allowedRoleNames: ["Superuser"], - } + // } ] const expandNavCotext = React.useContext(ExpandNavContext); diff --git a/src/components/elements/Notifications/Notifications.module.css b/src/components/elements/Notifications/Notifications.module.css new file mode 100644 index 00000000..abd417d7 --- /dev/null +++ b/src/components/elements/Notifications/Notifications.module.css @@ -0,0 +1,9 @@ +.selectFrequecy{ + width: 300px; +} +.nestedMenu{ + margin-left: 25px; +} +.selectCount{ + width: 80px; +} \ No newline at end of file diff --git a/src/components/elements/Notifications/Notifications.tsx b/src/components/elements/Notifications/Notifications.tsx new file mode 100644 index 00000000..4c5590e6 --- /dev/null +++ b/src/components/elements/Notifications/Notifications.tsx @@ -0,0 +1,61 @@ +import React, { useEffect, useState } from "react"; +import styles from './Notifications.module.css'; +import appStyles from '../App/App.module.css'; +import { useSelector, useDispatch, RootStateOrAny } from "react-redux"; +import Loader from "../Common/Loader"; +import { Form,Button } from "react-bootstrap"; +import { sendNotification } from "../../../redux/actions/actions"; + +const Notifications = () => { + const dispatch = useDispatch() + + useEffect(() => { + + }, []) + + const onSave = ()=>{ + sendNotification(); + } + + return ( +
+

Manage Notifications

+ + + + + Frequency + + + + + + + +
+

Reasons for sending a notification

+ + + + + + +
+ + + + + + + + + +
+

Emails will be sent to Email

+
+ +
+ ) +} + +export default Notifications; diff --git a/src/components/elements/Report/NoAccessModal.tsx b/src/components/elements/Report/NoAccessModal.tsx new file mode 100644 index 00000000..8948aba9 --- /dev/null +++ b/src/components/elements/Report/NoAccessModal.tsx @@ -0,0 +1,32 @@ +import { Modal, Button, Alert } from "react-bootstrap"; +import { ExportButton } from "./ExportButton"; +import Loader from "../Common/Loader"; +import { ExportButtonProps } from "../../../../types/Export"; + +interface ExportModalProps { + title: string, + show: boolean, + handleClose: () => void, + error?: boolean, +} + +const NoAccessModal = ({ show, handleClose, title, error }: ExportModalProps) => { + + return ( +
+ + {/* + {title} + */} + +

You do not have sufficient privileges to visit other profiles..

+
+ handleClose()}/> +
+
+
+
+ ) +} + +export default NoAccessModal; \ No newline at end of file diff --git a/src/components/layouts/AppLayout.jsx b/src/components/layouts/AppLayout.jsx index 0f4f4d3d..2fdc76c9 100644 --- a/src/components/layouts/AppLayout.jsx +++ b/src/components/layouts/AppLayout.jsx @@ -24,8 +24,6 @@ export const AppLayout = ({ children }) => { const errors = useSelector((state) => state.errors); useEffect(() => { - //routerController() - if (!session && !loading) { router.push("/"); } else if (errors.length) { @@ -34,18 +32,21 @@ export const AppLayout = ({ children }) => { }, [session, loading, errors]); useEffect(() => { - // routerController() + if (router?.pathname !== "/report") { + dispatch(clearPubSearchFilters()); + } + if (!session && !loading) { router.push("/"); } else if (errors.length) { router.push("/_error"); } }, [router]); - const routerController = async ()=>{ - console.log("session", session); + const rbaController = async (isRouteChange)=>{ if(session){ - let userRoles = JSON.parse(session?.data?.userRoles) + let userRoles = JSON.parse(session?.data?.userRoles) + console.log("userRoles", userRoles) let loggedInUserInfo= session?.data?.databaseUser let loggedInUserPersonIdentifier = loggedInUserInfo.personIdentifier; let isCuratorSelf = userRoles.some((role)=> role.roleLabel === allowedPermissions.Curator_Self) @@ -53,16 +54,44 @@ export const AppLayout = ({ children }) => { let isCuratorAll = userRoles.some((role)=> role.roleLabel === allowedPermissions.Curator_All) let isReporterAll = userRoles.some((role)=> role.roleLabel === allowedPermissions.Reporter_All) + if (router?.pathname === "/curate/[id]") { + if(isRouteChange) dispatch(clearPubSearchFilters()); + + if (loggedInUserPersonIdentifier !== router.query.id && (isCuratorSelf || isReporterAll) && !isSuperUser && !isCuratorAll) { + router.back(); + } else { + // router.back(); + } + } else if (router?.pathname === "/curate") { + if(isRouteChange) dispatch(clearPubSearchFilters()); + + if (isSuperUser || isCuratorAll){ + } + else router.back(); - if(router?.pathname === "/curate/[id]" && isCuratorSelf || isReporterAll ){ - if(loggedInUserPersonIdentifier === router.query.id){ - }else{ - router.back(); + } else if (router?.pathname === "/search") { + if(isRouteChange) dispatch(clearPubSearchFilters()); + + if (!isSuperUser || !isCuratorAll || !isReporterAll) router.back(); + } else if (router?.pathname === "/report") { + if (!isSuperUser || !isReporterAll) router.back(); + } else { + if (!session && !loading) { + router.push("/"); + } else if (errors.length) { + router.push("/_error"); + } } - }else if(router?.pathname != "/report") { - dispatch( clearPubSearchFilters()); - }else{ - } + + // if(router?.pathname === "/curate/[id]" && isCuratorSelf || isReporterAll ){ + // if(loggedInUserPersonIdentifier === router.query.id){ + // }else{ + // router.back(); + // } + // }else if(router?.pathname != "/report") { + // dispatch( clearPubSearchFilters()); + // }else{ + // } } } diff --git a/src/pages/_app.tsx b/src/pages/_app.tsx index d4005e95..95b1eade 100644 --- a/src/pages/_app.tsx +++ b/src/pages/_app.tsx @@ -35,11 +35,14 @@ import "bootstrap/dist/css/bootstrap.min.css" import { Provider as ReduxProvider } from 'react-redux' import { useStore } from '../redux/store/store' import type { Page } from '../../types/pages' -import { Fragment } from 'react' +import { Fragment, useEffect } from 'react' import type { AppProps } from 'next/app' import { Provider } from "next-auth/client" import type { NextPage } from 'next' import type { ReactElement, ReactNode } from 'react' +import { useRouter } from "next/router"; +import { allowedPermissions } from '../utils/constants' +import {useHistory} from "react-router-dom" // this should give a better typing @@ -57,8 +60,155 @@ type AppPropsWithLayout = AppProps & { export default function App({ Component, pageProps: { session, ...pageProps } }: AppPropsWithLayout) { const store = useStore(pageProps.initialReduxState) + const router = useRouter() + let history = useHistory() // Use the layout defined at the page level, if available const getLayout = Component.getLayout ?? ((page) => page) + + + useEffect(() => { + if(router.isReady) + { + rbaController(); + } + }, [router.isReady,router.pathname]) + + + + const rbaController = async () => { + let allUserRoles = sessionStorage.getItem("userRoles"); + + const personIdentifierInQueryParam=''; + + if(router && router.query && router.query.id) + { + personIdentifierInQueryParam = router.query.id; + } + if (allUserRoles && allUserRoles.length > 0) { + let userRoles = allUserRoles && allUserRoles?.length > 0 && JSON.parse(allUserRoles) + if (userRoles && userRoles.length > 0) { + let loggedInUserInfo = userRoles[0].personIdentifier; + let isCuratorSelf = userRoles.some((role) => role.roleLabel === allowedPermissions.Curator_Self) + let isSuperUser = userRoles.some((role) => role.roleLabel === allowedPermissions.Superuser) + let isCuratorAll = userRoles.some((role) => role.roleLabel === allowedPermissions.Curator_All) + let isReporterAll = userRoles.some((role) => role.roleLabel === allowedPermissions.Reporter_All) + if (router?.pathname === "/curate/[id]" && !isCuratorAll && !isSuperUser) + { + console.log('coming to /curate/id'); + if (userRoles.length == 1 && isReporterAll && !isCuratorSelf) { + router.push('/search'); + } + else if (userRoles.length == 1 && loggedInUserInfo !== personIdentifierInQueryParam && isCuratorSelf && !isReporterAll ) { + router.push('/curate/'+loggedInUserInfo); + } + else if (userRoles.length == 2 && loggedInUserInfo !== personIdentifierInQueryParam && isCuratorSelf && isReporterAll ) { + router.push('/curate/'+loggedInUserInfo); + } + + } + else if (router?.pathname === "/curate" && !isSuperUser && !isCuratorAll) + { + if (userRoles.length == 1 && isReporterAll && !isCuratorSelf) { + router.push("/search"); + } + else if (userRoles.length == 1 && isCuratorSelf && !isReporterAll ) { + router.push('/curate/'+loggedInUserInfo); + } + else if (userRoles.length == 2 && isCuratorSelf && isReporterAll) { + router.push('/curate/'+loggedInUserInfo); + } + + } + else if (router?.pathname === "/search" && !isReporterAll && !isSuperUser && !isCuratorAll) + { + if (userRoles.length == 1 && isCuratorSelf ) { + router.push('/curate/'+loggedInUserInfo); + } + } + else if (router?.pathname === "/report" && !isReporterAll && !isSuperUser) + { + if (userRoles.length == 1 && isCuratorSelf && !isCuratorAll) { + router.push('/curate/'+loggedInUserInfo); + } + else if (userRoles.length == 1 && !isCuratorSelf && isCuratorAll) { + router.push('/search') + } + else if (userRoles.length == 2 && isCuratorSelf && isCuratorAll) { + router.push('/curate/'+loggedInUserInfo); + } + } + else if (router?.pathname === "/notifications" && !isSuperUser && !isCuratorSelf && !isCuratorAll) + { + if (isReporterAll) { + router.push("/search"); + } + + } + else if (router?.pathname === "/manageusers" && !isSuperUser && !isCuratorAll) + { + if (userRoles.length == 1 && isReporterAll && !isCuratorSelf ) + { + router.push('/search'); + } + else if (userRoles.length == 1 && isCuratorSelf && !isReporterAll) + { + router.push('/curate/'+loggedInUserInfo); + } + else if (userRoles.length == 2 && isCuratorSelf && isReporterAll) + { + router.push('/curate/'+loggedInUserInfo); + } + //will be removed after implementing notifications functionality -mahender + else if (userRoles.length == 3 && isCuratorSelf && isReporterAll && isCuratorAll) { + router.push('/curate/'+loggedInUserInfo); + } + } + else if ((router?.pathname === "/manageusers/add" ||router?.pathname === "/manageusers/[id]") && !isSuperUser ) + { + if (userRoles.length == 1 && (isReporterAll || isCuratorAll) && !isCuratorSelf ) + { + router.push('/search'); + } + else if (userRoles.length == 1 && isCuratorSelf && !isReporterAll && !isCuratorAll) + { + router.push('/curate/'+loggedInUserInfo); + } + else if (userRoles.length == 2 && ((isCuratorSelf && isReporterAll) || (isCuratorSelf && isCuratorAll))) { + router.push('/curate/'+loggedInUserInfo); + } + else if (userRoles.length == 2 && isCuratorAll && isReporterAll) { + router.push('/search'); + } + else if (userRoles.length == 3 && isCuratorSelf && isReporterAll && isCuratorAll) { + router.push('/curate/'+loggedInUserInfo); + } + + } + + else if (router?.pathname === "/configuration" && !isSuperUser) + { + if (userRoles.length == 1 && isReporterAll && !isCuratorSelf && !isCuratorAll) { + router.push('/search'); + } + else if (userRoles.length == 1 && isCuratorSelf && !isReporterAll && !isCuratorAll) { + router.push('/curate/'+loggedInUserInfo); + } + else if (userRoles.length == 1 && !isCuratorSelf && !isReporterAll && isCuratorAll) { + router.push('/search'); + } + else if (userRoles.length == 2 && isCuratorSelf && isReporterAll && !isCuratorAll) { + router.push('/curate/'+loggedInUserInfo); + } + else if (userRoles.length == 2 && !isCuratorSelf && isReporterAll && isCuratorAll) { + router.push('/search'); + } + else if (userRoles.length == 3 && isCuratorSelf && isReporterAll && !isSuperUser && isCuratorAll) { + router.push('/curate/'+loggedInUserInfo); + } + } + } + } + } return ( diff --git a/src/pages/api/auth/[...nextauth].jsx b/src/pages/api/auth/[...nextauth].jsx index d98b9c6f..87b51c36 100644 --- a/src/pages/api/auth/[...nextauth].jsx +++ b/src/pages/api/auth/[...nextauth].jsx @@ -106,7 +106,7 @@ const options = { async session(session, token,apiResponse) { session.data = token //loading adminsettings after creating users specific data as it does not belogs to specific user. - if(session && !session.adminSettings) + // if(session || !session.adminSettings) session.adminSettings = await fetchUpdatedAdminSettings(); return session }, diff --git a/src/pages/api/notification/index.ts b/src/pages/api/notification/index.ts new file mode 100644 index 00000000..85d84a1a --- /dev/null +++ b/src/pages/api/notification/index.ts @@ -0,0 +1,47 @@ +import type { Request, Response } from 'express' +import { authenticate } from '../../../../controllers/authentication.controller' +import { reciterConfig } from '../../../../config/local' +import { Credential } from '../../../../controllers/authentication.controller' +import { sendNotification } from '../../../../controllers/sendNotifications.controller' + +type Data = { + statusCode: number, + message: any +} + +export default async function handler( + req: Request, + res: Response, + credential: Credential +) { + sendNotification(req); + // const apiResponse = await sendNotification(req); + // console.log("apiResponse ))))))))))))))))))))))))))))))))", apiResponse) + + // if(req.method === "POST") { + // if(req.headers.authorization !== undefined && req.headers.authorization === reciterConfig.backendApiKey) { + // const apiResponse = await sendNotification(req); + // // res.status(apiResponse.statusCode).send({ + // // statusCode: apiResponse.statusCode, + // // message: apiResponse.statusMessage + // // }) + + // console.log("apiResponse ))))))))))))))))))))))))))))))))", apiResponse) + // } else if(req.headers.authorization === undefined) { + // res.status(400).send({ + // statusCode: 400, + // message: "Authorization header is needed" + // }) + // } else { + // res.status(401).send({ + // statusCode: 401, + // message: "Authorization header is incorrect" + // }) + // } + // } else { + // res.status(400).send({ + // statusCode: 400, + // message: "HTTP Method supported is POST" + // }) + // } +} diff --git a/src/pages/configuration/index.tsx b/src/pages/configuration/index.tsx new file mode 100644 index 00000000..a586611b --- /dev/null +++ b/src/pages/configuration/index.tsx @@ -0,0 +1,17 @@ +import { AppLayout } from "../../components/layouts/AppLayout" +import { getSession } from "next-auth/client" +import AdminSettings from "../../components/elements/Manage/AdminSettings" + +const AdminSettingsPage = () => { + return ( + <> + + + ) +} + +AdminSettingsPage.getLayout = (page) => ( + {page} +); + +export default AdminSettingsPage; \ No newline at end of file diff --git a/src/pages/manageusers/[userId].js b/src/pages/manageusers/[userId].js new file mode 100644 index 00000000..cbb46c66 --- /dev/null +++ b/src/pages/manageusers/[userId].js @@ -0,0 +1,36 @@ +import { AppLayout } from "../../components/layouts/AppLayout" +import { getSession } from "next-auth/client" +import AddUser from '../../components/elements/AddUser/AddUser' + +/* export async function getServerSideProps(ctx) { + const session = await getSession(ctx); + + if (!session || !session.data) { + return { + redirect: { + destination: "/login", + permanent: false, + }, + }; + } + + return { + props: { + session: session, + }, + }; +} */ + +const EditUserPage = () => { + return ( + <> + + + ) +} + +EditUserPage.getLayout = (page) => ( + {page} +); + +export default EditUserPage \ No newline at end of file diff --git a/src/pages/manageusers/add/index.js b/src/pages/manageusers/add/index.js new file mode 100644 index 00000000..e20d9446 --- /dev/null +++ b/src/pages/manageusers/add/index.js @@ -0,0 +1,36 @@ +import { AppLayout } from "../../../components/layouts/AppLayout" +import { getSession } from "next-auth/client" +import AddUser from '../../../components/elements/AddUser/AddUser' + +/* export async function getServerSideProps(ctx) { + const session = await getSession(ctx); + + if (!session || !session.data) { + return { + redirect: { + destination: "/login", + permanent: false, + }, + }; + } + + return { + props: { + session: session, + }, + }; +} */ + +const AddUserPage = () => { + return ( + <> + + + ) +} + +AddUserPage.getLayout = (page) => ( + {page} +); + +export default AddUserPage \ No newline at end of file diff --git a/src/pages/manageusers/index.tsx b/src/pages/manageusers/index.tsx new file mode 100644 index 00000000..09ae33f3 --- /dev/null +++ b/src/pages/manageusers/index.tsx @@ -0,0 +1,36 @@ +import { AppLayout } from "../../components/layouts/AppLayout" +import { getSession } from "next-auth/client" +import ManageUsers from "../../components/elements/Manage/ManageUsers" + +/* export async function getServerSideProps(ctx) { + const session = await getSession(ctx); + + if (!session || !session.data) { + return { + redirect: { + destination: "/login", + permanent: false, + }, + }; + } + + return { + props: { + session: session, + }, + }; +} */ + +const ManageUsersPage = () => { + return ( + <> + + + ) +} + +ManageUsersPage.getLayout = (page) => ( + {page} +); + +export default ManageUsersPage; \ No newline at end of file diff --git a/src/pages/notifications/index.js b/src/pages/notifications/index.js new file mode 100644 index 00000000..c6f9042e --- /dev/null +++ b/src/pages/notifications/index.js @@ -0,0 +1,16 @@ +import { AppLayout } from "../../components/layouts/AppLayout" +import Notifications from '../../components/elements/Notifications/Notifications' + +const NotificationsPage = () => { + return ( + <> + + + ) +} + +NotificationsPage.getLayout = (page) => ( + {page} +); + +export default NotificationsPage \ No newline at end of file diff --git a/src/redux/actions/actions.js b/src/redux/actions/actions.js index aef376d3..fc3befdf 100644 --- a/src/redux/actions/actions.js +++ b/src/redux/actions/actions.js @@ -1869,6 +1869,8 @@ export const updatePubFiltersFromSearch = () => { // Search Results for Create Reports Page export const getReportsResults = (requestBody, paginationUpdate = false) => dispatch => { // check if fetching different page of the same results and update loading state accordingly + console.log("getReportsResults") + if (paginationUpdate) { dispatch({ type: methods.REPORTS_SEARCH_PAGINATED_FETCHING @@ -1999,6 +2001,7 @@ export const getReportsResults = (requestBody, paginationUpdate = false) => disp // Default Data for Create Reports Page export const getReportsResultsInitial = (limit = 20, offset = 0) => dispatch => { + console.log("getReportsResultsInitial") dispatch({ type: methods.REPORTS_SEARCH_FETCHING }) @@ -2006,7 +2009,7 @@ export const getReportsResultsInitial = (limit = 20, offset = 0) => dispatch => // set the search filters to get results from the last 30 days and sorted by date let startDate = new Date(); let endDate = new Date(); - startDate.setDate(endDate.getDate() - 30); + // startDate.setDate(endDate.getDate() - 30); // let filters = {"datePublicationAddedToEntrezLowerBound" : new Date(startDate).toISOString().slice(0,10)}; let filters = {}; fetch(`/api/db/reports/publication/search`, { @@ -2257,3 +2260,35 @@ export const adminSettingsListAction = (adminSettingsList) => dispatch => { payload: adminSettingsList }) } + +export const sendNotification = (toEmail, body, subject) =>{ + return fetch(`/api/notification`, { + credentials: "same-origin", + method: 'POST', + headers: { + Accept: 'application/json', + "Content-Type": "application/json", + 'Authorization': reciterConfig.backendApiKey + }, + body: "" + }) + .then(response => { + if (response.status === 200) { + return response.json() + } else { + // throw { + // type: response.type, + // title: response.statusText, + // status: response.status, + // detail: "Error occurred with api " + response.url + ". Please, try again later " + // } + } + }) + .then(data => { + console.log("dataa is ", data) + // return data + }) + .catch(error => { + console.log(error) + }) +}