From d03fcec2464b24a62220691b28cf3ffaa99e7b42 Mon Sep 17 00:00:00 2001 From: ayush3160 Date: Wed, 19 Apr 2023 10:12:30 +0530 Subject: [PATCH 1/2] dashboard-modified --- app/components/conferences/admin/dashboard.js | 14 +++-- app/lib/conferences/eventCall.js | 7 +-- app/pages/conferences/admin/dashboard.js | 38 ------------ .../conferences/admin/dashboard/[eid].js | 60 +++++++++++++++++++ cms/config/initialData/sub-menus.json | 2 +- 5 files changed, 72 insertions(+), 49 deletions(-) delete mode 100644 app/pages/conferences/admin/dashboard.js create mode 100644 app/pages/conferences/admin/dashboard/[eid].js diff --git a/app/components/conferences/admin/dashboard.js b/app/components/conferences/admin/dashboard.js index 83a2339b..8b9bcbd5 100644 --- a/app/components/conferences/admin/dashboard.js +++ b/app/components/conferences/admin/dashboard.js @@ -5,12 +5,12 @@ import { BiEdit } from "react-icons/bi"; import { MdDelete } from "react-icons/md"; import { deleteEvent, - getUserEventDeatils, + getUserEventDeatilsByState, } from "../../../lib/conferences/eventCall"; import styles from "../../../styles/event.module.css"; import toast, { Toaster } from 'react-hot-toast'; -export const EventDashBoard = () => { +export const EventDashBoard = ({state}) => { const [eventData, setEventData] = useState(null); let authCookie = Cookies.get("event_auth"); if (authCookie) { @@ -20,9 +20,10 @@ export const EventDashBoard = () => { const fetchEventDeatils = async () => { try { if (!eventData) { - const eventres = await getUserEventDeatils( + const eventres = await getUserEventDeatilsByState( authCookie.jwtInfo.identity, - authCookie.access_token + authCookie.access_token, + state ); setEventData(eventres.data); } @@ -36,9 +37,10 @@ export const EventDashBoard = () => { const handleDelete = async (e) => { try { await deleteEvent(e.target.id, authCookie?.access_token); - const eventres = await getUserEventDeatils( + const eventres = await getUserEventDeatilsByState( authCookie.jwtInfo.identity, - authCookie.access_token + authCookie.access_token, + state ); toast.success('Event deleted successfully',{ duration:2000 diff --git a/app/lib/conferences/eventCall.js b/app/lib/conferences/eventCall.js index 590f0c38..f014c938 100644 --- a/app/lib/conferences/eventCall.js +++ b/app/lib/conferences/eventCall.js @@ -1,8 +1,7 @@ import axios from "axios"; const eventUrl = process.env.NEXT_PUBLIC_EVENT_BACKEND_URL; -const nextDeployUrl = - process.env.NEXT_PUBLIC_API_URL || "http://localhost:3000"; +const nextDeployUrl = "http://localhost:3000"; //NextJS local API route call begins export const signCook = async (mail) => { @@ -148,12 +147,12 @@ export const getAllEvents = async (eid) => { return res; }; -export const getUserEventDeatils = async (uid, auth) => { +export const getUserEventDeatilsByState = async (uid, auth,state) => { const headers = { Accept: "application/vnd.api+json", Authorization: `JWT ${auth}`, }; - const res = await axios.get(`${eventUrl}/v1/users/${uid}/events`, { + const res = await axios.get(`${eventUrl}/v1/users/${uid}/events?filter=[{"name" : "state","op" : "eq","val" : "${state}"}]`, { headers: headers, }); return res; diff --git a/app/pages/conferences/admin/dashboard.js b/app/pages/conferences/admin/dashboard.js deleted file mode 100644 index e63acced..00000000 --- a/app/pages/conferences/admin/dashboard.js +++ /dev/null @@ -1,38 +0,0 @@ -import Head from "next/head"; -import { Stack } from "react-bootstrap"; -import { EventCreate } from "../../../components/conferences/create/EventCreate"; -import { ssrVerifyAdmin } from "../../../components/conferences/auth/AuthSuperProfileHelper"; -import { fetchAPI } from "../../../lib/api"; -import { unsignCook } from "../../../lib/conferences/eventCall"; -import { EventDashBoard } from "../../../components/conferences/admin/dashboard"; - -function EventDashBoardPage() { - return ( -
- - Event Create - - - - -
-

Preview of Event Dashboard

- - - -
-
- ); -} - -export async function getStaticProps(context) { - - const topNavItems = await fetchAPI("/top-nav-item"); - - return { - props: { topNavItems }, - revalidate: 10, - }; -} - -export default EventDashBoardPage; diff --git a/app/pages/conferences/admin/dashboard/[eid].js b/app/pages/conferences/admin/dashboard/[eid].js new file mode 100644 index 00000000..0badd8df --- /dev/null +++ b/app/pages/conferences/admin/dashboard/[eid].js @@ -0,0 +1,60 @@ +import Head from "next/head"; +import { Stack, Nav, Card } from "react-bootstrap"; +import { fetchAPI } from "../../../../lib/api"; +import { EventDashBoard } from "../../../../components/conferences/admin/dashboard"; +import { useRouter } from "next/router"; + +function EventDashBoardPage() { + const router = useRouter(); + const { eid } = router.query; + + return ( +
+ + Event Create + + + + +
+

Preview of Event Dashboard

+ + + + + + + + + + +
+
+ ); +} + +export async function getStaticPaths() { + return { + paths: [{ params: { eid: "published" } }, { params: { eid: "draft" } }], + fallback: "blocking", + }; +} + +export async function getStaticProps(context) { + + const topNavItems = await fetchAPI("/top-nav-item"); + + return { + props: { topNavItems }, + revalidate: 10, + }; +} + +export default EventDashBoardPage; diff --git a/cms/config/initialData/sub-menus.json b/cms/config/initialData/sub-menus.json index 1f3653ac..8faa2c28 100644 --- a/cms/config/initialData/sub-menus.json +++ b/cms/config/initialData/sub-menus.json @@ -150,7 +150,7 @@ { "id": 19, "label": "Dashboard", - "url": "/conferences/admin/dashboard", + "url": "/conferences/admin/dashboard/published", "published_at": "2021-06-21T09:03:49.991Z", "created_at": "2021-06-21T09:03:57.289Z", "updated_at": "2021-06-21T09:03:57.289Z" From eb7524a99b47675693c5b7ca6c5fd55edf3bca5a Mon Sep 17 00:00:00 2001 From: ayush3160 Date: Wed, 19 Apr 2023 10:31:51 +0530 Subject: [PATCH 2/2] minor-change --- app/lib/conferences/eventCall.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/lib/conferences/eventCall.js b/app/lib/conferences/eventCall.js index f014c938..3cba0855 100644 --- a/app/lib/conferences/eventCall.js +++ b/app/lib/conferences/eventCall.js @@ -1,7 +1,8 @@ import axios from "axios"; const eventUrl = process.env.NEXT_PUBLIC_EVENT_BACKEND_URL; -const nextDeployUrl = "http://localhost:3000"; +const nextDeployUrl = + process.env.NEXT_PUBLIC_API_URL || "http://localhost:3000"; //NextJS local API route call begins export const signCook = async (mail) => {