Commit b62606bb by jaymehta

loading wishlist

1 parent a08c5fbe
...@@ -4,11 +4,11 @@ import { useDispatch, useSelector } from "react-redux"; ...@@ -4,11 +4,11 @@ import { useDispatch, useSelector } from "react-redux";
import { checkWishlist, deleteWishlist, getWishlists, toggleWishlist } from "../../redux/actions/activityAction"; import { checkWishlist, deleteWishlist, getWishlists, toggleWishlist } from "../../redux/actions/activityAction";
const WishlistComponent = ({ activityId, userId }) => { const WishlistComponent = ({ activityId, userId }) => {
const { wishlists } = useSelector(state => state.wishlists); const { wishlists, loading } = useSelector(state => state.wishlists);
const [isActive, setisActive] = useState(false); const [isActive, setisActive] = useState(false);
const [wishlistId, setwishlistId] = useState(); const [wishlistId, setwishlistId] = useState();
const dispatch = useDispatch(); const dispatch = useDispatch();
// console.log("wishlists", wishlists); // console.log("wishlists", wishlists);
useEffect(() => { useEffect(() => {
wishlists && wishlists &&
wishlists.length > 0 && wishlists.length > 0 &&
......
...@@ -2,12 +2,19 @@ import React from "react"; ...@@ -2,12 +2,19 @@ import React from "react";
import Layout from "../../../components/layout/Layout"; import Layout from "../../../components/layout/Layout";
import MyWhishList from "../../../components/user/MyWhishList"; import MyWhishList from "../../../components/user/MyWhishList";
import { useSelector } from "react-redux"; import { useSelector } from "react-redux";
import { Skeleton } from "antd";
export default function UserProfilePage() { export default function UserProfilePage() {
const { wishlists } = useSelector(state => state.wishlists)
return (
<Layout>
<MyWhishList data={wishlists}/>
</Layout>
);
};
\ No newline at end of file \ No newline at end of file
const { wishlists, loading } = useSelector(state => state.wishlists);
return (
<Layout>
{loading ? (
<div>
<Skeleton active />
</div>
) : (
<MyWhishList data={wishlists} />
)}
</Layout>
);
}
...@@ -530,7 +530,8 @@ export const getWishlists = ...@@ -530,7 +530,8 @@ export const getWishlists =
return; return;
} }
dispatch({ dispatch({
type: GET_WISHLISTS_REQUEST type: GET_WISHLISTS_REQUEST,
loading: true
}); });
const config = { const config = {
headers: { headers: {
...@@ -557,7 +558,8 @@ export const getWishlists = ...@@ -557,7 +558,8 @@ export const getWishlists =
const response = await axios.get(`${process.env.NEXT_PUBLIC_BACKEND_API_URL}/api/wishlists?${queryString}`, config); const response = await axios.get(`${process.env.NEXT_PUBLIC_BACKEND_API_URL}/api/wishlists?${queryString}`, config);
dispatch({ dispatch({
type: GET_WISHLISTS_SUCCESS, type: GET_WISHLISTS_SUCCESS,
payload: response.data.data payload: response.data.data,
loading: false
}); });
return response.data.data; return response.data.data;
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!