From d94188656efbba98de20c5ebac5b9100416d3b69 Mon Sep 17 00:00:00 2001 From: Srinath Date: Wed, 4 Feb 2026 13:42:27 +0530 Subject: [PATCH] added Offer catelogue --- .../ProductCatlogue/CatalogueTemplate3.jsx | 613 ++---------------- 1 file changed, 53 insertions(+), 560 deletions(-) diff --git a/src/Pages/ProductCatlogue/CatalogueTemplate3.jsx b/src/Pages/ProductCatlogue/CatalogueTemplate3.jsx index 2346381..9e6dd8b 100644 --- a/src/Pages/ProductCatlogue/CatalogueTemplate3.jsx +++ b/src/Pages/ProductCatlogue/CatalogueTemplate3.jsx @@ -1,595 +1,88 @@ import React, { useEffect, useState } from 'react'; import { useSelector, useDispatch } from 'react-redux'; -import { printDiv, getSession } from '../../Services/Others'; -import shopico from '../../Images/Assets/shop.png'; - -import { - GlobalCataloguedata, - Branchname, -} from '../../Features/ProductCatlog/ProductCatlogue'; -import Footerimg from '../../Images/cate-f.png'; +import { GlobalCataloguedata, Branchname } from '../../Features/ProductCatlog/ProductCatlogue'; import best from '../../Images/Assets/Cateloge3HeaderImage.svg'; import '../../Styles/ProductCatalogue/CatalogueTemplate3.scss'; -// import "../../Fonts/OtherFonts/Roboto_Slab/RobotoSlab-VariableFont_wght.ttf" import { FaPhoneVolume } from 'react-icons/fa'; import { FaLocationDot } from 'react-icons/fa6'; +import { getSession } from '../../Services/Others'; -const CatelogueTemplate5 = () => { +const CatelogueTemplate3 = () => { const dispatch = useDispatch(); const BrId = getSession('BranchId'); const Globalcataloguedata1 = useSelector(GlobalCataloguedata); const [Branchdatas, setBranchdatas] = useState(); - const [base64Image, setBase64Image] = useState(null); - - const printDocument = () => { - window.print(); - }; useEffect(() => { + const Branchdata = async () => { + const response = await dispatch(Branchname({ BrId })).unwrap(); + if (response?.data?.statusCode === 1) { + setBranchdatas(response?.data?.data); + } + }; Branchdata(); - }, []); + }, [BrId, dispatch]); - const Branchdata = async () => { - let data = { BrId: BrId }; - - const response = await dispatch(Branchname(data)).unwrap(); - if (response?.data?.statusCode == 1) { - setBranchdatas(response?.data?.data); - } - }; - - function safeRound(amountStr) { + const safeRound = (amountStr) => { if (amountStr == null) return '0.00'; - const cleaned = String(amountStr).replace(/[^0-9.-]+/g, ''); const num = Number(cleaned); - - return isNaN(num) ? '0.00' : num.toFixed(2); // return as string with 2 decimals - } - - useEffect(() => { - async function fetchImage() { - try { - const base64 = await imageUrlToBase64(Branchdatas?.[0]?.CompLogo); - setBase64Image(base64); - } catch (error) { - console.log('Error converting image', error.message); - } - } - if (Branchdatas?.[0]?.CompLogo) { - fetchImage(); - } - }, [Branchdatas?.[0]?.CompLogo]); - - const imageUrlToBase64 = async (url) => { - try { - const response = await fetch(url); - const blob = await response.blob(); - return new Promise((resolve, reject) => { - const reader = new FileReader(); - reader.onloadend = () => resolve(reader.result); - reader.onerror = reject; - reader.readAsDataURL(blob); - }); - } catch (error) { - console.error('Error fetching or converting image:', error); - throw error; - } - }; - - const style = ``; - - const PrintA4 = async () => { - await printDiv('CatelogueTemplate5', style); + return isNaN(num) ? '0.00' : num.toFixed(2); }; return ( -
- {/*
- {Branchdatas?.map((item) => ( -
-
-
-
- {item.BrName} -
-
-
{item.BrMobile}
-
- {item.Address1 != null && item.Address1 + ','}{item.City != null && item.City + ','}{item.Dist != null && item.Dist + ','}{item.State != null && item.State} +
+
+ {/* Branch Header */} +
+ {Branchdatas?.map((item, index) => ( +
+
+
{item.BrName}
+ {item.BrMobile && ( +
+ {item.BrMobile}
-
-
-
-
- -
BEST DEALS
-
-
- ))} - - - - - - - - - - - - -
-
-
-
-
- - - -
- {Globalcataloguedata1?.map((item) => ( -
-
- -
-
- {item?.ProdName} {item?.UomName} -
-
- - {item?.SellPrice} -
-
- ))} -
- - -
-
-
-
*/} - -
-
- {Branchdatas?.map((item) => ( - <> -
-
-
- {item.BrName} + )} + {(item.Address1 || item.City || item.Dist || item.State) && ( +
+ + {item.Address1 && item.Address1 + ', '} + {item.City && item.City + ', '} + {item.Dist && item.Dist + ', '} + {item.State && item.State}
- {/*
{item.BrMobile}
*/} - {item.BrMobile && ( -
- {item.BrMobile} -
- )} -
- {/* {item.Address1 != null && item.Address1 + ','}{item.City != null && item.City + ','}{item.Dist != null && item.Dist + ','}{item.State != null && item.State} */} - {(item.Address1 || - item.City || - item.Dist || - item.State) && ( -
- - {item.Address1 && item.Address1 + ', '} - {item.City && item.City + ', '} - {item.Dist && item.Dist + ', '} - {item.State && item.State} -
- )} -
-
- - - - - FRESH
DEALS -
+ )}
- + + logo + +
+ FRESH
DEALS +
+
))}
- {/*
-
-
- -

{Branchdatas?.[0]?.BrName}

+ {/* Catalogue Grid */} +
+ {Globalcataloguedata1?.map((item, index) => ( +
+
+ {item?.ProdName} {item?.UomName}
- -
- -
-
-
FREE HOME
-
DELEVERY
-
-
-
-
-
*/} + {item?.ProdLogo && ( + {item?.ProdName} + )} - - - - - - - - - - - - - - - - - - -
-
- {' '} -
-
-
-
- {Globalcataloguedata1?.map((item) => ( - <> - - - ))} -
-
-
-
-
+
₹{safeRound(item?.SellPrice)}
+
+ ))} +
); }; -export default CatelogueTemplate5; +export default CatelogueTemplate3;