Commit 395e7636 by jaymehta

.

1 parent 9d3f8c00
import { Empty, Modal } from "antd"
import Image from "next/image"
import { cleanImage } from '../../services/imageHandling.js'
import { Empty, Modal } from "antd";
import { cleanImage } from "../../services/imageHandling.js";
const ActivityDetailGallaryModal = ({ activityDetailInfo }) => {
return (
<>
return (
<>
{activityDetailInfo[0].attributes.imagesComponent.length > 0 ? (
<div className="p-4">
<div className="row">
{activityDetailInfo[0].attributes.imagesComponent.map((data, index) => (
<div className="col-4" key={index}>
<img className="img-fluid" height={400} width={400} alt="" src={cleanImage(data.image.data?.attributes)} />
</div>
))}
</div>
</div>
) : (
<div className="d-flex align-items-center justify-content-center" style={{ height: "60vh" }}>
<Empty image={Empty.PRESENTED_IMAGE_SIMPLE} />
</div>
)}
</>
);
};
{activityDetailInfo[0].attributes.imagesComponent.length > 0 ?
<div className="p-4">
<div className="row">
{activityDetailInfo[0].attributes.imagesComponent.map((data, index) => (
<div className="col-4" key={index}>
<Image className="img-fluid" height={400} width={400} alt="" src={cleanImage(data.image.data.attributes)} />
</div>
))}
</div>
</div>
:
<div className="d-flex align-items-center justify-content-center" style={{height : '60vh'}}>
<Empty image={Empty.PRESENTED_IMAGE_SIMPLE} />
</div>
}
</>
)
}
export default ActivityDetailGallaryModal
\ No newline at end of file
export default ActivityDetailGallaryModal;
......@@ -154,7 +154,7 @@ const ActivityDetailsModal = ({ show, handleClose, activityDetailInfo }) => {
<div className="col-12 col-lg-6 ">
<p
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
</p>
......@@ -168,7 +168,7 @@ const ActivityDetailsModal = ({ show, handleClose, activityDetailInfo }) => {
</div>
<div className="col-12 col-lg-6">
<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
</p>
......
......@@ -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 });
console.log(response.data);
await dispatch(getAllVendors());
await dispatch(getAllVendors({}));
handleClose()
setShowDetail(false);
}}
......
......@@ -6,7 +6,7 @@ import Image from "next/image";
import RejectModal from "./RejectModal";
import ActivityListingRBAC from "../vendor/ActivityListingRBAC";
import { useDispatch, useSelector } from "react-redux";
import { getActivitiesByVendor, getActivitiesForAdmin } from "../../redux/actions/activityAction";
import { getActivitiesForAdmin } from "../../redux/actions/activityAction";
import { Tag } from "antd";
import { updateApprovalStatusAdmin } from "../../redux/actions/userActions";
import { getAllVendors } from "../../redux/actions/vendorActions";
......@@ -25,6 +25,16 @@ const VendorDetails = ({ id, backClick, setShowDetail, showDetail, detail }) =>
dispatch(getActivitiesForAdmin({ vendorId: detail[0].id }));
}, [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);
const [showActivityDetailsModal, setShowActivityDetailsModal] = useState(false);
const [showRejectModal, setShowRejectModal] = useState(false);
......@@ -157,7 +167,7 @@ const VendorDetails = ({ id, backClick, setShowDetail, showDetail, detail }) =>
onClick={async () => {
await updateApprovalStatusAdmin({ status: "approved", userId: detail[0].attributes.user.data.id });
toast.success("User approved");
await dispatch(getAllVendors());
await dispatch(getAllVendors({}));
}}
>
Approve
......@@ -175,7 +185,13 @@ const VendorDetails = ({ id, backClick, setShowDetail, showDetail, detail }) =>
</div>
<div className="col-12 col-lg-12 mt-4">
<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>
......
......@@ -25,7 +25,7 @@ const VendorListing = () => {
// selectors
const { loadedUser } = useSelector(state => state.loadedUser);
const { allVendors } = useSelector(state => state.allVendors);
const { allVendors, loading: vendorLoading, totalCount } = useSelector(state => state.allVendors);
const toggleMenu = index => {
setShowMenuIndex(index === showMenuIndex ? null : index);
};
......@@ -63,9 +63,19 @@ const VendorListing = () => {
useEffect(() => {
if (!loadedUser) return;
dispatch(getAllVendors());
dispatch(getAllVendors({ pageNumber: 1, pageSize: 10 }));
}, [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);
const [vendorId, setVendorId] = useState(null);
const [showVendorDetails, setShowVendorDetails] = useState(false);
......@@ -190,7 +200,17 @@ const VendorListing = () => {
) : (
<div>
{!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 />
<VendorDetails setShowDetail={setShowDetail} showDetail={showDetail} detail={detail} />
......@@ -201,96 +221,6 @@ const VendorListing = () => {
</div>
</div>
</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
import { Modal } from "react-bootstrap";
import { toast } from "react-toastify";
const onChange = (pagination, filters, sorter, extra) => {
console.log("params", pagination, filters, sorter, extra);
};
// const onChange = (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 dispatch = useDispatch();
// let columns = []
// useSelectors
const { allActivitiesData } = useSelector(state => state.allActivitiesData);
const { allActivitiesData, loading, totalCount } = useSelector(state => state.allActivitiesData);
const { loadedUser } = useSelector(state => state.loadedUser);
const { categories } = useSelector(state => state.categories);
const { subCategories } = useSelector(state => state.subCategories);
......@@ -431,7 +431,18 @@ export const ActivityListingRBAC = ({ setactivityDetailInfo, setShowActivityDeta
};
return (
<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
show={rejectPopUp}
onHide={() => {
......
......@@ -21,22 +21,37 @@ export default function ActivityListingPage() {
const dispatch = useDispatch();
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 (
<GenericLayout>
{/* <Layout> */}
{/* <div className="sidebarContainer"> */}
{/* <Sidebar /> */}
{/* <div className="content"> */}
{/* <ActivityListing /> */}
<ActivityListingRBAC setactivityDetailInfo={setactivityDetailInfo} setShowActivityDetailsModal={setShowActivityDetailsModal} />
{showActivityDetailsModal && (
<ActivityDetailsModal show={showActivityDetailsModal} handleClose={handleCloseActivityDetails} activityDetailInfo={activityDetailInfo} />
)}
{/* </div> */}
{/* </div> */}
{/* </Layout> */}
{/* <Layout> */}
{/* <div className="sidebarContainer"> */}
{/* <Sidebar /> */}
{/* <div className="content"> */}
{/* <ActivityListing /> */}
<ActivityListingRBAC
setactivityDetailInfo={setactivityDetailInfo}
setShowActivityDetailsModal={setShowActivityDetailsModal}
onChange={onChange}
tableCurrentPage={tableCurrentPage}
tableItemsPerPage={tableItemsPerPage}
/>
{showActivityDetailsModal && <ActivityDetailsModal show={showActivityDetailsModal} handleClose={handleCloseActivityDetails} activityDetailInfo={activityDetailInfo} />}
{/* </div> */}
{/* </div> */}
{/* </Layout> */}
</GenericLayout>
);
}
......
......@@ -29,7 +29,6 @@ export default ReviewsPage;
export const getServerSideProps = wrapper.getServerSideProps(store => async ({ req, query }) => {
// await store.dispatch(loadUser());
await store.dispatch(getActivitiesByFilters({}));
// await store.dispatch(getAllVendors());
// await store.dispatch(loadUser());
// await store.dispatch(getActivitiesByVendor());
// await store.dispatch(getAllCategories());
......
......@@ -3,7 +3,6 @@ import Layout from "../../../components/layout/Layout";
import Sidebar from "../../../components/layout/AdminDashboardSidebar";
import VendorListing from "../../../components/admin/VendorListing";
import { wrapper } from "../../../redux/store";
import { getAllVendors } from "../../../redux/actions/vendorActions";
import { loadUser } from "../../../redux/actions/userActions";
import { getAllCategories, getAllSubCategories } from "../../../redux/actions/categoriesAction";
import { GenericLayout } from "../../../components/layout/Generics/GenericLayout";
......@@ -29,7 +28,6 @@ export default function VendorListingPage() {
// // get the locations data.
// await store.dispatch(loadUser());
// await store.dispatch(getAllVendors());
// return {
// props: {}
......@@ -39,7 +37,6 @@ export default function VendorListingPage() {
/** For server side rendering */
export const getServerSideProps = wrapper.getServerSideProps(store => async ({ req, query }) => {
// await store.dispatch(loadUser());
// await store.dispatch(getAllVendors());
await store.dispatch(loadUser());
// await store.dispatch(getActivitiesByVendor());
await store.dispatch(getAllCategories());
......
......@@ -6,7 +6,6 @@ import React from "react";
// import { ToastContainer } from "react-bootstrap";
import Sidebar from "../../../components/layout/VendorDashboardSidebar";
import ActivityDetails from "../../../components/vendor/ActivityDetails";
import ActivityListingRBAC from "../../../components/vendor/ActivityListingRBAC";
import UpdateActivity from "../../../components/vendor/UpdateActivity";
import { getActivitiesByVendor, getActivityById } from "../../../redux/actions/activityAction";
import { getAllCategories, getAllSubCategories } from "../../../redux/actions/categoriesAction";
......@@ -19,17 +18,6 @@ const EditActivityDetail = () => {
<GenericLayout>
<ActivityDetails isUpdate={true} />
</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() {
const dispatch = useDispatch();
useEffect(() => {
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 (
<GenericLayout>
{/* <div className="sidebarContainer">
<Sidebar />
<div className="content"> */}
<ActivityListingRBAC />
<ActivityListingRBAC onChange={onChange} tableCurrentPage={tableCurrentPage} tableItemsPerPage={tableItemsPerPage} />
{/* </div>
</div> */}
</GenericLayout>
......
......@@ -31,7 +31,6 @@ export default ReviewsPage;
export const getServerSideProps = wrapper.getServerSideProps(store => async ({ req, query }) => {
// await store.dispatch(loadUser());
// await store.dispatch(getActivitiesByVendor());
// await store.dispatch(getAllVendors());
// await store.dispatch(loadUser());
// await store.dispatch(getActivitiesByVendor());
// await store.dispatch(getAllCategories());
......
......@@ -61,99 +61,102 @@ export const createActivity = data => async dispatch => {
}
};
export const getActivitiesByVendor = () => async dispatch => {
// console.log("data", data);
const session = await getSession();
console.log("session", session);
try {
const vendorConfig = {
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${session.jwt}`
}
};
const vendorQuery = {
filters: {
user: {
id: { $eq: session.id }
export const getActivitiesByVendor =
() =>
async dispatch => {
// console.log("data", data);
const session = await getSession();
console.log("session", session);
try {
const vendorConfig = {
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${session.jwt}`
}
}
};
const vendorQueryString = qs.stringify(vendorQuery, {
encodeValuesOnly: true
});
};
const vendorQuery = {
filters: {
user: {
id: { $eq: session.id }
}
}
};
const vendorResponse = await axios.get(`${process.env.NEXT_PUBLIC_BACKEND_API_URL}/api/vendors/?${vendorQueryString}`, vendorConfig);
const vendorQueryString = qs.stringify(vendorQuery, {
encodeValuesOnly: true
});
console.log("vendorResponse", vendorResponse.data.data[0].id);
// const loggedinVendor = await getLoggedInVendor()
// console.log("loggedinVendor", loggedinVendor);
if (!session) {
return "You are not authenticated, please log in.";
}
dispatch({
type: GET_ACTIVITIES_REQUEST,
loading: true
});
const vendorResponse = await axios.get(`${process.env.NEXT_PUBLIC_BACKEND_API_URL}/api/vendors/?${vendorQueryString}`, vendorConfig);
const config = {
headers: {
"Content-Type": "application/json"
// Authorization: `Bearer ${session.jwt}`
console.log("vendorResponse", vendorResponse.data.data[0].id);
// const loggedinVendor = await getLoggedInVendor()
// console.log("loggedinVendor", loggedinVendor);
if (!session) {
return "You are not authenticated, please log in.";
}
};
dispatch({
type: GET_ACTIVITIES_REQUEST,
loading: true
});
const query = {
filters: {
vendor: {
id: {
$eq: vendorResponse.data.data[0].id
}
const config = {
headers: {
"Content-Type": "application/json"
// Authorization: `Bearer ${session.jwt}`
}
},
pagination: {
pageSize: 1000
},
populate: [
"masterMonths",
"subCategory",
"subCategory.category",
"timeSlots",
"masterPincode",
"vendor",
"category",
"imagesComponent",
"imagesComponent.image",
"image",
"termsConditions",
"cancellationPolicy",
"reviews"
]
};
const queryString = qs.stringify(query, {
encodeValuesOnly: true
});
// let activityData = {
// data: {
// ...data
// }
// };
console.log(query);
const response = await axios.get(`${process.env.NEXT_PUBLIC_BACKEND_API_URL}/api/experiences?${queryString}`, config);
console.log("Response", response.data);
dispatch({
type: GET_ACTIVITIES_SUCCESS,
payload: response.data
});
return response.data;
} catch (error) {
dispatch({
type: GET_ACTIVITIES_FAIL,
payload: error.response.data
});
}
};
};
const query = {
filters: {
vendor: {
id: {
$eq: vendorResponse.data.data[0].id
}
}
},
pagination: {
pageSize: 1000,
// page: pageNumber
},
populate: [
"masterMonths",
"subCategory",
"subCategory.category",
"timeSlots",
"masterPincode",
"vendor",
"category",
"imagesComponent",
"imagesComponent.image",
"image",
"termsConditions",
"cancellationPolicy",
"reviews"
]
};
const queryString = qs.stringify(query, {
encodeValuesOnly: true
});
// let activityData = {
// data: {
// ...data
// }
// };
console.log(query);
const response = await axios.get(`${process.env.NEXT_PUBLIC_BACKEND_API_URL}/api/experiences?${queryString}`, config);
console.log("Response", response.data);
dispatch({
type: GET_ACTIVITIES_SUCCESS,
payload: response.data
});
return response.data;
} catch (error) {
dispatch({
type: GET_ACTIVITIES_FAIL,
payload: error.response.data
});
}
};
export const getActivityById = id => async dispatch => {
try {
......@@ -250,7 +253,7 @@ export const updateActivityById =
};
export const getActivitiesForAdmin =
({ vendorId }) =>
({ vendorId, pageNumber = 1, pageSize = 10 }) =>
async dispatch => {
try {
dispatch({
......@@ -274,10 +277,11 @@ export const getActivitiesForAdmin =
}
},
pagination: {
pageSize: 1000
pageSize: pageSize,
page: pageNumber
},
populate: [
"masterMonths",
// "masterMonths",
"subCategory",
"subCategory.category",
"timeSlots",
......@@ -286,7 +290,7 @@ export const getActivitiesForAdmin =
"category",
"imagesComponent",
"imagesComponent.image",
"image",
// "image",
"termsConditions",
"cancellationPolicy",
"reviews"
......@@ -303,7 +307,7 @@ export const getActivitiesForAdmin =
// };
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({
type: GET_ACTIVITIES_SUCCESS,
payload: response.data
......
......@@ -137,7 +137,7 @@ export const getLoggedInVendor = () => async dispatch => {
export const getVendorDetails = () => async dispatch => {
const session = await getSession();
if (!session) {
return
return;
}
try {
dispatch({
......@@ -187,53 +187,60 @@ export const getVendorDetails = () => async dispatch => {
}
};
export const getAllVendors = () => async dispatch => {
const session = await getSession();
try {
dispatch({
type: GET_ALL_VENDORS_REQUEST
});
export const getAllVendors =
({ pageNumber = 1, pageSize = 10 }) =>
async dispatch => {
const session = await getSession();
try {
dispatch({
type: GET_ALL_VENDORS_REQUEST
});
// console.log("here 1", session);
const config = {
headers: {
"Content-Type": "Application/json",
Authorization: `Bearer ${session.jwt}`
// console.log("here 1", session);
const config = {
headers: {
"Content-Type": "Application/json",
Authorization: `Bearer ${session.jwt}`
}
};
if (!session) {
return;
}
};
// console.log("here 2");
if (!session) {
return;
}
const query = {
// filters: {
// user: {
// id: {
// $eq: session.id
// }
// }
// },
populate: ["user", "experiences", "brandLogo"],
sort: ["createdAt:desc"]
};
// console.log("here 3", query);
const query = {
// filters: {
// user: {
// id: {
// $eq: session.id
// }
// }
// },
populate: ["user", "experiences", "brandLogo"],
sort: ["createdAt:desc"],
pagination: {
pageSize: pageSize,
page: pageNumber
}
};
// console.log("here 3", query);
const queryString = qs.stringify(query, {
encodeValuesOnly: true
});
console.log("session", session, session.id);
const response = await axios.get(`${process.env.NEXT_PUBLIC_BACKEND_API_URL}/api/vendors/?${queryString}`, config);
console.log("response", response);
dispatch({
type: GET_ALL_VENDORS_SUCCESS,
payload: response.data.data
});
const queryString = qs.stringify(query, {
encodeValuesOnly: true
});
// console.log("session", session, session.id);
const response = await axios.get(`${process.env.NEXT_PUBLIC_BACKEND_API_URL}/api/vendors/?${queryString}`, config);
console.log("response", response);
dispatch({
type: GET_ALL_VENDORS_SUCCESS,
payload: response.data.data,
totalCount: response.data.meta.pagination.total,
resultsPerPage: response.data.meta.pagination.pageSize
});
return response.data.data[0];
} catch (error) {
dispatch({
type: GET_ALL_VENDORS_FAIL,
payload: error.response.data
});
}
};
return response.data.data[0];
} catch (error) {
dispatch({
type: GET_ALL_VENDORS_FAIL,
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
export const loggedInVendorReducer = (state = { loading: true, success: false, loggedInVendor: null }, action) => {
......@@ -100,13 +113,15 @@ export const getAllVendorsReducer = (state = { loading: true, success: false, al
switch (action.type) {
case GET_ALL_VENDORS_REQUEST:
return {
loading: true,
loading: true
};
case GET_ALL_VENDORS_SUCCESS:
return {
loading: false,
allVendors: action.payload
allVendors: action.payload,
totalCount: action.totalCount,
resultsPerPage: action.resultsPerPage
};
case GET_ALL_VENDORS_FAIL:
......@@ -124,4 +139,4 @@ export const getAllVendorsReducer = (state = { loading: true, success: false, al
default:
return state;
}
};
\ No newline at end of file
};
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!