Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions app/components/conferences/admin/dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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);
}
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions app/lib/conferences/eventCall.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,12 +148,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;
Expand Down
38 changes: 0 additions & 38 deletions app/pages/conferences/admin/dashboard.js

This file was deleted.

60 changes: 60 additions & 0 deletions app/pages/conferences/admin/dashboard/[eid].js
Original file line number Diff line number Diff line change
@@ -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 (
<div>
<Head>
<title>Event Create</title>
<meta name="description" content="Rocket.Chat form tool demo" />
<link rel="icon" href="/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
</Head>
<div className="mx-auto">
<h1 className="mx-auto mt-3">Preview of Event Dashboard</h1>
<Card style={{ margin: "1vw" }}>
<Card.Header>
<Nav variant="tabs" defaultActiveKey="published" activeKey={eid}>
<Nav.Item>
<Nav.Link href="published">Live</Nav.Link>
</Nav.Item>
<Nav.Item>
<Nav.Link href="draft">Draft</Nav.Link>
</Nav.Item>
</Nav>
</Card.Header>
<Card.Body>
<Stack direction="vertical">
<EventDashBoard state={eid} />
</Stack>
</Card.Body>
</Card>
</div>
</div>
);
}

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;
2 changes: 1 addition & 1 deletion cms/config/initialData/sub-menus.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down