feat: Add shop ID to layout component

This commit adds functionality to the layout component to retrieve the shop ID from the URL query parameters and dispatch it to the Redux store using the setShopId action.
This commit is contained in:
ALi Josheghani
2024-10-30 11:32:53 +03:30
parent 0be0abaf9a
commit 72eca494b0

View File

@@ -6,10 +6,14 @@ import { Helmet } from "react-helmet-async";
import { useEffect } from "react";
import { useDispatch } from "react-redux";
import { setConfigId } from "../redux/slices/configId";
import { setShopId } from "../redux/slices/shop-id";
// import toast from "react-hot-toast";
const Layout = () => {
const { configs } = useParams<{ configs: string }>();
const shopId = new URLSearchParams(window.location.search).get("shop_id");
const dispatch = useDispatch();
useEffect(() => {
if (configs === "1" || configs === "2" || configs === "3") {
@@ -26,6 +30,12 @@ const Layout = () => {
}, 100); // Scroll to 100% of the page height
}, [configs, dispatch]);
useEffect(() => {
if (shopId) {
dispatch(setShopId(shopId));
}
}, [shopId, dispatch]);
// useEffect(() => {
// toast.custom(
// (t) => (