Blame view

pages/activities/[id].js 1.09 KB
jaymehta committed
1 2
import React, { useEffect } from "react";
import { useDispatch } from "react-redux";
.  
jaymehta committed
3 4
import Detail from "../../components/detail/Detail";
import Layout from "../../components/layout/Layout";
.  
jaymehta committed
5
import { getActivityById } from "../../redux/actions/activityAction";
jaymehta committed
6
import { loadUser } from "../../redux/actions/userActions";
.  
jaymehta committed
7
import { wrapper } from "../../redux/store";
8
import { getFaqs } from "../../redux/actions/faqsAction";
.  
jaymehta committed
9
import { getReviewsAction } from "../../redux/actions/reviewsAction";
.  
jaymehta committed
10 11

const ActivityDetailPage = () => {
jaymehta committed
12 13 14 15 16
  const dispatch = useDispatch();
  useEffect(() => {
    dispatch(loadUser());
  }, []);

.  
jaymehta committed
17 18 19 20 21 22 23 24 25 26 27
  return (
    <Layout>
      <Detail />
    </Layout>
  );
};

export default ActivityDetailPage;

/** For server side rendering */
export const getServerSideProps = wrapper.getServerSideProps(store => async ({ req, query }) => {
jaymehta committed
28
  await store.dispatch(getActivityById(query.id));
29
  await store.dispatch(getFaqs());
.  
jaymehta committed
30
  await store.dispatch(getReviewsAction({activityId: query.id}))
jaymehta committed
31
  //   await store.dispatch(getActivitiesByFilters({category: query.category}))
.  
jaymehta committed
32 33 34 35 36

  return {
    props: {}
  };
});