Blame view

pages/vendor/activities/index.js 2.11 KB
jaymehta committed
1
import React, { useEffect, useState } from "react";
2 3 4 5
import Layout from "../../../components/layout/Layout";
import { wrapper } from "../../../redux/store";
import Sidebar from "../../../components/layout/VendorDashboardSidebar";
import ActivityListing from "../../../components/vendor/ActivityListing";
jaymehta committed
6 7 8
import ActivityListingRBAC from "../../../components/vendor/ActivityListingRBAC";
import { getAllCategories, getAllSubCategories } from "../../../redux/actions/categoriesAction";
import { getActivitiesByVendor } from "../../../redux/actions/activityAction";
jaymehta committed
9
import { loadUser } from "../../../redux/actions/userActions";
jaymehta committed
10
import { useDispatch } from "react-redux";
Chetan committed
11
import { GenericLayout } from "../../../components/layout/Generics/GenericLayout";
12 13 14 15
// import { loadUser } from "../redux/actions/userActions";
// import { wrapper } from "../redux/store";

export default function ActivityListingPage() {
jaymehta committed
16 17 18
  const dispatch = useDispatch();
  useEffect(() => {
    dispatch(getActivitiesByVendor());
.  
jaymehta committed
19
    dispatch(loadUser());
jaymehta committed
20 21
  }, []);

.  
jaymehta committed
22 23 24 25 26 27 28 29 30
  const [tableCurrentPage, settableCurrentPage] = useState(1);
  const [tableItemsPerPage, settableItemsPerPage] = useState(10);

  const onChange = (pagination, filters, sorter, extra) => {
    console.log("params", pagination, filters, sorter, extra);
    settableCurrentPage(pagination.current);
    settableItemsPerPage(pagination.pageSize);
    dispatch(getActivitiesByVendor());
  };
jaymehta committed
31
  return (
Chetan committed
32 33
    <GenericLayout>
      {/* <div className="sidebarContainer">
jaymehta committed
34
        <Sidebar />
Chetan committed
35
        <div className="content"> */}
.  
jaymehta committed
36
      <ActivityListingRBAC onChange={onChange} tableCurrentPage={tableCurrentPage} tableItemsPerPage={tableItemsPerPage} />
Chetan committed
37 38 39
      {/* </div>
      </div> */}
    </GenericLayout>
jaymehta committed
40 41
  );
}
42 43 44

/** For server side rendering */
export const getServerSideProps = wrapper.getServerSideProps(store => async ({ req, query }) => {
jaymehta committed
45
  await store.dispatch(loadUser());
jaymehta committed
46
  // await store.dispatch(getActivitiesByVendor());
jaymehta committed
47 48 49 50
  await store.dispatch(getAllCategories());
  await store.dispatch(getAllSubCategories());
  // get the locations data.
  // await store.dispatch(getVendorDetails())
51

jaymehta committed
52 53 54
  return {
    props: {}
  };
55
});