Commit 61d982d8 by jaymehta

enquiries

1 parent 2fb6bccd
......@@ -95,57 +95,59 @@ const DetailGallery = ({ activityById }) => {
</div>
</div>
<div className="row hide-on-mobile">
<div className="col-12">
<ul className="availability-wrappper">
<li>
<span className="image-container">
<Image layout="fill" alt="" className="image img-fluid" src="/images/availability/month.svg" />
</span>
From: {activityById.data.attributes.fromDate} To: {activityById.data.attributes.toDate}
</li>
<li>
<span className="image-container">
<Image layout="fill" alt="" className="image img-fluid" src="/images/availability/time.svg" />
</span>
Time: {activityById.data.attributes.fromTime} - {activityById.data.attributes.toTime}
</li>
<li>
<span className="image-container">
<Image layout="fill" alt="" className="image img-fluid" src="/images/availability/duration.svg" />
</span>
Duration: {activityById.data.attributes.minimumDuration}-{activityById.data.attributes.maximumDuration} Hours
</li>
<li>
<span className="image-container">
<Image layout="fill" alt="" className="image img-fluid" src="/images/availability/contact.svg" />
</span>
Contact: {activityById.data.attributes.phoneNumber}
</li>
<li>
<span className="image-container">
<Image layout="fill" alt="" className="image img-fluid" src="/images/availability/date.svg" />
</span>
Active on:{" "}
{returnAvilablleDaysArray({ data: activityById.data })
.map(item => {
return item.name;
})
.join(", ")}
</li>
<li>
<span className="image-container">
<Image layout="fill" alt="" className="image img-fluid" src="/images/availability/age.svg" />
</span>
Age: {activityById.data.attributes.ageLowerLimit}+
<div className="info-div">
<a className="image-container info" onMouseEnter={handleMouseEnter} onMouseLeave={handleMouseLeave}>
<Image layout="fill" alt="" className="image img-fluid" src="/images/icons/info.svg" />
</a>
{showInfo && <div className="info-text">13+. Climbers aged 13-17 must be accompanied by an adult (18+)</div>}
</div>
</li>
</ul>
</div>
{activityById && (
<div className="col-12">
<ul className="availability-wrappper">
<li>
<span className="image-container">
<Image layout="fill" alt="" className="image img-fluid" src="/images/availability/month.svg" />
</span>
From: {activityById.data.attributes.fromDate} To: {activityById.data.attributes.toDate}
</li>
<li>
<span className="image-container">
<Image layout="fill" alt="" className="image img-fluid" src="/images/availability/time.svg" />
</span>
Time: {activityById.data.attributes.fromTime} - {activityById.data.attributes.toTime}
</li>
<li>
<span className="image-container">
<Image layout="fill" alt="" className="image img-fluid" src="/images/availability/duration.svg" />
</span>
Duration: {activityById.data.attributes.minimumDuration}-{activityById.data.attributes.maximumDuration} Hours
</li>
<li>
<span className="image-container">
<Image layout="fill" alt="" className="image img-fluid" src="/images/availability/contact.svg" />
</span>
Contact: {activityById.data.attributes.phoneNumber}
</li>
<li>
<span className="image-container">
<Image layout="fill" alt="" className="image img-fluid" src="/images/availability/date.svg" />
</span>
Active on:{" "}
{returnAvilablleDaysArray({ data: activityById.data })
.map(item => {
return item.name;
})
.join(", ")}
</li>
<li>
<span className="image-container">
<Image layout="fill" alt="" className="image img-fluid" src="/images/availability/age.svg" />
</span>
Age: {activityById.data.attributes.ageLowerLimit}+
<div className="info-div">
<a className="image-container info" onMouseEnter={handleMouseEnter} onMouseLeave={handleMouseLeave}>
<Image layout="fill" alt="" className="image img-fluid" src="/images/icons/info.svg" />
</a>
{showInfo && <div className="info-text">13+. Climbers aged 13-17 must be accompanied by an adult (18+)</div>}
</div>
</li>
</ul>
</div>
)}
</div>
</div>
</>
......
import Image from "next/image";
import React, { Fragment, useEffect, useState } from "react";
import { Button } from "react-bootstrap";
import { Button, Modal } from "react-bootstrap";
import { fadeIn, zoomIn, slideFromLeft, slideFromRight } from "../animationvariants.js";
import { motion } from "framer-motion";
import { getSession } from "next-auth/react";
import { DatePicker } from "antd";
import { DatePicker, Input } from "antd";
import { date } from "yup";
import { sendEnquiry } from "../../redux/actions/enquiryAction.js";
import { useDispatch, useSelector } from "react-redux";
......@@ -12,9 +12,10 @@ import { toast } from "react-toastify";
import { getCurrentEndUser } from "../../redux/actions/userActions.js";
import { Loader } from "react-bootstrap-typeahead";
import { useRouter } from "next/router.js";
import Link from "next/link.js";
const DetailInfo = ({ activityById }) => {
const router = useRouter()
const router = useRouter();
const dispatch = useDispatch();
useEffect(() => {
dispatch(getCurrentEndUser());
......@@ -23,6 +24,9 @@ const DetailInfo = ({ activityById }) => {
// const [session, setSession] = useState(null);
const [enqDate, setenqDate] = useState();
const [loading, setloading] = useState(false);
const [quantity, setquantity] = useState();
const [loginModal, setloginModal] = useState(false);
const [enquiryModal, setenquiryModal] = useState(false);
const { loadedUser } = useSelector(state => state.loadedUser);
const { endUser } = useSelector(state => state.endUser);
// useEffect(() => {
......@@ -48,96 +52,104 @@ const DetailInfo = ({ activityById }) => {
return (
<Fragment>
<div className="row">
<div className="col-12">
<div className="product-info">
<div className="hide-on-mobile">
<div className="top-row">
<div className="most-booked">Most Booked</div>
{activityById && (
<div className="col-12">
<div className="product-info">
<div className="hide-on-mobile">
<div className="top-row">
<div className="most-booked">Most Booked</div>
<div className="wishlist-share">
<a href="#" className={`add-to-wishlist ${isToggled ? "active" : ""}`} onClick={handleClick}>
<div className="wishlist-share">
<a href="#" className={`add-to-wishlist ${isToggled ? "active" : ""}`} onClick={handleClick}>
<span className="image-container">
<Image layout="fill" alt="" className="image img-fluid" src={isToggled ? "/images/icons/wishlist-01-active.svg" : "/images/icons/wishlist-01.svg"} />
</span>
</a>
<a href="#" className="add-to-forwardt">
<span className="image-container">
<Image layout="fill" alt="" className="image img-fluid" src="/images/icons/forward.svg" />
</span>
</a>
</div>
</div>
<motion.div variants={slideFromRight(0.4)} initial={"hidden"} whileInView={"show"} viewport={{ once: false, amount: 0.2 }}>
<div className="product-name">{activityById.data.attributes.name}</div>
</motion.div>
</div>
<div className="product-reviews">
<span className="rating">{activityById.data.attributes.rating}</span>
<span className="review">1,365 Reviews</span>
<span className="star">
<a href="">
<span className="image-container">
<Image layout="fill" alt="" className="image img-fluid" src={isToggled ? "/images/icons/wishlist-01-active.svg" : "/images/icons/wishlist-01.svg"} />
<Image layout="fill" alt="" className="image img-fluid" src="/images/icons/star.svg" />
</span>
</a>
<a href="#" className="add-to-forwardt">
<a href="">
<span className="image-container">
<Image layout="fill" alt="" className="image img-fluid" src="/images/icons/forward.svg" />
<Image layout="fill" alt="" className="image img-fluid" src="/images/icons/star.svg" />
</span>
</a>
</div>
<a href="">
<span className="image-container">
<Image layout="fill" alt="" className="image img-fluid" src="/images/icons/star.svg" />
</span>
</a>
<a href="">
<span className="image-container">
<Image layout="fill" alt="" className="image img-fluid" src="/images/icons/star.svg" />
</span>
</a>
<a href="">
<span className="image-container">
<Image layout="fill" alt="" className="image img-fluid" src="/images/icons/star.svg" />
</span>
</a>
</span>
</div>
<motion.div variants={slideFromRight(0.4)} initial={"hidden"} whileInView={"show"} viewport={{ once: false, amount: 0.2 }}>
<div className="product-name">{activityById.data.attributes.name}</div>
</motion.div>
</div>
<div className="product-reviews">
<span className="rating">{activityById.data.attributes.rating}</span>
<span className="review">1,365 Reviews</span>
<span className="star">
<a href="">
<span className="image-container">
<Image layout="fill" alt="" className="image img-fluid" src="/images/icons/star.svg" />
</span>
</a>
<a href="">
<span className="image-container">
<Image layout="fill" alt="" className="image img-fluid" src="/images/icons/star.svg" />
</span>
</a>
<a href="">
<span className="image-container">
<Image layout="fill" alt="" className="image img-fluid" src="/images/icons/star.svg" />
</span>
</a>
<a href="">
<span className="image-container">
<Image layout="fill" alt="" className="image img-fluid" src="/images/icons/star.svg" />
</span>
</a>
<a href="">
<span className="image-container">
<Image layout="fill" alt="" className="image img-fluid" src="/images/icons/star.svg" />
<div className="mb-2">Per Person</div>
<div className="price">
${activityById.data.attributes.pricePerPerson} {activityById.data.attributes.offers && <span>{activityById.data.attributes.offers}% Off</span>}
</div>
<div className="mb-4">{activityById.data.attributes.description}</div>
<div className="location">
Location & Address <span>{activityById.data.attributes.activityType}</span>
</div>
<div className="mb-2">Chelsea </div>
<div className="">{activityById.data.attributes.address}</div>
<div className="btn-row">
<Button
disabled={loading}
onClick={() => {
if (!endUser) {
setloginModal(true);
} else {
setenquiryModal(true);
}
}}
variant="primary me-3"
>
{loading ? <Loader /> : "Enquire Now"}
</Button>
<Button
onClick={() => {
if (!endUser) {
setloginModal(true);
} else {
router.push("/gift-card");
}
}}
variant="secondary"
>
Gift Now
<span className="image-container btn-gift">
<Image layout="fill" className="image img-fluid" src="/images/icons/gift-card-icon.svg" />
</span>
</a>
</span>
</div>
<div className="mb-2">Per Person</div>
<div className="price">
${activityById.data.attributes.pricePerPerson} {activityById.data.attributes.offers && <span>{activityById.data.attributes.offers}% Off</span>}
</div>
<div className="mb-4">{activityById.data.attributes.description}</div>
<div className="location">
Location & Address <span>{activityById.data.attributes.activityType}</span>
</div>
<div className="mb-2">Chelsea </div>
<div className="">{activityById.data.attributes.address}</div>
<div className="btn-row">
<Button
disabled={loading}
onClick={async () => {
setloading(true);
console.log("hello");
let res = await sendEnquiry({ activityId: activityById.data.id, userId: endUser.id, vendorId: activityById.data.attributes.vendor.data.id });
console.log("res", res);
toast.success("Enquiry sent successfully, our team will get back to you shortly! Thank you!");
setloading(false);
}}
variant="primary me-3"
>
{loading ? <Loader /> : "Enquire Now"}
</Button>
<Button onClick={() => {
router.push("/gift-card")
}} variant="secondary">
Gift Now
<span className="image-container btn-gift">
<Image layout="fill" className="image img-fluid" src="/images/icons/gift-card-icon.svg" />
</span>
</Button>
</Button>
</div>
</div>
</div>
</div>
)}
</div>
<div className="row hide-on-desktop">
<div className="col-12">
......@@ -187,6 +199,78 @@ const DetailInfo = ({ activityById }) => {
</ul>
</div>
</div>
<Modal
show={enquiryModal}
onHide={() => {
setenquiryModal(false);
setquantity();
}}
>
<Modal.Header>Send Enquiry</Modal.Header>
<Modal.Body>
<div>Experience Name:</div>
<div className="" style={{ fontSize: "22px", fontWeight: "bold" }}>
{activityById.data.attributes.name}
</div>
<div className="mt-2">Full Name:</div>
<div className="" style={{ fontWeight: "bold" }}>
{endUser?.attributes.name}
</div>
<div className="mt-2">Email ID:</div>
<div className="" style={{ fontSize: "22px", fontWeight: "bold" }}>
{endUser?.attributes.email}
</div>
<div className="mt-2">Quantity:</div>
<Input
type="number"
onChange={e => {
// console.log("e", e);
setquantity(e.target.value);
}}
></Input>
<Button
disabled={loading || !quantity}
className="mt-2"
onClick={async () => {
setloading(true);
console.log("hello");
let res = await sendEnquiry({ activityId: activityById.data.id, userId: endUser.id, vendorId: activityById.data.attributes.vendor.data.id, quantity });
console.log("res", res);
toast.success("Enquiry sent successfully, our team will get back to you shortly! Thank you!");
setloading(false);
setenquiryModal(false);
setquantity();
}}
>
{loading ? <Loader /> : "Submit"}
</Button>
</Modal.Body>
</Modal>
<Modal
show={loginModal}
centered
onHide={() => {
setloginModal(false);
}}
>
<Modal.Header closeButton>Please Log in</Modal.Header>
<Modal.Body>
<div className="text-center d-flex justify-content-center row">
<div className="col-12 m-2">Please login to avail this feature.</div>
<Button
className="col-6 m-2"
onClick={() => {
router.push("/login/user");
}}
>
Login
</Button>
<Link className="m-2" href={"/signup/user"}>
Or click here to sign up.
</Link>
</div>
</Modal.Body>
</Modal>
</Fragment>
);
};
......
......@@ -8,6 +8,7 @@ import axios from "axios";
import { toast } from "react-toastify";
import { Loader } from "react-bootstrap-typeahead";
import { finishVendorOtpVerification } from "../../redux/actions/vendorActions";
import { useRouter } from "next/router";
// import { getCurrentEndUser } from "../../redux/actions/userActions";
const validationSchema = Yup.object().shape({
......@@ -21,6 +22,7 @@ const validationSchema = Yup.object().shape({
let formik1;
const GiftCard = () => {
const router = useRouter()
const dispatch = useDispatch();
// useEffect(() => {
// dispatch(getCurrentEndUser());
......@@ -389,11 +391,13 @@ const GiftCard = () => {
<div className="col-12">
<div className="result-box">
<p>
Sorry, unable to process the Gift Card now.
<br /> This feature will be available shortly.
Gift card sent for approval, please wait till the vendor contacts you
<br /> Thank you.
</p>
<div>
<button className="btn btn-primary" type="button" onClick={handleclose}>
<button className="btn btn-primary" type="button" onClick={()=>{
router.push("/listing")
}}>
Browse Experiences
</button>
</div>
......
import Image from "next/image";
import Link from "next/link";
import { useRouter } from "next/router";
import React, { useState } from "react";
import { ToastContainer } from "react-toastify";
......@@ -21,22 +22,28 @@ const Sidebar = () => {
</button> */}
<ul>
<li className={router.pathname === "/vendor/dashboard" ? "active" : ""}>
<a href="/vendor/dashboard">
<Image alt="" width={22} height={15} src="/images/vendor/icon-dashboard.svg" />
<span>Dashboard</span>
</a>
<span className="d-flex">
<Image className="" alt="" width={22} height={15} src="/images/vendor/icon-dashboard.svg" />
<div className="mx-2 text-center">
<Link href="/vendor/dashboard">Dashboard</Link>
</div>
</span>
</li>
<li className={router.pathname === "/vendor/orders" ? "active" : ""}>
<a href="/vendor/orders">
<li className={router.pathname === "/vendor/enquiries" ? "active" : ""}>
<span className="d-flex">
<Image alt="" width={22} height={15} src="/images/vendor/icon-orders.svg" />
<span>Orders</span>
</a>
<div className="mx-2 text-center">
<Link href="/vendor/enquiries">Enquiries</Link>
</div>
</span>
</li>
<li className={router.pathname === "/vendor/activities" ? "active" : ""}>
<a href="/vendor/activities">
<span className="d-flex">
<Image alt="" width={22} height={15} src="/images/vendor/icon-activities.svg" />
<span>Activities</span>
</a>
<div className="mx-2 text-center">
<Link href="/vendor/activities">Activities</Link>
</div>
</span>
</li>
</ul>
</div>
......
......@@ -170,10 +170,10 @@ export const ActivityListingRBAC = ({ setactivityDetailInfo, setShowActivityDeta
};
});
const categoryFilterArray = categories.data.map((item, index) => {
const categoryFilterArray = categories?.data.map((item, index) => {
return { text: item.attributes.name, value: item.attributes.name };
});
const subCategoryFilterArray = subCategories.data.map((item, index) => {
const subCategoryFilterArray = subCategories?.data.map((item, index) => {
return { text: item.attributes.name, value: item.attributes.name };
});
setdata(initialData);
......
import { Fragment } from "react";
import { Button, Image, Table } from "react-bootstrap";
import { EyeOutlined, EyeTwoTone } from "@ant-design/icons";
import { Space, Table, Tag } from "antd";
import { Fragment, useEffect, useState } from "react";
import { Button, Image, Modal } from "react-bootstrap";
import { useDispatch, useSelector } from "react-redux";
import { toast } from "react-toastify";
import { getActivitiesByVendor } from "../../redux/actions/activityAction";
import { changeEnquiryStatus, getEnquiriesByVendor } from "../../redux/actions/enquiryAction";
const OrderListing = () => {
const array = [1, 2, 3, 4, 5, 6, 7, 8, 9]
return (
<Fragment>
<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>Orders</h2>
<p>View all the orders</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>Order ID</th>
<th>Order Date</th>
<th>Items</th>
<th>Total Amount</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>ID_8797878</td>
<td>29 Jan 2024</td>
<td>Edge City Climb <span style={{color:"blue"}}>+3more</span></td>
<td>$ 499</td>
<td><div className="statusDiv processing">Processing</div></td>
<td><Image alt="" width={20} height={20} src="/images/vendor/icon-more-vertical.svg" /></td>
</tr>
))}
<tr>
<td colSpan={7}>Showing Results 10 of 1567</td>
</tr>
</tbody>
</Table>
</div>
</div>
const dispatch = useDispatch();
useEffect(() => {
dispatch(getEnquiriesByVendor());
dispatch(getActivitiesByVendor());
}, []);
const { enquiriesByVendor } = useSelector(state => state.enquiriesByVendor);
const { allActivitiesData } = useSelector(state => state.allActivitiesData);
const [data, setData] = useState();
const [activityFilters, setactivityFilters] = useState();
const [enquiryDetails, setenquiryDetails] = useState();
const [showEnquiryModal, setshowEnquiryModal] = useState(false);
console.log("enquiriesByVendor", enquiriesByVendor);
const columns = [
{
title: "Activity name",
dataIndex: "activityName",
filters: activityFilters,
// filterMode: "tree",
filterSearch: true,
onFilter: (value, record) => {
console.log("value", value, record.name.startsWith(value));
return record.activityName.startsWith(value);
},
width: "25%"
},
{
title: "Name",
dataIndex: "name",
sorter: (a, b) => a.age - b.age,
width: "25%"
},
{
title: "Status",
dataIndex: "status",
filters: [
{
text: "pending",
value: "pending"
},
{
text: "closed",
value: "closed"
}
],
onFilter: (value, record) => record.status.startsWith(value),
filterSearch: true,
width: "25%",
render: tag => (
<span>
{tag == "pending" ? (
<Tag color={"red"} key={tag}>
{tag.toUpperCase()}
</Tag>
) : (
<Tag color={"blue"} key={tag}>
{tag.toUpperCase()}
</Tag>
)}
</span>
)
},
{
title: "Quantity",
dataIndex: "quantity",
// filters: [
// {
// text: "London",
// value: "London"
// },
// {
// text: "New York",
// value: "New York"
// }
// ],
// onFilter: (value, record) => record.address.startsWith(value),
// filterSearch: true,
width: "15%"
},
{
title: "Action",
width: "25%",
render: (_, record) => (
<Space size="middle">
<EyeTwoTone
onClick={() => {
setshowEnquiryModal(true);
console.log(record);
setenquiryDetails(enquiriesByVendor.filter(item => item.id == record.key));
}}
style={{ fontSize: "22px" }}
/>
{/* <a>Delete</a> */}
</Space>
)
}
];
useEffect(() => {
let rawData =
enquiriesByVendor &&
enquiriesByVendor.map(item => {
return {
key: item.id,
name: item.attributes.end_user.data.attributes.name,
quantity: item.attributes.quantity,
status: item.attributes.status,
activityName: item.attributes.experience.data.attributes.name
};
});
setData(rawData);
}, [enquiriesByVendor]);
useEffect(() => {
const activityFiltersRaw =
allActivitiesData &&
allActivitiesData.data.map(item => {
return {
text: item.attributes.name,
value: item.attributes.name
};
});
setactivityFilters(activityFiltersRaw);
}, [allActivitiesData]);
const onChange = (pagination, filters, sorter, extra) => {
// console.log("params", pagination, filters, sorter, extra);
};
return (
<Fragment>
<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>Orders</h2>
<p>View all the orders</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>
</Fragment>
);
<Table columns={columns} dataSource={data} onChange={onChange} />
</div>
</div>
</div>
<Modal
show={showEnquiryModal}
onHide={() => {
setshowEnquiryModal(false);
}}
>
{console.log("enquiryDetails", enquiryDetails)}
<Modal.Header>Enquiry Details</Modal.Header>
<Modal.Body>
{enquiryDetails && enquiryDetails.length > 0 && (
<>
<div className="p-2">Name: {enquiryDetails[0].attributes.end_user.data.attributes.name}</div>
<div className="p-2">Phone number: {enquiryDetails[0].attributes.end_user.data.attributes.phone}</div>
<div className="p-2">Email: {enquiryDetails[0].attributes.end_user.data.attributes.email}</div>
<div className="p-2">
Status: <Tag color={enquiryDetails[0].attributes.status == "pending" ? "red" : "blueI"}>{enquiryDetails[0].attributes.status.toUpperCase()}</Tag>
</div>
<Button
onClick={async () => {
if (enquiryDetails[0].attributes.status == "pending") {
let res = await changeEnquiryStatus({ status: "closed", id: enquiryDetails[0].id });
console.log("res", res);
} else {
let res = await changeEnquiryStatus({ status: "pending", id: enquiryDetails[0].id });
console.log("res", res);
}
await dispatch(getEnquiriesByVendor());
toast.success("Status changed");
setshowEnquiryModal(false);
}}
>
Change Status
</Button>
</>
)}
</Modal.Body>
</Modal>
</Fragment>
);
};
export default OrderListing;
......@@ -6,30 +6,28 @@ import Sidebar from "../../../components/layout/VendorDashboardSidebar";
// import { loadUser } from "../redux/actions/userActions";
// import { wrapper } from "../redux/store";
export default function OrderListingPage() {
return (
<Layout>
<div className="sidebarContainer">
<Sidebar />
<div className="content">
<OrderListing />
</div>
</div>
</Layout>
);
const OrderListingPage = () => {
return (
<Layout>
<div className="sidebarContainer">
<Sidebar />
<div className="content">
<OrderListing />
</div>
</div>
</Layout>
);
};
export default OrderListingPage;
/** For server side rendering */
export const getServerSideProps = wrapper.getServerSideProps(store => async ({ req, query }) => {
// Get the menu data.
// get the locations data.
// await store.dispatch(getVendorDetails())
// Get the menu data.
return {
props: {},
// get the locations data.
// await store.dispatch(loadUser());
};
return {
props: {}
};
});
......@@ -82,7 +82,7 @@ export const getActivitiesByVendor = () => async dispatch => {
const vendorResponse = await axios.get(`${process.env.NEXT_PUBLIC_BACKEND_API_URL}/api/vendors/?${vendorQueryString}`, vendorConfig);
console.log("vendorResponse", vendorResponse.data.data[0].id);
// console.log("vendorResponse", vendorResponse.data.data[0].id);
// const loggedinVendor = await getLoggedInVendor()
// console.log("loggedinVendor", loggedinVendor);
if (!session) {
......
import axios from "axios";
import { CLEAR_ERRORS, ENQUIRY_SUBMIT_FAIL, ENQUIRY_SUBMIT_REQUEST, ENQUIRY_SUBMIT_SUCCESS } from "../constants/enquiryConstants";
import { getSession } from "next-auth/react";
import {
CLEAR_ERRORS,
ENQUIRY_SUBMIT_FAIL,
ENQUIRY_SUBMIT_REQUEST,
ENQUIRY_SUBMIT_SUCCESS,
GET_ENQUIRIES_BY_VENDOR_FAIL,
GET_ENQUIRIES_BY_VENDOR_REQUEST,
GET_ENQUIRIES_BY_VENDOR_SUCCESS
} from "../constants/enquiryConstants";
import qs from "qs";
export const sendEnquiry = async ({ activityId, userId, date, vendorId }) => {
export const sendEnquiry = async ({ activityId, userId, date, vendorId, quantity }) => {
const data = {
data: {
experience: activityId,
endUser: userId,
end_user: userId,
vendor: vendorId,
date,
status: "pending"
status: "pending",
quantity
}
};
const config = {
......@@ -28,3 +39,85 @@ export const clearErrors = () => async dispatch => {
type: CLEAR_ERRORS
});
};
export const getEnquiriesByVendor = () => async dispatch => {
try {
const session = await getSession();
if (!session) {
return;
}
const vendorConfig = {
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${session.jwt}`
}
};
const vendorQuery = {
filters: {
user: {
id: { $eq: session.id }
}
}
};
const vendorQueryString = qs.stringify(vendorQuery, {
encodeValuesOnly: true
});
const vendorResponse = await axios.get(`${process.env.NEXT_PUBLIC_BACKEND_API_URL}/api/vendors/?${vendorQueryString}`, vendorConfig);
console.log("session", vendorResponse.data.data[0].id);
dispatch({
type: GET_ENQUIRIES_BY_VENDOR_REQUEST
});
const config = {
headers: {
"Content-type": "application/json",
Authorization: `Bearer ${session.jwt}`
}
};
const query = {
filters: {
vendor: {
id: { $eq: vendorResponse.data.data[0].id }
}
},
populate: ["vendor", "experience", "end_user"]
};
const queryString = qs.stringify(query, {
encodeValuesOnly: true
});
// console.log("querystring", query);
const response = await axios.get(`${process.env.NEXT_PUBLIC_BACKEND_API_URL}/api/enquires/?${queryString}`, config);
console.log("response", response);
dispatch({
type: GET_ENQUIRIES_BY_VENDOR_SUCCESS,
payload: response.data.data
});
} catch (error) {
dispatch({
type: GET_ENQUIRIES_BY_VENDOR_FAIL,
payload: error.response.data
});
}
};
export const changeEnquiryStatus = async ({ status, id }) => {
try {
const session = await getSession();
if (!session) {
return;
}
const config = {
headers: {
"Content-type": "application/json",
Authorization: `Bearer ${session.jwt}`
}
};
const response = await axios.put(`${process.env.NEXT_PUBLIC_BACKEND_API_URL}/api/enquires/${id}`, { data: { status } }, config);
return response.data;
} catch (error) {}
};
......@@ -403,6 +403,9 @@ export const getCurrentEndUser = () => async dispatch => {
try {
console.log("here action");
const session = await getSession();
if (!session) {
return;
}
console.log("session action", session);
dispatch({
type: GET_END_USER_REQUEST
......
......@@ -2,6 +2,10 @@ export const ENQUIRY_SUBMIT_REQUEST = "ENQUIRY_SUBMIT_REQUEST";
export const ENQUIRY_SUBMIT_SUCCESS = "ENQUIRY_SUBMIT_SUCCESS";
export const ENQUIRY_SUBMIT_FAIL = "ENQUIRY_SUBMIT_FAIL";
export const GET_ENQUIRIES_BY_VENDOR_REQUEST = "GET_ENQUIRIES_BY_VENDOR_REQUEST";
export const GET_ENQUIRIES_BY_VENDOR_SUCCESS = "GET_ENQUIRIES_BY_VENDOR_SUCCESS";
export const GET_ENQUIRIES_BY_VENDOR_FAIL = "GET_ENQUIRIES_BY_VENDOR_FAIL";
export const CLEAR_ERRORS = "CLEAR_ERRORS";
// export const TOGGLE_SUCCESS
\ No newline at end of file
import { ENQUIRY_SUBMIT_FAIL, ENQUIRY_SUBMIT_REQUEST, ENQUIRY_SUBMIT_SUCCESS } from "../constants/enquiryConstants";
import {
ENQUIRY_SUBMIT_FAIL,
ENQUIRY_SUBMIT_REQUEST,
ENQUIRY_SUBMIT_SUCCESS,
GET_ENQUIRIES_BY_VENDOR_FAIL,
GET_ENQUIRIES_BY_VENDOR_REQUEST,
GET_ENQUIRIES_BY_VENDOR_SUCCESS
} from "../constants/enquiryConstants";
export const enquiryReducer = (state = { enquiry: null }, action) => {
switch (action.type) {
......@@ -11,7 +18,7 @@ export const enquiryReducer = (state = { enquiry: null }, action) => {
return {
loading: false,
success: true,
referral: action.payload
enquiry: action.payload
};
case ENQUIRY_SUBMIT_FAIL:
return {
......@@ -24,3 +31,25 @@ export const enquiryReducer = (state = { enquiry: null }, action) => {
return state;
}
};
export const getEnquiriesReducer = (state = { enquiriesByVendor: null }, action) => {
switch (action.type) {
case GET_ENQUIRIES_BY_VENDOR_REQUEST:
return {
loading: true,
};
case GET_ENQUIRIES_BY_VENDOR_SUCCESS:
return {
loading: false,
enquiriesByVendor: action.payload
};
case GET_ENQUIRIES_BY_VENDOR_FAIL:
return {
loading: false,
error: action.payload.error.message
};
default:
return state;
}
};
......@@ -2,7 +2,7 @@ import { combineReducers } from "redux";
import { projectReducer, projectsReducer, similarProjectsReducer } from "./projectsReducer";
import { townshipReducer, townshipsReducer } from "./townshipsReducer";
import { authReducer, forgotPasswordReducer, getEndUserReducer, loadedUserReducer, resetPasswordReducer, userReducer } from "./userReducers";
import { enquiryReducer } from "./enquiryReducer";
import { enquiryReducer, getEnquiriesReducer } from "./enquiryReducer";
import { displayEnquireNowReducer } from "./enquireNowModalReducer";
import { getAllVendorsReducer, getVendorDetailsReducer, loggedInVendorReducer, updateVendorReducer } from "./vendorReducers";
import { createActivityReducer, getActivitiesReducer, getActivityByIdReducer, updateActivityByIdReducer } from "./activitiesReducer";
......@@ -39,6 +39,7 @@ const reducers = combineReducers({
homeBanner: getAllHomeBannerReducer,
allVendors: getAllVendorsReducer,
endUser: getEndUserReducer,
enquiriesByVendor: getEnquiriesReducer,
});
export default reducers;
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!