Commit 93ce6ebc by jaymehta

.

1 parent 9e140f94
......@@ -5,7 +5,7 @@ import { useDispatch, useSelector } from "react-redux";
import { getActivitiesByFilters } from "../../redux/actions/activityAction";
import ReviewsListing from "./ReviewsListing";
const Reviews = () => {
const Reviews = ({ isVendor }) => {
const dispatch = useDispatch();
const searchInput = useRef(null);
const [searchText, setSearchText] = useState("");
......@@ -127,7 +127,7 @@ const Reviews = () => {
return {
key: item.id,
name: item.attributes.name,
reviewsCount: item.attributes.reviews.data.length
reviewsCount: item.attributes.reviews?.data.length
// tags: ["nice", "developer"]
};
})
......@@ -165,7 +165,7 @@ const Reviews = () => {
width: "10%"
}
]);
}, []);
}, [allActivitiesData]);
useEffect(() => {
setdata(
allActivitiesData &&
......@@ -174,7 +174,7 @@ const Reviews = () => {
return {
key: item.id,
name: item.attributes.name,
reviewsCount: item.attributes.reviews.data.length
reviewsCount: item.attributes.reviews?.data.length
// tags: ["nice", "developer"]
};
})
......@@ -184,7 +184,9 @@ const Reviews = () => {
return (
<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>
);
};
......
......@@ -8,7 +8,7 @@ import { toast } from "react-toastify";
// import { getActivitiesByFilters } from "../../redux/actions/activityAction";
import { deleteReview, getReviewsAction } from "../../redux/actions/reviewsAction";
const ReviewsListing = ({ activityId, setshowReviews }) => {
const ReviewsListing = ({ activityId, setshowReviews, isVendor }) => {
const dispatch = useDispatch();
useEffect(() => {
dispatch(getReviewsAction({ activityId }));
......@@ -22,12 +22,13 @@ const ReviewsListing = ({ activityId, setshowReviews }) => {
<div className="col-12 col-lg-12">
<div className="d-flex align-items-center justify-content-between">
<div className="backDiv">
<span className="backArrow">
<FaAngleLeft
<span
className="backArrow"
onClick={() => {
setshowReviews(false);
}}
/>
>
<FaAngleLeft />
</span>
<span>Reviews: </span>
</div>
......@@ -49,6 +50,7 @@ const ReviewsListing = ({ activityId, setshowReviews }) => {
<Accordion.Body>
<div className="m-1">Rating: {item.attributes.rating}</div>
<div className="m-1">Review: {item.attributes.comments}</div>
{!isVendor && (
<div>
<Button
className="btnAdd btnReject m-0"
......@@ -60,6 +62,7 @@ const ReviewsListing = ({ activityId, setshowReviews }) => {
Delete review
</Button>
</div>
)}
</Accordion.Body>
</Accordion.Item>
);
......
......@@ -13,7 +13,6 @@ import Image from "next/image";
import DetailSchedule from "./DetailSchedule";
const Detail = () => {
const router = useRouter();
const dispatch = useDispatch();
const { allActivitiesData } = useSelector(state => state.allActivitiesData);
......@@ -25,7 +24,7 @@ const Detail = () => {
dispatch(getActivitiesByFilters({ category: activityById?.data.attributes.category?.data?.id }));
}, [activityById]);
console.log("faqs=>", faqs)
console.log("faqs=>", faqs);
console.log("activityById", activityById);
console.log("loadedUser", loadedUser);
return (
......
......@@ -5,6 +5,7 @@ import { Button, Modal } from "react-bootstrap";
import { useSelector } from "react-redux";
import StarRatings from "react-star-ratings";
import { postReviewEndUser } from "../../redux/actions/reviewsAction";
import { dateFormatFn } from "../../services/imageHandling";
const GuestReviews = ({ activityById }) => {
const [rating, setRating] = useState(0);
......@@ -55,7 +56,7 @@ const GuestReviews = ({ activityById }) => {
<div className="guest-reviews-detail">
<div className="head">
<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>
<StarRatings
className="col-3 mx-2"
......
......@@ -45,6 +45,14 @@ const Sidebar = () => {
</div>
</span>
</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>
</div>
);
......
......@@ -12,7 +12,7 @@ const ReviewsPage = () => {
<div className="sidebarContainer">
<Sidebar />
<div className="content">
<Reviews />
<Reviews isVendor={false} />
</div>
</div>
</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 => {
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) {
......@@ -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, {
encodeValuesOnly: true
......
......@@ -61,3 +61,11 @@ export const sanitizeTimeRange = ({ data }) => {
return formattedDate;
// 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
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!