Commit 395e7636 by jaymehta

.

1 parent 9d3f8c00
import { Empty, Modal } from "antd" import { Empty, Modal } from "antd";
import Image from "next/image" import { cleanImage } from "../../services/imageHandling.js";
import { cleanImage } from '../../services/imageHandling.js'
const ActivityDetailGallaryModal = ({ activityDetailInfo }) => { const ActivityDetailGallaryModal = ({ activityDetailInfo }) => {
return ( return (
<> <>
{activityDetailInfo[0].attributes.imagesComponent.length > 0 ? (
{activityDetailInfo[0].attributes.imagesComponent.length > 0 ?
<div className="p-4"> <div className="p-4">
<div className="row"> <div className="row">
{activityDetailInfo[0].attributes.imagesComponent.map((data, index) => ( {activityDetailInfo[0].attributes.imagesComponent.map((data, index) => (
<div className="col-4" key={index}> <div className="col-4" key={index}>
<Image className="img-fluid" height={400} width={400} alt="" src={cleanImage(data.image.data.attributes)} /> <img className="img-fluid" height={400} width={400} alt="" src={cleanImage(data.image.data?.attributes)} />
</div> </div>
))} ))}
</div> </div>
</div> </div>
: ) : (
<div className="d-flex align-items-center justify-content-center" style={{height : '60vh'}}> <div className="d-flex align-items-center justify-content-center" style={{ height: "60vh" }}>
<Empty image={Empty.PRESENTED_IMAGE_SIMPLE} /> <Empty image={Empty.PRESENTED_IMAGE_SIMPLE} />
</div> </div>
} )}
</> </>
) );
} };
export default ActivityDetailGallaryModal
\ No newline at end of file \ No newline at end of file
export default ActivityDetailGallaryModal;
...@@ -154,7 +154,7 @@ const ActivityDetailsModal = ({ show, handleClose, activityDetailInfo }) => { ...@@ -154,7 +154,7 @@ const ActivityDetailsModal = ({ show, handleClose, activityDetailInfo }) => {
<div className="col-12 col-lg-6 "> <div className="col-12 col-lg-6 ">
<p <p
className="pview cursor-pointer" className="pview cursor-pointer"
onClick={() => getUrls(`${process.env.NEXT_PUBLIC_BACKEND_API_URL}${activityDetailInfo[0]?.attributes?.cancellationPolicy?.data?.attributes?.url}`)} onClick={() => getUrls(`${activityDetailInfo[0]?.attributes?.cancellationPolicy?.data?.attributes?.url}`)}
> >
View View
</p> </p>
...@@ -168,7 +168,7 @@ const ActivityDetailsModal = ({ show, handleClose, activityDetailInfo }) => { ...@@ -168,7 +168,7 @@ const ActivityDetailsModal = ({ show, handleClose, activityDetailInfo }) => {
</div> </div>
<div className="col-12 col-lg-6"> <div className="col-12 col-lg-6">
<p className="pview cursor-pointer" <p className="pview cursor-pointer"
onClick={() => getUrls(`${process.env.NEXT_PUBLIC_BACKEND_API_URL}${activityDetailInfo[0]?.attributes?.termsConditions?.data?.attributes?.url}`)} onClick={() => getUrls(`${activityDetailInfo[0]?.attributes?.termsConditions?.data?.attributes?.url}`)}
> >
View View
</p> </p>
......
...@@ -54,7 +54,7 @@ const RejectModal = ({ show, handleClose, detail, setShowDetail }) => { ...@@ -54,7 +54,7 @@ const RejectModal = ({ show, handleClose, detail, setShowDetail }) => {
let response = await updateApprovalStatusAdmin({ status: "rejected", userId: detail[0].attributes.user.data.id, rejectionReason: data.rejectionReason }); let response = await updateApprovalStatusAdmin({ status: "rejected", userId: detail[0].attributes.user.data.id, rejectionReason: data.rejectionReason });
console.log(response.data); console.log(response.data);
await dispatch(getAllVendors()); await dispatch(getAllVendors({}));
handleClose() handleClose()
setShowDetail(false); setShowDetail(false);
}} }}
......
...@@ -6,7 +6,7 @@ import Image from "next/image"; ...@@ -6,7 +6,7 @@ import Image from "next/image";
import RejectModal from "./RejectModal"; import RejectModal from "./RejectModal";
import ActivityListingRBAC from "../vendor/ActivityListingRBAC"; import ActivityListingRBAC from "../vendor/ActivityListingRBAC";
import { useDispatch, useSelector } from "react-redux"; import { useDispatch, useSelector } from "react-redux";
import { getActivitiesByVendor, getActivitiesForAdmin } from "../../redux/actions/activityAction"; import { getActivitiesForAdmin } from "../../redux/actions/activityAction";
import { Tag } from "antd"; import { Tag } from "antd";
import { updateApprovalStatusAdmin } from "../../redux/actions/userActions"; import { updateApprovalStatusAdmin } from "../../redux/actions/userActions";
import { getAllVendors } from "../../redux/actions/vendorActions"; import { getAllVendors } from "../../redux/actions/vendorActions";
...@@ -25,6 +25,16 @@ const VendorDetails = ({ id, backClick, setShowDetail, showDetail, detail }) => ...@@ -25,6 +25,16 @@ const VendorDetails = ({ id, backClick, setShowDetail, showDetail, detail }) =>
dispatch(getActivitiesForAdmin({ vendorId: detail[0].id })); dispatch(getActivitiesForAdmin({ vendorId: detail[0].id }));
}, [allVendors]); }, [allVendors]);
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(getActivitiesForAdmin({ vendorId: detail[0].id, pageNumber: pagination.current, pageSize: pagination.pageSize }));
};
console.log("detail", detail); console.log("detail", detail);
const [showActivityDetailsModal, setShowActivityDetailsModal] = useState(false); const [showActivityDetailsModal, setShowActivityDetailsModal] = useState(false);
const [showRejectModal, setShowRejectModal] = useState(false); const [showRejectModal, setShowRejectModal] = useState(false);
...@@ -157,7 +167,7 @@ const VendorDetails = ({ id, backClick, setShowDetail, showDetail, detail }) => ...@@ -157,7 +167,7 @@ const VendorDetails = ({ id, backClick, setShowDetail, showDetail, detail }) =>
onClick={async () => { onClick={async () => {
await updateApprovalStatusAdmin({ status: "approved", userId: detail[0].attributes.user.data.id }); await updateApprovalStatusAdmin({ status: "approved", userId: detail[0].attributes.user.data.id });
toast.success("User approved"); toast.success("User approved");
await dispatch(getAllVendors()); await dispatch(getAllVendors({}));
}} }}
> >
Approve Approve
...@@ -175,7 +185,13 @@ const VendorDetails = ({ id, backClick, setShowDetail, showDetail, detail }) => ...@@ -175,7 +185,13 @@ const VendorDetails = ({ id, backClick, setShowDetail, showDetail, detail }) =>
</div> </div>
<div className="col-12 col-lg-12 mt-4"> <div className="col-12 col-lg-12 mt-4">
<h4 className="mb-1">Activities</h4> <h4 className="mb-1">Activities</h4>
<ActivityListingRBAC setactivityDetailInfo={setactivityDetailInfo} setShowActivityDetailsModal={setShowActivityDetailsModal} /> <ActivityListingRBAC
setactivityDetailInfo={setactivityDetailInfo}
setShowActivityDetailsModal={setShowActivityDetailsModal}
onChange={onChange}
tableCurrentPage={tableCurrentPage}
tableItemsPerPage={tableItemsPerPage}
/>
</div> </div>
</div> </div>
</div> </div>
......
...@@ -25,7 +25,7 @@ const VendorListing = () => { ...@@ -25,7 +25,7 @@ const VendorListing = () => {
// selectors // selectors
const { loadedUser } = useSelector(state => state.loadedUser); const { loadedUser } = useSelector(state => state.loadedUser);
const { allVendors } = useSelector(state => state.allVendors); const { allVendors, loading: vendorLoading, totalCount } = useSelector(state => state.allVendors);
const toggleMenu = index => { const toggleMenu = index => {
setShowMenuIndex(index === showMenuIndex ? null : index); setShowMenuIndex(index === showMenuIndex ? null : index);
}; };
...@@ -63,9 +63,19 @@ const VendorListing = () => { ...@@ -63,9 +63,19 @@ const VendorListing = () => {
useEffect(() => { useEffect(() => {
if (!loadedUser) return; if (!loadedUser) return;
dispatch(getAllVendors()); dispatch(getAllVendors({ pageNumber: 1, pageSize: 10 }));
}, [loadedUser]); }, [loadedUser]);
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(getAllVendors({ pageNumber: pagination.current, pageSize: pagination.pageSize }));
};
console.log("allVendors", allVendors); console.log("allVendors", allVendors);
const [vendorId, setVendorId] = useState(null); const [vendorId, setVendorId] = useState(null);
const [showVendorDetails, setShowVendorDetails] = useState(false); const [showVendorDetails, setShowVendorDetails] = useState(false);
...@@ -190,7 +200,17 @@ const VendorListing = () => { ...@@ -190,7 +200,17 @@ const VendorListing = () => {
) : ( ) : (
<div> <div>
{!showDetail ? ( {!showDetail ? (
<Table loading={loading} columns={columns} dataSource={data} /> <Table
loading={vendorLoading}
columns={columns}
dataSource={data}
onChange={onChange}
pagination={{
current: tableCurrentPage,
pageSize: tableItemsPerPage,
total: totalCount
}}
/>
) : ( ) : (
// <VendorDetailModal /> // <VendorDetailModal />
<VendorDetails setShowDetail={setShowDetail} showDetail={showDetail} detail={detail} /> <VendorDetails setShowDetail={setShowDetail} showDetail={showDetail} detail={detail} />
...@@ -201,96 +221,6 @@ const VendorListing = () => { ...@@ -201,96 +221,6 @@ const VendorListing = () => {
</div> </div>
</div> </div>
</Fragment> </Fragment>
// <Fragment>
// {!showVendorDetails && (
// <div className="row">
// <div className="col-12 col-lg-12">
// <div className="rightContent">
// <div className="d-flex align-items-center justify-content-between px-2 mb-2">
// <div>
// <h2>Vendors</h2>
// <p>View all the vendors</p>
// </div>
// <div>
// <Button type="button" variant="" className="btnAdd m-0">
// <Image alt="" width="16" height="16" src="/images/vendor/icon-filter.svg" className="me-2" /> Filter
// </Button>
// </div>
// </div>
// <Table responsive className="listingTable">
// <thead>
// <tr>
// <th>
// <label className="check-container mb-0 ps-2" htmlFor="checkh">
// <input type="checkbox" id="checkh" className="check-box" />
// <span className="checkmark"></span>
// </label>
// </th>
// <th>Vendor</th>
// <th>Vendor Id</th>
// <th>Contact Person</th>
// <th>Phone Number</th>
// <th>Email Address</th>
// <th>Status</th>
// <th></th>
// </tr>
// </thead>
// <tbody>
// {array.map((data, index) => (
// <tr key={index}>
// <td>
// <label className="check-container mb-0 ps-2" htmlFor={`check${index}`}>
// <input type="checkbox" id={`check${index}`} className="check-box" />
// <span className="checkmark"></span>
// </label>
// </td>
// <td>
// <span
// onClick={() => {
// setVendorId(1);
// handleShowVendorDetails();
// }}
// >
// M S Adventure
// </span>
// </td>
// <td>VN_ET9797</td>
// <td>Ridge Johnson</td>
// <td>+91 9865 43210</td>
// <td>adventuretrails@example.com</td>
// <td>
// <div className={`statusDiv ${index % 2 ? "inactive" : "active"}`}>{index % 2 ? "Inactive" : "Active"}</div>
// </td>
// <td>
// <div className="actions">
// <div className="ellipse" onClick={() => toggleMenu(index)}>
// <Image alt="" width={20} height={20} src="/images/vendor/icon-more-vertical.svg" />
// </div>
// {showMenuIndex === index && (
// <div className="menu">
// <ul>
// <li>View</li>
// <li>Deactivate</li>
// <li>Delete</li>
// </ul>
// </div>
// )}
// </div>
// </td>
// </tr>
// ))}
// <tr>
// <td colSpan={7}>Showing Results 10 of 1567</td>
// </tr>
// </tbody>
// </Table>
// </div>
// </div>
// </div>
// )}
// {vendorId && showVendorDetails && <VendorDetails id={vendorId} backClick={handleCloseVendorDetails} />}
// </Fragment>
); );
}; };
......
...@@ -9,16 +9,16 @@ import { loadUser, updateActivityStatusAdmin } from "../../redux/actions/userAct ...@@ -9,16 +9,16 @@ import { loadUser, updateActivityStatusAdmin } from "../../redux/actions/userAct
import { Modal } from "react-bootstrap"; import { Modal } from "react-bootstrap";
import { toast } from "react-toastify"; import { toast } from "react-toastify";
const onChange = (pagination, filters, sorter, extra) => { // const onChange = (pagination, filters, sorter, extra) => {
console.log("params", pagination, filters, sorter, extra); // console.log("params", pagination, filters, sorter, extra);
}; // };
export const ActivityListingRBAC = ({ setactivityDetailInfo, setShowActivityDetailsModal }) => { export const ActivityListingRBAC = ({ setactivityDetailInfo, setShowActivityDetailsModal, onChange, tableCurrentPage, tableItemsPerPage }) => {
const router = useRouter(); const router = useRouter();
const dispatch = useDispatch(); const dispatch = useDispatch();
// let columns = [] // let columns = []
// useSelectors // useSelectors
const { allActivitiesData } = useSelector(state => state.allActivitiesData); const { allActivitiesData, loading, totalCount } = useSelector(state => state.allActivitiesData);
const { loadedUser } = useSelector(state => state.loadedUser); const { loadedUser } = useSelector(state => state.loadedUser);
const { categories } = useSelector(state => state.categories); const { categories } = useSelector(state => state.categories);
const { subCategories } = useSelector(state => state.subCategories); const { subCategories } = useSelector(state => state.subCategories);
...@@ -431,7 +431,18 @@ export const ActivityListingRBAC = ({ setactivityDetailInfo, setShowActivityDeta ...@@ -431,7 +431,18 @@ export const ActivityListingRBAC = ({ setactivityDetailInfo, setShowActivityDeta
}; };
return ( return (
<div className="p-5"> <div className="p-5">
<Table rowSelection={rowSelection} columns={columns} dataSource={data} onChange={onChange} /> <Table
loading={loading}
rowSelection={rowSelection}
columns={columns}
dataSource={data}
onChange={onChange}
pagination={{
current: tableCurrentPage,
pageSize: tableItemsPerPage,
total: totalCount
}}
/>
<Modal <Modal
show={rejectPopUp} show={rejectPopUp}
onHide={() => { onHide={() => {
......
...@@ -21,8 +21,19 @@ export default function ActivityListingPage() { ...@@ -21,8 +21,19 @@ export default function ActivityListingPage() {
const dispatch = useDispatch(); const dispatch = useDispatch();
useEffect(() => { useEffect(() => {
dispatch(getActivitiesForAdmin({})); dispatch(getActivitiesForAdmin({ pageNumber: 1 }));
}, []); }, []);
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(getActivitiesForAdmin({ pageNumber: pagination.current, pageSize: pagination.pageSize }));
};
return ( return (
<GenericLayout> <GenericLayout>
{/* <Layout> */} {/* <Layout> */}
...@@ -30,10 +41,14 @@ export default function ActivityListingPage() { ...@@ -30,10 +41,14 @@ export default function ActivityListingPage() {
{/* <Sidebar /> */} {/* <Sidebar /> */}
{/* <div className="content"> */} {/* <div className="content"> */}
{/* <ActivityListing /> */} {/* <ActivityListing /> */}
<ActivityListingRBAC setactivityDetailInfo={setactivityDetailInfo} setShowActivityDetailsModal={setShowActivityDetailsModal} /> <ActivityListingRBAC
{showActivityDetailsModal && ( setactivityDetailInfo={setactivityDetailInfo}
<ActivityDetailsModal show={showActivityDetailsModal} handleClose={handleCloseActivityDetails} activityDetailInfo={activityDetailInfo} /> setShowActivityDetailsModal={setShowActivityDetailsModal}
)} onChange={onChange}
tableCurrentPage={tableCurrentPage}
tableItemsPerPage={tableItemsPerPage}
/>
{showActivityDetailsModal && <ActivityDetailsModal show={showActivityDetailsModal} handleClose={handleCloseActivityDetails} activityDetailInfo={activityDetailInfo} />}
{/* </div> */} {/* </div> */}
{/* </div> */} {/* </div> */}
{/* </Layout> */} {/* </Layout> */}
......
...@@ -29,7 +29,6 @@ export default ReviewsPage; ...@@ -29,7 +29,6 @@ export default ReviewsPage;
export const getServerSideProps = wrapper.getServerSideProps(store => async ({ req, query }) => { export const getServerSideProps = wrapper.getServerSideProps(store => async ({ req, query }) => {
// await store.dispatch(loadUser()); // await store.dispatch(loadUser());
await store.dispatch(getActivitiesByFilters({})); await store.dispatch(getActivitiesByFilters({}));
// await store.dispatch(getAllVendors());
// await store.dispatch(loadUser()); // await store.dispatch(loadUser());
// await store.dispatch(getActivitiesByVendor()); // await store.dispatch(getActivitiesByVendor());
// await store.dispatch(getAllCategories()); // await store.dispatch(getAllCategories());
......
...@@ -3,7 +3,6 @@ import Layout from "../../../components/layout/Layout"; ...@@ -3,7 +3,6 @@ import Layout from "../../../components/layout/Layout";
import Sidebar from "../../../components/layout/AdminDashboardSidebar"; import Sidebar from "../../../components/layout/AdminDashboardSidebar";
import VendorListing from "../../../components/admin/VendorListing"; import VendorListing from "../../../components/admin/VendorListing";
import { wrapper } from "../../../redux/store"; import { wrapper } from "../../../redux/store";
import { getAllVendors } from "../../../redux/actions/vendorActions";
import { loadUser } from "../../../redux/actions/userActions"; import { loadUser } from "../../../redux/actions/userActions";
import { getAllCategories, getAllSubCategories } from "../../../redux/actions/categoriesAction"; import { getAllCategories, getAllSubCategories } from "../../../redux/actions/categoriesAction";
import { GenericLayout } from "../../../components/layout/Generics/GenericLayout"; import { GenericLayout } from "../../../components/layout/Generics/GenericLayout";
...@@ -29,7 +28,6 @@ export default function VendorListingPage() { ...@@ -29,7 +28,6 @@ export default function VendorListingPage() {
// // get the locations data. // // get the locations data.
// await store.dispatch(loadUser()); // await store.dispatch(loadUser());
// await store.dispatch(getAllVendors());
// return { // return {
// props: {} // props: {}
...@@ -39,7 +37,6 @@ export default function VendorListingPage() { ...@@ -39,7 +37,6 @@ export default function VendorListingPage() {
/** For server side rendering */ /** For server side rendering */
export const getServerSideProps = wrapper.getServerSideProps(store => async ({ req, query }) => { export const getServerSideProps = wrapper.getServerSideProps(store => async ({ req, query }) => {
// await store.dispatch(loadUser()); // await store.dispatch(loadUser());
// await store.dispatch(getAllVendors());
await store.dispatch(loadUser()); await store.dispatch(loadUser());
// await store.dispatch(getActivitiesByVendor()); // await store.dispatch(getActivitiesByVendor());
await store.dispatch(getAllCategories()); await store.dispatch(getAllCategories());
......
...@@ -6,7 +6,6 @@ import React from "react"; ...@@ -6,7 +6,6 @@ import React from "react";
// import { ToastContainer } from "react-bootstrap"; // import { ToastContainer } from "react-bootstrap";
import Sidebar from "../../../components/layout/VendorDashboardSidebar"; import Sidebar from "../../../components/layout/VendorDashboardSidebar";
import ActivityDetails from "../../../components/vendor/ActivityDetails"; import ActivityDetails from "../../../components/vendor/ActivityDetails";
import ActivityListingRBAC from "../../../components/vendor/ActivityListingRBAC";
import UpdateActivity from "../../../components/vendor/UpdateActivity"; import UpdateActivity from "../../../components/vendor/UpdateActivity";
import { getActivitiesByVendor, getActivityById } from "../../../redux/actions/activityAction"; import { getActivitiesByVendor, getActivityById } from "../../../redux/actions/activityAction";
import { getAllCategories, getAllSubCategories } from "../../../redux/actions/categoriesAction"; import { getAllCategories, getAllSubCategories } from "../../../redux/actions/categoriesAction";
...@@ -19,17 +18,6 @@ const EditActivityDetail = () => { ...@@ -19,17 +18,6 @@ const EditActivityDetail = () => {
<GenericLayout> <GenericLayout>
<ActivityDetails isUpdate={true} /> <ActivityDetails isUpdate={true} />
</GenericLayout> </GenericLayout>
// <Layout>
// <ToastContainer position="bottom-right"></ToastContainer>
// <div className="sidebarContainer">
// <Sidebar />
// <div className="content">
// <ActivityListingRBAC />
// <ActivityDetails isUpdate={true} />
// <UpdateActivity />
// </div>
// </div>
// </Layout>
); );
}; };
......
...@@ -16,15 +16,24 @@ export default function ActivityListingPage() { ...@@ -16,15 +16,24 @@ export default function ActivityListingPage() {
const dispatch = useDispatch(); const dispatch = useDispatch();
useEffect(() => { useEffect(() => {
dispatch(getActivitiesByVendor()); dispatch(getActivitiesByVendor());
dispatch(loadUser()) dispatch(loadUser());
}, []); }, []);
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());
};
return ( return (
<GenericLayout> <GenericLayout>
{/* <div className="sidebarContainer"> {/* <div className="sidebarContainer">
<Sidebar /> <Sidebar />
<div className="content"> */} <div className="content"> */}
<ActivityListingRBAC /> <ActivityListingRBAC onChange={onChange} tableCurrentPage={tableCurrentPage} tableItemsPerPage={tableItemsPerPage} />
{/* </div> {/* </div>
</div> */} </div> */}
</GenericLayout> </GenericLayout>
......
...@@ -31,7 +31,6 @@ export default ReviewsPage; ...@@ -31,7 +31,6 @@ export default ReviewsPage;
export const getServerSideProps = wrapper.getServerSideProps(store => async ({ req, query }) => { export const getServerSideProps = wrapper.getServerSideProps(store => async ({ req, query }) => {
// await store.dispatch(loadUser()); // await store.dispatch(loadUser());
// await store.dispatch(getActivitiesByVendor()); // await store.dispatch(getActivitiesByVendor());
// await store.dispatch(getAllVendors());
// await store.dispatch(loadUser()); // await store.dispatch(loadUser());
// await store.dispatch(getActivitiesByVendor()); // await store.dispatch(getActivitiesByVendor());
// await store.dispatch(getAllCategories()); // await store.dispatch(getAllCategories());
......
...@@ -61,7 +61,9 @@ export const createActivity = data => async dispatch => { ...@@ -61,7 +61,9 @@ export const createActivity = data => async dispatch => {
} }
}; };
export const getActivitiesByVendor = () => async dispatch => { export const getActivitiesByVendor =
() =>
async dispatch => {
// console.log("data", data); // console.log("data", data);
const session = await getSession(); const session = await getSession();
console.log("session", session); console.log("session", session);
...@@ -113,7 +115,8 @@ export const getActivitiesByVendor = () => async dispatch => { ...@@ -113,7 +115,8 @@ export const getActivitiesByVendor = () => async dispatch => {
} }
}, },
pagination: { pagination: {
pageSize: 1000 pageSize: 1000,
// page: pageNumber
}, },
populate: [ populate: [
"masterMonths", "masterMonths",
...@@ -153,7 +156,7 @@ export const getActivitiesByVendor = () => async dispatch => { ...@@ -153,7 +156,7 @@ export const getActivitiesByVendor = () => async dispatch => {
payload: error.response.data payload: error.response.data
}); });
} }
}; };
export const getActivityById = id => async dispatch => { export const getActivityById = id => async dispatch => {
try { try {
...@@ -250,7 +253,7 @@ export const updateActivityById = ...@@ -250,7 +253,7 @@ export const updateActivityById =
}; };
export const getActivitiesForAdmin = export const getActivitiesForAdmin =
({ vendorId }) => ({ vendorId, pageNumber = 1, pageSize = 10 }) =>
async dispatch => { async dispatch => {
try { try {
dispatch({ dispatch({
...@@ -274,10 +277,11 @@ export const getActivitiesForAdmin = ...@@ -274,10 +277,11 @@ export const getActivitiesForAdmin =
} }
}, },
pagination: { pagination: {
pageSize: 1000 pageSize: pageSize,
page: pageNumber
}, },
populate: [ populate: [
"masterMonths", // "masterMonths",
"subCategory", "subCategory",
"subCategory.category", "subCategory.category",
"timeSlots", "timeSlots",
...@@ -286,7 +290,7 @@ export const getActivitiesForAdmin = ...@@ -286,7 +290,7 @@ export const getActivitiesForAdmin =
"category", "category",
"imagesComponent", "imagesComponent",
"imagesComponent.image", "imagesComponent.image",
"image", // "image",
"termsConditions", "termsConditions",
"cancellationPolicy", "cancellationPolicy",
"reviews" "reviews"
...@@ -303,7 +307,7 @@ export const getActivitiesForAdmin = ...@@ -303,7 +307,7 @@ export const getActivitiesForAdmin =
// }; // };
const response = await axios.get(`${process.env.NEXT_PUBLIC_BACKEND_API_URL}/api/experiences?${queryString}`, config); const response = await axios.get(`${process.env.NEXT_PUBLIC_BACKEND_API_URL}/api/experiences?${queryString}`, config);
// console.log("Response", response.data); console.log("Response", response.data);
dispatch({ dispatch({
type: GET_ACTIVITIES_SUCCESS, type: GET_ACTIVITIES_SUCCESS,
payload: response.data payload: response.data
......
...@@ -137,7 +137,7 @@ export const getLoggedInVendor = () => async dispatch => { ...@@ -137,7 +137,7 @@ export const getLoggedInVendor = () => async dispatch => {
export const getVendorDetails = () => async dispatch => { export const getVendorDetails = () => async dispatch => {
const session = await getSession(); const session = await getSession();
if (!session) { if (!session) {
return return;
} }
try { try {
dispatch({ dispatch({
...@@ -187,7 +187,9 @@ export const getVendorDetails = () => async dispatch => { ...@@ -187,7 +187,9 @@ export const getVendorDetails = () => async dispatch => {
} }
}; };
export const getAllVendors = () => async dispatch => { export const getAllVendors =
({ pageNumber = 1, pageSize = 10 }) =>
async dispatch => {
const session = await getSession(); const session = await getSession();
try { try {
dispatch({ dispatch({
...@@ -201,7 +203,6 @@ export const getAllVendors = () => async dispatch => { ...@@ -201,7 +203,6 @@ export const getAllVendors = () => async dispatch => {
Authorization: `Bearer ${session.jwt}` Authorization: `Bearer ${session.jwt}`
} }
}; };
// console.log("here 2");
if (!session) { if (!session) {
return; return;
} }
...@@ -214,19 +215,25 @@ export const getAllVendors = () => async dispatch => { ...@@ -214,19 +215,25 @@ export const getAllVendors = () => async dispatch => {
// } // }
// }, // },
populate: ["user", "experiences", "brandLogo"], populate: ["user", "experiences", "brandLogo"],
sort: ["createdAt:desc"] sort: ["createdAt:desc"],
pagination: {
pageSize: pageSize,
page: pageNumber
}
}; };
// console.log("here 3", query); // console.log("here 3", query);
const queryString = qs.stringify(query, { const queryString = qs.stringify(query, {
encodeValuesOnly: true encodeValuesOnly: true
}); });
console.log("session", session, session.id); // console.log("session", session, session.id);
const response = await axios.get(`${process.env.NEXT_PUBLIC_BACKEND_API_URL}/api/vendors/?${queryString}`, config); const response = await axios.get(`${process.env.NEXT_PUBLIC_BACKEND_API_URL}/api/vendors/?${queryString}`, config);
console.log("response", response); console.log("response", response);
dispatch({ dispatch({
type: GET_ALL_VENDORS_SUCCESS, type: GET_ALL_VENDORS_SUCCESS,
payload: response.data.data payload: response.data.data,
totalCount: response.data.meta.pagination.total,
resultsPerPage: response.data.meta.pagination.pageSize
}); });
return response.data.data[0]; return response.data.data[0];
...@@ -236,4 +243,4 @@ export const getAllVendors = () => async dispatch => { ...@@ -236,4 +243,4 @@ export const getAllVendors = () => async dispatch => {
payload: error.response.data payload: error.response.data
}); });
} }
}; };
import { UPDATE_VENDOR_DETAILS_FAIL, UPDATE_VENDOR_DETAILS_REQUEST, UPDATE_VENDOR_DETAILS_SUCCESS, CLEAR_ERRORS, GET_LOGGED_IN_VENDOR_REQUEST, GET_LOGGED_IN_VENDOR_SUCCESS, GET_LOGGED_IN_VENDOR_FAIL, GET_VENDOR_DETAILS_FAIL, GET_VENDOR_DETAILS_SUCCESS, GET_VENDOR_DETAILS_REQUEST, GET_ALL_VENDORS_REQUEST, GET_ALL_VENDORS_SUCCESS, GET_ALL_VENDORS_FAIL } from "../constants/vendorConstants"; import {
UPDATE_VENDOR_DETAILS_FAIL,
UPDATE_VENDOR_DETAILS_REQUEST,
UPDATE_VENDOR_DETAILS_SUCCESS,
CLEAR_ERRORS,
GET_LOGGED_IN_VENDOR_REQUEST,
GET_LOGGED_IN_VENDOR_SUCCESS,
GET_LOGGED_IN_VENDOR_FAIL,
GET_VENDOR_DETAILS_FAIL,
GET_VENDOR_DETAILS_SUCCESS,
GET_VENDOR_DETAILS_REQUEST,
GET_ALL_VENDORS_REQUEST,
GET_ALL_VENDORS_SUCCESS,
GET_ALL_VENDORS_FAIL
} from "../constants/vendorConstants";
// Load user reducer // Load user reducer
export const loggedInVendorReducer = (state = { loading: true, success: false, loggedInVendor: null }, action) => { export const loggedInVendorReducer = (state = { loading: true, success: false, loggedInVendor: null }, action) => {
...@@ -100,13 +113,15 @@ export const getAllVendorsReducer = (state = { loading: true, success: false, al ...@@ -100,13 +113,15 @@ export const getAllVendorsReducer = (state = { loading: true, success: false, al
switch (action.type) { switch (action.type) {
case GET_ALL_VENDORS_REQUEST: case GET_ALL_VENDORS_REQUEST:
return { return {
loading: true, loading: true
}; };
case GET_ALL_VENDORS_SUCCESS: case GET_ALL_VENDORS_SUCCESS:
return { return {
loading: false, loading: false,
allVendors: action.payload allVendors: action.payload,
totalCount: action.totalCount,
resultsPerPage: action.resultsPerPage
}; };
case GET_ALL_VENDORS_FAIL: case GET_ALL_VENDORS_FAIL:
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!