index.js
2.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import React, { useEffect, useState } from "react";
import Layout from "../../../components/layout/Layout";
import Sidebar from "../../../components/layout/AdminDashboardSidebar";
import ActivityListing from "../../../components/admin/ActivityListing";
import ActivityListingRBAC from "../../../components/vendor/ActivityListingRBAC";
import { wrapper } from "../../../redux/store";
import { loadUser } from "../../../redux/actions/userActions";
import { getAllCategories, getAllSubCategories } from "../../../redux/actions/categoriesAction";
import { useDispatch } from "react-redux";
import { getActivitiesForAdmin } from "../../../redux/actions/activityAction";
import ActivityDetailsModal from "../../../components/admin/ActivityDetailsModal";
import { GenericLayout } from "../../../components/layout/Generics/GenericLayout";
export default function ActivityListingPage() {
const [activityDetailInfo, setactivityDetailInfo] = useState();
const [showActivityDetailsModal, setShowActivityDetailsModal] = useState(false);
const handleCloseActivityDetails = () => {
setShowActivityDetailsModal(false);
};
const dispatch = useDispatch();
useEffect(() => {
dispatch(getActivitiesForAdmin({ pageNumber: 1 }));
}, []);
const [tableCurrentPage, settableCurrentPage] = useState(1);
const [tableItemsPerPage, settableItemsPerPage] = useState(10);
const [filterValue, setfilterValue] = useState();
const onChange = (pagination, filters, sorter, extra, searchText) => {
console.log("params", pagination, filters, sorter, extra);
settableCurrentPage(pagination.current);
settableItemsPerPage(pagination.pageSize);
dispatch(getActivitiesForAdmin({ pageNumber: pagination.current, pageSize: pagination.pageSize, vendorName: filterValue }));
};
return (
<GenericLayout>
{/* <Layout> */}
{/* <div className="sidebarContainer"> */}
{/* <Sidebar /> */}
{/* <div className="content"> */}
{/* <ActivityListing /> */}
<ActivityListingRBAC
setfilterValue={setfilterValue}
setactivityDetailInfo={setactivityDetailInfo}
setShowActivityDetailsModal={setShowActivityDetailsModal}
onChange={onChange}
tableCurrentPage={tableCurrentPage}
tableItemsPerPage={tableItemsPerPage}
/>
{showActivityDetailsModal && <ActivityDetailsModal show={showActivityDetailsModal} handleClose={handleCloseActivityDetails} activityDetailInfo={activityDetailInfo} />}
{/* </div> */}
{/* </div> */}
{/* </Layout> */}
</GenericLayout>
);
}
/** For server side rendering */
export const getServerSideProps = wrapper.getServerSideProps(store => async ({ req, query }) => {
await store.dispatch(loadUser());
// await store.dispatch(getActivitiesByVendor());
await store.dispatch(getAllCategories());
await store.dispatch(getAllSubCategories());
// get the locations data.
// await store.dispatch(getVendorDetails())
return {
props: {}
};
});