Commit 93ce6ebc by jaymehta

.

1 parent 9e140f94
...@@ -5,7 +5,7 @@ import { useDispatch, useSelector } from "react-redux"; ...@@ -5,7 +5,7 @@ import { useDispatch, useSelector } from "react-redux";
import { getActivitiesByFilters } from "../../redux/actions/activityAction"; import { getActivitiesByFilters } from "../../redux/actions/activityAction";
import ReviewsListing from "./ReviewsListing"; import ReviewsListing from "./ReviewsListing";
const Reviews = () => { const Reviews = ({ isVendor }) => {
const dispatch = useDispatch(); const dispatch = useDispatch();
const searchInput = useRef(null); const searchInput = useRef(null);
const [searchText, setSearchText] = useState(""); const [searchText, setSearchText] = useState("");
...@@ -127,7 +127,7 @@ const Reviews = () => { ...@@ -127,7 +127,7 @@ const Reviews = () => {
return { return {
key: item.id, key: item.id,
name: item.attributes.name, name: item.attributes.name,
reviewsCount: item.attributes.reviews.data.length reviewsCount: item.attributes.reviews?.data.length
// tags: ["nice", "developer"] // tags: ["nice", "developer"]
}; };
}) })
...@@ -165,7 +165,7 @@ const Reviews = () => { ...@@ -165,7 +165,7 @@ const Reviews = () => {
width: "10%" width: "10%"
} }
]); ]);
}, []); }, [allActivitiesData]);
useEffect(() => { useEffect(() => {
setdata( setdata(
allActivitiesData && allActivitiesData &&
...@@ -174,7 +174,7 @@ const Reviews = () => { ...@@ -174,7 +174,7 @@ const Reviews = () => {
return { return {
key: item.id, key: item.id,
name: item.attributes.name, name: item.attributes.name,
reviewsCount: item.attributes.reviews.data.length reviewsCount: item.attributes.reviews?.data.length
// tags: ["nice", "developer"] // tags: ["nice", "developer"]
}; };
}) })
...@@ -184,7 +184,9 @@ const Reviews = () => { ...@@ -184,7 +184,9 @@ const Reviews = () => {
return ( return (
<Fragment> <Fragment>
<div className="row">{!showReviews ? <Table columns={columns} dataSource={data} /> : <ReviewsListing setshowReviews={setshowReviews} activityId={activityId} />}</div> <div className="row">
{!showReviews ? <Table columns={columns} dataSource={data} /> : <ReviewsListing setshowReviews={setshowReviews} activityId={activityId} isVendor={isVendor} />}
</div>
</Fragment> </Fragment>
); );
}; };
......
...@@ -8,7 +8,7 @@ import { toast } from "react-toastify"; ...@@ -8,7 +8,7 @@ import { toast } from "react-toastify";
// import { getActivitiesByFilters } from "../../redux/actions/activityAction"; // import { getActivitiesByFilters } from "../../redux/actions/activityAction";
import { deleteReview, getReviewsAction } from "../../redux/actions/reviewsAction"; import { deleteReview, getReviewsAction } from "../../redux/actions/reviewsAction";
const ReviewsListing = ({ activityId, setshowReviews }) => { const ReviewsListing = ({ activityId, setshowReviews, isVendor }) => {
const dispatch = useDispatch(); const dispatch = useDispatch();
useEffect(() => { useEffect(() => {
dispatch(getReviewsAction({ activityId })); dispatch(getReviewsAction({ activityId }));
...@@ -22,12 +22,13 @@ const ReviewsListing = ({ activityId, setshowReviews }) => { ...@@ -22,12 +22,13 @@ const ReviewsListing = ({ activityId, setshowReviews }) => {
<div className="col-12 col-lg-12"> <div className="col-12 col-lg-12">
<div className="d-flex align-items-center justify-content-between"> <div className="d-flex align-items-center justify-content-between">
<div className="backDiv"> <div className="backDiv">
<span className="backArrow"> <span
<FaAngleLeft className="backArrow"
onClick={() => { onClick={() => {
setshowReviews(false); setshowReviews(false);
}} }}
/> >
<FaAngleLeft />
</span> </span>
<span>Reviews: </span> <span>Reviews: </span>
</div> </div>
...@@ -49,6 +50,7 @@ const ReviewsListing = ({ activityId, setshowReviews }) => { ...@@ -49,6 +50,7 @@ const ReviewsListing = ({ activityId, setshowReviews }) => {
<Accordion.Body> <Accordion.Body>
<div className="m-1">Rating: {item.attributes.rating}</div> <div className="m-1">Rating: {item.attributes.rating}</div>
<div className="m-1">Review: {item.attributes.comments}</div> <div className="m-1">Review: {item.attributes.comments}</div>
{!isVendor && (
<div> <div>
<Button <Button
className="btnAdd btnReject m-0" className="btnAdd btnReject m-0"
...@@ -60,6 +62,7 @@ const ReviewsListing = ({ activityId, setshowReviews }) => { ...@@ -60,6 +62,7 @@ const ReviewsListing = ({ activityId, setshowReviews }) => {
Delete review Delete review
</Button> </Button>
</div> </div>
)}
</Accordion.Body> </Accordion.Body>
</Accordion.Item> </Accordion.Item>
); );
......
...@@ -13,7 +13,6 @@ import Image from "next/image"; ...@@ -13,7 +13,6 @@ import Image from "next/image";
import DetailSchedule from "./DetailSchedule"; import DetailSchedule from "./DetailSchedule";
const Detail = () => { const Detail = () => {
const router = useRouter(); const router = useRouter();
const dispatch = useDispatch(); const dispatch = useDispatch();
const { allActivitiesData } = useSelector(state => state.allActivitiesData); const { allActivitiesData } = useSelector(state => state.allActivitiesData);
...@@ -25,7 +24,7 @@ const Detail = () => { ...@@ -25,7 +24,7 @@ const Detail = () => {
dispatch(getActivitiesByFilters({ category: activityById?.data.attributes.category?.data?.id })); dispatch(getActivitiesByFilters({ category: activityById?.data.attributes.category?.data?.id }));
}, [activityById]); }, [activityById]);
console.log("faqs=>", faqs) console.log("faqs=>", faqs);
console.log("activityById", activityById); console.log("activityById", activityById);
console.log("loadedUser", loadedUser); console.log("loadedUser", loadedUser);
return ( return (
......
...@@ -5,6 +5,7 @@ import { Button, Modal } from "react-bootstrap"; ...@@ -5,6 +5,7 @@ import { Button, Modal } from "react-bootstrap";
import { useSelector } from "react-redux"; import { useSelector } from "react-redux";
import StarRatings from "react-star-ratings"; import StarRatings from "react-star-ratings";
import { postReviewEndUser } from "../../redux/actions/reviewsAction"; import { postReviewEndUser } from "../../redux/actions/reviewsAction";
import { dateFormatFn } from "../../services/imageHandling";
const GuestReviews = ({ activityById }) => { const GuestReviews = ({ activityById }) => {
const [rating, setRating] = useState(0); const [rating, setRating] = useState(0);
...@@ -55,7 +56,7 @@ const GuestReviews = ({ activityById }) => { ...@@ -55,7 +56,7 @@ const GuestReviews = ({ activityById }) => {
<div className="guest-reviews-detail"> <div className="guest-reviews-detail">
<div className="head"> <div className="head">
<div className="name">{data.attributes.endUser.data.attributes.name}</div> <div className="name">{data.attributes.endUser.data.attributes.name}</div>
<div className="month">{data.attributes.createdAt}</div> <div className="month">{dateFormatFn(data.attributes.createdAt)}</div>
</div> </div>
<StarRatings <StarRatings
className="col-3 mx-2" className="col-3 mx-2"
......
...@@ -45,6 +45,14 @@ const Sidebar = () => { ...@@ -45,6 +45,14 @@ const Sidebar = () => {
</div> </div>
</span> </span>
</li> </li>
<li className={router.pathname === "/vendor/reviews" ? "active" : ""}>
<span className="d-flex">
<Image alt="" width={22} height={15} src="/images/vendor/icon-orders.svg" />
<div className="mx-2 text-center">
<Link href="/vendor/reviews">Reviews</Link>
</div>
</span>
</li>
</ul> </ul>
</div> </div>
); );
......
...@@ -12,7 +12,7 @@ const ReviewsPage = () => { ...@@ -12,7 +12,7 @@ const ReviewsPage = () => {
<div className="sidebarContainer"> <div className="sidebarContainer">
<Sidebar /> <Sidebar />
<div className="content"> <div className="content">
<Reviews /> <Reviews isVendor={false} />
</div> </div>
</div> </div>
</Layout> </Layout>
......
import React, { useEffect } from "react";
import { useDispatch } from "react-redux";
import Reviews from "../../../components/admin/Reviews";
import Layout from "../../../components/layout/Layout";
import Sidebar from "../../../components/layout/VendorDashboardSidebar";
import { getActivitiesByVendor } from "../../../redux/actions/activityAction";
import { wrapper } from "../../../redux/store";
const ReviewsPage = () => {
const dispatch = useDispatch();
useEffect(() => {
dispatch(getActivitiesByVendor());
}, []);
return (
<div>
<Layout>
<div className="sidebarContainer">
<Sidebar />
<div className="content">
<Reviews isVendor={true} />
</div>
</div>
</Layout>
</div>
);
};
export default ReviewsPage;
/** For server side rendering */
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());
// await store.dispatch(getAllSubCategories());
return {
props: {}
};
});
...@@ -86,7 +86,7 @@ export const getActivitiesByVendor = () => async dispatch => { ...@@ -86,7 +86,7 @@ export const getActivitiesByVendor = () => async dispatch => {
const vendorResponse = await axios.get(`${process.env.NEXT_PUBLIC_BACKEND_API_URL}/api/vendors/?${vendorQueryString}`, vendorConfig); 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() // const loggedinVendor = await getLoggedInVendor()
// console.log("loggedinVendor", loggedinVendor); // console.log("loggedinVendor", loggedinVendor);
if (!session) { if (!session) {
...@@ -112,7 +112,7 @@ export const getActivitiesByVendor = () => async dispatch => { ...@@ -112,7 +112,7 @@ export const getActivitiesByVendor = () => async dispatch => {
} }
} }
}, },
populate: ["masterMonths", "subCategory", "subCategory.category", "timeSlots", "masterPincode", "vendor", "image", "category"] populate: ["masterMonths", "subCategory", "subCategory.category", "timeSlots", "masterPincode", "vendor", "image", "category", "reviews"]
}; };
const queryString = qs.stringify(query, { const queryString = qs.stringify(query, {
encodeValuesOnly: true encodeValuesOnly: true
......
...@@ -61,3 +61,11 @@ export const sanitizeTimeRange = ({ data }) => { ...@@ -61,3 +61,11 @@ export const sanitizeTimeRange = ({ data }) => {
return formattedDate; return formattedDate;
// const endDate = new Date(data[1].$d); // const endDate = new Date(data[1].$d);
}; };
export const dateFormatFn = rawDate => {
const date = new Date(rawDate);
const year = date.getFullYear();
const month = String(date.getMonth() + 1).padStart(2, "0"); // Months are zero-indexed
const day = String(date.getDate()).padStart(2, "0");
return `${year}-${month}-${day}`;
};
\ No newline at end of file \ 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!