From 72eca494b0b16a2b942bc44c604b546d3fbf8644 Mon Sep 17 00:00:00 2001 From: ALi Josheghani Date: Wed, 30 Oct 2024 11:32:53 +0330 Subject: [PATCH] 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. --- src/layout/index.tsx | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/layout/index.tsx b/src/layout/index.tsx index 4d10a8d..2bc1339 100644 --- a/src/layout/index.tsx +++ b/src/layout/index.tsx @@ -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) => (