From c18c4ebd2c25d7dc92d5ae1c35e1bfe5d29706f5 Mon Sep 17 00:00:00 2001 From: karthikalakshmi Date: Fri, 13 Feb 2026 12:47:25 +0530 Subject: [PATCH] Fix#140 One month free Plan Updated --- src/App.jsx | 5 +- src/Pages/BookingScreen/BookingPage.jsx | 4 + .../Template/BSLayout1/BSLayout1.jsx | 25 +- .../Template/BSLayout2/BSLayout2.jsx | 23 +- .../Template/BSLayout3/BSLayout3.jsx | 21 +- .../Template/BSLayout4/BSLayout4.jsx | 23 +- .../Template/BSLayout5/BSLayout5.jsx | 26 +- .../Template/BSLayout6/BSLayout6.jsx | 31 +- .../Template/BSLayout7/BSCombo1.jsx | 22 +- .../Template/PlanExpireNotification.jsx | 396 ++++++------------ .../ExtentedModal/ExtendSubscriptionModal.jsx | 120 +++++- 11 files changed, 285 insertions(+), 411 deletions(-) diff --git a/src/App.jsx b/src/App.jsx index 38f781c..69ae4f7 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -27,7 +27,7 @@ import ExtendSubscriptionModal from './Pages/ExtentedModal/ExtendSubscriptionMod const AppRoutes = () => { const ItemCard = useSelector(GlobalItemCard); const { sessionData, logout } = useSessionManager(ItemCard); - const { remainingDays, handleCancel, handlePay, freeExtend, extendModel } = useSubscriptionManager(sessionData, logout); + const { remainingDays, handleCancel, freeExtend, extendModel,setExtendModel } = useSubscriptionManager(sessionData, logout); useEffect(() => { const handlePopState = () => { @@ -69,8 +69,7 @@ const AppRoutes = () => { return ( ); } diff --git a/src/Pages/BookingScreen/BookingPage.jsx b/src/Pages/BookingScreen/BookingPage.jsx index dcf8963..9dd1004 100644 --- a/src/Pages/BookingScreen/BookingPage.jsx +++ b/src/Pages/BookingScreen/BookingPage.jsx @@ -72,6 +72,8 @@ const BookingPage = () => { const UserType = getSession('UserType'); const AuthToken = sessionStorage.getItem('auth'); const SessionMobileNo = getSession('MobileNo'); + const UserName = getSession("UserName"); + const SessionId =getSession("SessionId") const FeatureAddonData = useSelector(GlobalFeatAddOnData); const Scantemplatedata = useSelector(GlobalScanTemplate); @@ -128,6 +130,8 @@ const BookingPage = () => { AuthToken, SessionMobileNo, FeatureAddonData, + UserName, + SessionId }; dispatch(changeSessionData(SessionData)); }, [BranchId, FeatureAddonData]); diff --git a/src/Pages/BookingScreen/Template/BSLayout1/BSLayout1.jsx b/src/Pages/BookingScreen/Template/BSLayout1/BSLayout1.jsx index 19cf74e..276b81b 100644 --- a/src/Pages/BookingScreen/Template/BSLayout1/BSLayout1.jsx +++ b/src/Pages/BookingScreen/Template/BSLayout1/BSLayout1.jsx @@ -92,8 +92,6 @@ const BSLayout1 = () => { const BranchId = SessionData?.BranchId; const UserId = SessionData?.UserId; const UserType = SessionData?.UserType; - const AppName = SessionData?.AppName; - const GlobalLayoutColorDetail = useSelector(SelectedGlobalLayoutColorDetail); const GlobalsalesDetailData = useSelector(GlobalSalesDetailData); const SelectedCatgColor = useSelector(SelectedGlobalCatgColorDetail); @@ -134,7 +132,7 @@ const BSLayout1 = () => { const SelectedBillColor = useSelector(SelectedGlobalBillingColorDetail); const currentDateValue = moment().format('YYYY-MM-DD HH:mm:ss'); - const [count, setcount] = useState(0); + const [popOverOpen, setPopOverOpen] = useState(false); const appPreferences = useSelector(ApplicationPreferences); const salespagefields = appPreferences?.find( @@ -159,16 +157,15 @@ const BSLayout1 = () => { (i) => i.SettingIdName === 'DineIn' )?.[0]; let containerHeight = isMobile - ? AppExpDate?.RemainingDays <= 7 + ? AppExpDate?.RemainingDays <= 7 || AppExpDate?.PlanType?.toLowerCase() === 'extend' ? '575px' : '595px' : UserType != 'Super Admin' && UserType != 'Super Admin User' && - AppExpDate?.RemainingDays <= 7 + AppExpDate?.RemainingDays <= 7 || AppExpDate?.PlanType?.toLowerCase() === 'extend' ? '96vh' : '99vh'; - const animations = ['example1', 'example2', 'example3']; - let ss = animations[count]; + useEffect(() => { if (AppId && CompId && BranchId && UserId) { @@ -227,15 +224,7 @@ const BSLayout1 = () => { // setBadgeCount(length); }; - useEffect(() => { - if (AppExpDate?.RemainingDays <= 7) { - const interval = setInterval(() => { - setcount((prevCount) => (prevCount >= 2 ? 0 : prevCount + 1)); - }, 22000); - return () => clearInterval(interval); - } - }, [count == 2]); - + const onComplete = useCallback(() => { setMessageData(null); @@ -317,8 +306,8 @@ const BSLayout1 = () => { /> {UserType != 'Super Admin' && UserType != 'Super Admin User' && - (AppExpDate?.RemainingDays <= 7 || AppExpDate === 'undefined') && ( - + (AppExpDate?.RemainingDays <= 7 || AppExpDate === 'undefined' || AppExpDate?.PlanType?.toLowerCase() === 'extend') && ( + )}
{ (i) => i.SettingIdName === 'DineIn' )?.[0]; let containerHeight = isMobile - ? AppExpDate?.RemainingDays <= 7 + ? AppExpDate?.RemainingDays <= 7 || AppExpDate?.PlanType?.toLowerCase() === 'extend' ? '575px' : '' : UserType != 'Super Admin' && UserType != 'Super Admin User' && - AppExpDate?.RemainingDays <= 7 + AppExpDate?.RemainingDays <= 7 || AppExpDate?.PlanType?.toLowerCase() === 'extend' ? '96vh' : '99vh'; - const animations = ['example1', 'example2', 'example3']; - const [count, setcount] = useState(0); + const [ListOfInvoices, setListOfInvoices] = useState(false); const appPreferences = useSelector(ApplicationPreferences); const salespagefields = appPreferences?.find( @@ -211,7 +210,6 @@ const BSLayout2 = () => { preference?.PreferredStatus == 'Y' ); - let ss = animations[count]; useEffect(() => { fetchAmount(); @@ -228,16 +226,7 @@ const BSLayout2 = () => { fetchBookingStatus(); } }, [AppId, CompId, BranchId, UserId]); - useEffect(() => { - if (AppExpDate?.RemainingDays <= 7) { - const interval = setInterval(() => { - setcount((prevCount) => (prevCount >= 2 ? 0 : prevCount + 1)); - }, 22000); - - return () => clearInterval(interval); - } - }, [count == 2]); - + const fetchAmount = async () => { let data = { CompId: CompId, @@ -345,9 +334,9 @@ const BSLayout2 = () => {
{UserType != 'Super Admin' && UserType != 'Super Admin User' && - (AppExpDate?.RemainingDays <= 7 || AppExpDate === 'undefined') && ( + (AppExpDate?.RemainingDays <= 7 || AppExpDate === 'undefined' || AppExpDate?.PlanType?.toLowerCase() === 'extend') && ( Loading...
}> - + )}
{ const AppExpDate = useSelector(GlobalAppExpDateData); // const [AppExpDate, setAppExpDate] = useState(0); const [Kioskopen, setKioskopen] = useState(false); - const [count, setcount] = useState(0); const BookingStatus = useSelector(GlobalBookingStatus); const appPreferences = useSelector(ApplicationPreferences); const commonModulePreference = appPreferences?.find( @@ -125,8 +124,7 @@ const BSLayout3 = () => { const BookingSubCategory = BSLayout3Data?.BookingSubCategory; const BookingCard = BSLayout3Data?.BookingCard; const BookingBilling = BSLayout3Data?.BookingBilling?.[0]; - const animations = ['example1', 'example2', 'example3']; - let ss = animations[count]; + const DineInAccess = SettingDataSelector?.[0]?.SettingDtlDetails.filter( (i) => i.SettingIdName === 'DineIn' )?.[0]; @@ -138,12 +136,12 @@ const BSLayout3 = () => { const UserType = SessionData?.UserType; const currentDateValue = moment().format('YYYY-MM-DD HH:mm:ss'); let containerHeight = isMobile - ? AppExpDate?.RemainingDays <= 7 + ? AppExpDate?.RemainingDays <= 7 || AppExpDate?.PlanType?.toLowerCase() === 'extend' ? '576px' : '590px' : UserType != 'Super Admin' && UserType != 'Super Admin User' && - AppExpDate?.RemainingDays <= 7 + AppExpDate?.RemainingDays <= 7 || AppExpDate?.PlanType?.toLowerCase() === 'extend' ? '95vh' : '99vh'; const SAdminuserPin = useSelector(GLobalSadminUserPin); @@ -164,14 +162,7 @@ const BSLayout3 = () => { } }, [SessionData]); - useEffect(() => { - if (AppExpDate?.RemainingDays <= 7) { - const interval = setInterval(() => { - setcount((prevCount) => (prevCount >= 2 ? 0 : prevCount + 1)); - }, 22000); - return () => clearInterval(interval); - } - }, [count == 2]); + const fetchKioskDatas = async () => { let data = { CompId: CompId, @@ -278,8 +269,8 @@ const BSLayout3 = () => { /> {UserType != 'Super Admin' && UserType != 'Super Admin User' && - (AppExpDate?.RemainingDays <= 7 || AppExpDate === 'undefined') && ( - + (AppExpDate?.RemainingDays <= 7 || AppExpDate === 'undefined' || AppExpDate?.PlanType?.toLowerCase() === 'extend') && ( + )}
{ const dispatch = useDispatch(); @@ -111,7 +110,6 @@ const BSLayout4 = () => { ); // const [AppExpDate, setAppExpDate] = useState(0); const [Kioskopen, setKioskopen] = useState(false); - const [count, setcount] = useState(0); const BookingStatus = useSelector(GlobalBookingStatus); const CheckBookingStatus = BookingStatus?.find((item) => item.ScreenType === 'Booking') @@ -122,11 +120,9 @@ const BSLayout4 = () => { const BookingCard = BSLayout4Data?.BookingCard; const BookingBilling = BSLayout4Data?.BookingBilling?.[0]; console.log('BSLayout4Data', BookingBilling); - const animations = ['example1', 'example2', 'example3']; const DineInAccess = SettingDataSelector?.[0]?.SettingDtlDetails.filter( (i) => i.SettingIdName === 'DineIn' )?.[0]; - const AppName = SessionData?.AppName; const AppId = SessionData?.AppId; const CompId = SessionData?.CompId; const BranchId = SessionData?.BranchId; @@ -134,15 +130,14 @@ const BSLayout4 = () => { const UserType = SessionData?.UserType; const currentDateValue = moment().format('YYYY-MM-DD HH:mm:ss'); let containerHeight = isMobile - ? AppExpDate?.RemainingDays <= 7 + ? AppExpDate?.RemainingDays <= 7 || AppExpDate?.PlanType?.toLowerCase() === 'extend' ? '575px' : '590px' : UserType != 'Super Admin' && UserType != 'Super Admin User' && - AppExpDate?.RemainingDays <= 7 + AppExpDate?.RemainingDays <= 7 || AppExpDate?.PlanType?.toLowerCase() === 'extend' ? '96vh' : '99vh'; - let ss = animations[count]; const [ListOfInvoices, setListOfInvoices] = useState(false); useEffect(() => { @@ -160,15 +155,7 @@ const BSLayout4 = () => { fetchBookingStatus(); } }, [AppId, CompId, BranchId, UserId]); - useEffect(() => { - if (AppExpDate?.RemainingDays <= 7) { - const interval = setInterval(() => { - setcount((prevCount) => (prevCount >= 2 ? 0 : prevCount + 1)); - }, 22000); - return () => clearInterval(interval); - } - }, [count == 2]); const OpenListOfInvoices = () => { setListOfInvoices(true); }; @@ -278,8 +265,8 @@ const BSLayout4 = () => { /> {UserType != 'Super Admin' && UserType != 'Super Admin User' && - (AppExpDate?.RemainingDays <= 7 || AppExpDate === 'undefined') && ( - + (AppExpDate?.RemainingDays <= 7 || AppExpDate === 'undefined' || AppExpDate?.PlanType?.toLowerCase() === 'extend') && ( + )}
{ const dispatch = useDispatch(); @@ -107,7 +106,6 @@ const BSLayout5 = () => { // const [AppExpDate, setAppExpDate] = useState(0); const [screenHeight, setScreenHeight] = useState(window.innerHeight); const [Kioskopen, setKioskopen] = useState(false); - const [count, setcount] = useState(0); const PricingAppPricingName = useSelector(GlobalPricingAppPricingName); const SAdminuserPin = useSelector(GLobalSadminUserPin); const BookingNavbar = BSLayout5Data?.BookingNavbar?.[0]; @@ -117,22 +115,20 @@ const BSLayout5 = () => { const DineInAccess = SettingDataSelector?.[0]?.SettingDtlDetails.filter( (i) => i.SettingIdName === 'DineIn' )?.[0]; - const AppName = SessionData?.AppName; const AppId = SessionData?.AppId; const CompId = SessionData?.CompId; const BranchId = SessionData?.BranchId; const UserId = SessionData?.UserId; const UserType = SessionData?.UserType; const currentDateValue = moment().format('YYYY-MM-DD HH:mm:ss'); - const animations = ['example1', 'example2', 'example3']; - let ss = animations[count]; + let containerHeight = isMobile - ? AppExpDate?.RemainingDays <= 7 + ? AppExpDate?.RemainingDays <= 7 || AppExpDate?.PlanType?.toLowerCase() === 'extend' ? '580px' : '590px' : UserType != 'Super Admin' && UserType != 'Super Admin User' && - AppExpDate?.RemainingDays <= 7 + AppExpDate?.RemainingDays <= 7 || AppExpDate?.PlanType?.toLowerCase() === 'extend' ? '96vh' : '99vh'; const [ListOfInvoices, setListOfInvoices] = useState(false); @@ -160,15 +156,7 @@ const BSLayout5 = () => { fetchKioskDatas(); } }, [SessionData]); - useEffect(() => { - if (AppExpDate?.RemainingDays <= 7) { - const interval = setInterval(() => { - setcount((prevCount) => (prevCount >= 2 ? 0 : prevCount + 1)); - }, 22000); - return () => clearInterval(interval); - } - }, [count == 2]); useEffect(() => { if (AppId && CompId && BranchId && UserId) { fetchBookingStatus(); @@ -293,8 +281,8 @@ const BSLayout5 = () => { /> {UserType != 'Super Admin' && UserType != 'Super Admin User' && - (AppExpDate?.RemainingDays <= 7 || AppExpDate === 'undefined') && ( - + (AppExpDate?.RemainingDays <= 7 || AppExpDate === 'undefined' || AppExpDate?.PlanType?.toLowerCase() === 'extend') && ( + )}
{ const AppExpDate = useSelector(GlobalAppExpDateData); const [screenHeight, setScreenHeight] = useState(window?.innerHeight); // const [AppExpDate, setAppExpDate] = useState(0); - const [count, setcount] = useState(0); const BookingNavbar = BSLayout6Data?.BookingNavbar?.[0]; const BookingCategory = BSLayout6Data?.BookingCategory; const BookingCard = BSLayout6Data?.BookingCard; const BookingBilling = BSLayout6Data?.BookingBilling?.[0]; - const AppName = SessionData?.AppName; const AppId = SessionData?.AppId; const CompId = SessionData?.CompId; const BranchId = SessionData?.BranchId; @@ -154,15 +149,7 @@ const BSLayout6 = () => { } }, [SessionData]); - useEffect(() => { - if (AppExpDate?.RemainingDays <= 7) { - const interval = setInterval(() => { - setcount((prevCount) => (prevCount >= 2 ? 0 : prevCount + 1)); - }, 22000); - - return () => clearInterval(interval); - } - }, [count == 2]); + useEffect(() => { if (AppId && CompId && BranchId && UserId) { fetchBookingStatus(); @@ -198,18 +185,16 @@ const BSLayout6 = () => { }; let containerHeight = isMobile - ? AppExpDate?.RemainingDays <= 7 + ? AppExpDate?.RemainingDays <= 7 || AppExpDate?.PlanType?.toLowerCase() === 'extend' ? '577px' : '595px' : UserType != 'Super Admin' && UserType != 'Super Admin User' && - AppExpDate?.RemainingDays <= 7 + AppExpDate?.RemainingDays <= 7 || AppExpDate?.PlanType?.toLowerCase() === 'extend' ? '96vh' : '99vh'; - const animations = ['example1', 'example2', 'example3']; - - let ss = animations[count]; + useEffect(() => { function handleResize() { setScreenHeight(window.innerHeight); @@ -300,8 +285,8 @@ const BSLayout6 = () => { /> {UserType != 'Super Admin' && UserType != 'Super Admin User' && - (AppExpDate?.RemainingDays <= 30 || AppExpDate === 'undefined') && ( - + (AppExpDate?.RemainingDays <= 30 || AppExpDate === 'undefined' || AppExpDate?.PlanType?.toLowerCase() === 'extend') && ( + )}
{ - if (AppExpDate?.RemainingDays <= 7) { - const interval = setInterval(() => { - setcount((prevCount) => (prevCount >= 2 ? 0 : prevCount + 1)); - }, 22000); - - return () => clearInterval(interval); - } - }, [count == 2]); + useEffect(() => { Combodata(); if (AppId && CompId && BranchId && UserId) { @@ -298,8 +284,8 @@ export default function BSCombo1() { /> {UserType != 'Super Admin' && UserType != 'Super Admin User' && - (AppExpDate?.RemainingDays <= 7 || AppExpDate === 'undefined') && ( - + (AppExpDate?.RemainingDays <= 7 || AppExpDate === 'undefined' || AppExpDate?.PlanType?.toLowerCase() === 'extend') && ( + )} {/* Combo Container */} diff --git a/src/Pages/BookingScreen/Template/PlanExpireNotification.jsx b/src/Pages/BookingScreen/Template/PlanExpireNotification.jsx index 1f6838a..1adef66 100644 --- a/src/Pages/BookingScreen/Template/PlanExpireNotification.jsx +++ b/src/Pages/BookingScreen/Template/PlanExpireNotification.jsx @@ -1,222 +1,62 @@ -// import { useSelector } from "react-redux"; -// import { GlobalAppExpDateData } from "../../../Features/BookingScreen/BookingData/BookingData"; -// import { useNavigate } from "react-router-dom"; -// import { ArrowUpOutlined } from '@ant-design/icons'; -// import { StoredSessionData } from "../../../Features/ThemeChange/ThemeChange"; -// import ExtendSubscriptionModal from "../../ExtentedModal/ExtendSubscriptionModal"; -// import { useDispatch } from "react-redux"; -// import { getPurchasedAppDetails, postInvoice } from "../../../Features/BookingScreen/Pricing/Pricing"; -// import { sendSms } from "../../../Features/Payment/PaymentDetails/PaymentDetails"; -// import { useState } from "react"; -// const subDirectory = import.meta.env.BASE_URL; -// const commonDirectory = import.meta.env.COMMON_BASE_URL; - -// const PlanExpireNotification = ({ss}) => { -// const navigate = useNavigate(); -// const dispatch = useDispatch(); - -// const AppExpDate = useSelector(GlobalAppExpDateData); -// const SessionData = useSelector(StoredSessionData); -// const [extendModel, setExtendModel] = useState(false); -// console.log("AppExpDate", AppExpDate); -// const navigateFun = () => { -// navigate(`${subDirectory}PricingPage`, { state: { AppName: SessionData?.AppName } }); -// }; - -// const navigatePublicFun = () => { -// navigate(`${commonDirectory}`); -// }; -// const formatDate = (dateStr) => { -// const date = new Date(dateStr); -// const year = date.getFullYear(); -// const month = String(date.getMonth() + 1).padStart(2, '0'); // Months are 0-based -// const day = String(date.getDate()).padStart(2, '0'); -// return `${day}-${month}-${year}`; -// }; -// const freeExtend = async () => { -// try { -// const { CompId, AppId, BranchId, UserType,UserId } = SessionData; - -// // Current date -// const now = new Date(); -// const currentDate = formatDate(now); - -// // 1️⃣ Get purchased app details -// const response1 = await dispatch( -// getPurchasedAppDetails({ AppId, UserId }) -// ).unwrap(); - -// const PurchasedDetails = response1?.data?.data; - -// if (!PurchasedDetails || !PurchasedDetails.length) { -// console.error('No purchased details found'); -// return; -// } - -// // 2️⃣ Prepare post data -// const postData = { -// UserId: UserId, -// AppId: AppId, -// PricingId: PurchasedDetails[0]?.PricingId, -// PurDate: currentDate, -// NoofDays: 30, -// PaymentMode: 27, -// PaymentStatus: 'S', -// LicenseStatus: PurchasedDetails[0]?.LicenseStatus, -// Price: PurchasedDetails[0]?.Price ?? 0, -// TaxId: PurchasedDetails[0]?.TaxId ?? 0, -// NetPrice: PurchasedDetails[0]?.ExistingPlanNetPrice ?? 0, -// ValidityStart: currentDate, -// ValidityEnd: addDays( -// currentDate, -// PurchasedDetails[0]?.NoOfDays -// ), -// CreatedBy: UserId, -// TaxAmount: PurchasedDetails[0]?.TaxAmount ?? 0, -// MobileNo: getSession('MobileNo'), -// MailId: 'ts@gmmail.com', -// Type: "FreeExtend" -// }; - -// // 3️⃣ Post invoice -// const response = await dispatch(postInvoice(postData)).unwrap(); - -// // 4️⃣ Send SMS if required -// if (response?.data?.statusCode === 1 && response?.data?.SMSbody) { -// await dispatch( -// sendSms({ body: response.data.SMSbody }) -// ); -// setExtendModel(false) - -// } - -// } catch (error) { -// console.error('freeExtend error:', error); -// } -// }; -// const handleCancel = () => { -// Logout(); -// setExtendModel(false) - -// } -// const handlePay = () => { -// setExtendModel(false) -// let AppName = getSession("AppName") -// navigate(`${subDirectory}PricingPage`, { state: { AppName: AppName } }); -// } - -// return( -// <> -//
-//

-// {(AppExpDate?.RemainingDays < 30 && -// AppExpDate?.RemainingHours < 30 && -// AppExpDate?.RemainingMinutes < 50 && -// AppExpDate?.RemainingSeconds < 60 -// ) || -// AppExpDate === 'undefined' ? ( -// (AppExpDate?.PlanType?.toLowerCase() == "extend expired")?( - -// -// Subscription expired   -// { -// navigatePublicFun(); -// }} -// className="upgrdbtn" -// > -// RENEWAL NOW -// -// -// ) : ( - -// ) -// ) : AppExpDate?.RemainingDays < 1 ? ( -//

-// Your application subscription will expire within   -// -// {AppExpDate?.RemainingHours >= 1 -// ? AppExpDate?.RemainingHours -// : AppExpDate?.RemainingMinutes} -// {' '} -// {AppExpDate?.RemainingHours >= 1 ? 'Hrs' : 'Min'} .   -// { -// navigateFun(); -// }} -// className="upgrdbtn" -// > -// RENEWAL NOW -// -//

-// ) : ( -//

-// Your application subscription will expire within   -// -// {AppExpDate?.RemainingDays} -// {' '} -// days.   -// { -// navigateFun(); -// }} -// className="upgrdbtn" -// > -// RENEWAL NOW -// -//

-// )} -//

-//
-// {extendModel && ( -// -// )} -// -// ) -// } -// export default PlanExpireNotification; -import { useSelector } from "react-redux"; -import { GlobalAppExpDateData } from "../../../Features/BookingScreen/BookingData/BookingData"; -import { useNavigate } from "react-router-dom"; +import { useSelector } from 'react-redux'; +import { GlobalAppExpDateData } from '../../../Features/BookingScreen/BookingData/BookingData'; +import { useNavigate } from 'react-router-dom'; import { ArrowUpOutlined } from '@ant-design/icons'; -import { StoredSessionData } from "../../../Features/ThemeChange/ThemeChange"; -import ExtendSubscriptionModal from "../../ExtentedModal/ExtendSubscriptionModal"; -import { useDispatch } from "react-redux"; -import { getPurchasedAppDetails, postInvoice } from "../../../Features/BookingScreen/Pricing/Pricing"; -import { sendSms } from "../../../Features/Payment/PaymentDetails/PaymentDetails"; -import { useEffect, useState, useMemo } from "react"; -import { getSession } from "../../../Services/Others"; +import { StoredSessionData } from '../../../Features/ThemeChange/ThemeChange'; +import ExtendSubscriptionModal from '../../ExtentedModal/ExtendSubscriptionModal'; +import { useDispatch } from 'react-redux'; +import { + getPurchasedAppDetails, + postInvoice, +} from '../../../Features/BookingScreen/Pricing/Pricing'; +import { sendSms } from '../../../Features/Payment/PaymentDetails/PaymentDetails'; +import { useEffect, useState, useMemo } from 'react'; +import { encryptObject, getSession } from '../../../Services/Others'; +import { GenerateLogout } from '../../../Features/BrachLogin/BranchLogin'; +import { PublicQrCodepost } from '../../../Features/ConfigMasterPage/ConfigMasterPage'; -const subDirectory = import.meta.env.BASE_URL; -const commonDirectory = import.meta.env.COMMON_BASE_URL; - -const PlanExpireNotification = ({ ss }) => { +const subDirectory = import.meta.env.ENV_BASE_URL; +const commonDirectory = import.meta.env.ENV_COMMON_BASE_URL; +console.log('commonDirectory', commonDirectory); +const PlanExpireNotification = () => { const navigate = useNavigate(); const dispatch = useDispatch(); const AppExpDate = useSelector(GlobalAppExpDateData); const SessionData = useSelector(StoredSessionData); const [extendModel, setExtendModel] = useState(false); - const { AppId, UserId } = SessionData; - console.log("AppExpDate", AppExpDate); + const { + AppId, + UserId, + AppName, + SessionId, + AuthToken, + CompId, + SessionMobileNo, + UserName, + UserType, + } = SessionData; + console.log('SessionData', AppExpDate); + const [count, setcount] = useState(0); + const animations = ['example1', 'example2', 'example3']; + let ss = animations[count]; - // ================= NAVIGATION ================= - const navigateFun = () => { - navigate(`${subDirectory}PricingPage`, { state: { AppName: SessionData?.AppName } }); - }; - - const navigatePublicFun = () => { - navigate(`${commonDirectory}`); - }; + useEffect(() => { + if ( + AppExpDate?.RemainingDays <= 7 || + AppExpDate?.PlanType?.toLowerCase() === 'extend' + ) { + const interval = setInterval(() => { + setcount((prevCount) => (prevCount >= 2 ? 0 : prevCount + 1)); + }, 22000); + return () => clearInterval(interval); + } + }, [count == 2]); // ================= DATE FORMAT ================= const formatDate = (dateStr) => { const date = new Date(dateStr); - return `${String(date.getDate()).padStart(2, "0")}-${String(date.getMonth() + 1).padStart(2, "0")}-${date.getFullYear()}`; + return `${String(date.getDate()).padStart(2, '0')}-${String(date.getMonth() + 1).padStart(2, '0')}-${date.getFullYear()}`; }; // ================= CHECK STATUS FLAGS ================= @@ -229,115 +69,117 @@ const PlanExpireNotification = ({ ss }) => { ); }, [AppExpDate]); - const isExtendExpired = useMemo(() => { - return AppExpDate?.PlanType?.toLowerCase() === "extend expired"; + const isExtend = useMemo(() => { + return AppExpDate?.PlanType?.toLowerCase() === 'extend'; }, [AppExpDate]); - const isExpiringToday = AppExpDate?.RemainingDays < 1 && !isExpired; - const isExpiringSoon = AppExpDate?.RemainingDays >= 1 && AppExpDate?.RemainingDays <= 30; + const isExpiringToday = + AppExpDate?.RemainingDays < 1 && !isExpired && !isExtend; + const isExpiringSoon = + AppExpDate?.RemainingDays >= 1 && + AppExpDate?.RemainingDays <= 30 && + !isExtend; // ================= AUTO OPEN EXTEND MODAL ================= useEffect(() => { - if (isExpired && !isExtendExpired) { + if (isExpired && !isExtend) { setExtendModel(true); } - }, [isExpired, isExtendExpired]); - - // ================= FREE EXTEND ================= - const freeExtend = async () => { - try { - - const now = new Date();y - const currentDate = formatDate(now); - - const response1 = await dispatch(getPurchasedAppDetails({ AppId, UserId })).unwrap(); - const PurchasedDetails = response1?.data?.data; - - if (!PurchasedDetails?.length) return; - - const postData = { - UserId, - AppId, - PricingId: PurchasedDetails[0]?.PricingId, - PurDate: currentDate, - NoofDays: 30, - PaymentMode: 27, - PaymentStatus: "S", - LicenseStatus: PurchasedDetails[0]?.LicenseStatus, - Price: PurchasedDetails[0]?.Price ?? 0, - TaxId: PurchasedDetails[0]?.TaxId ?? 0, - NetPrice: PurchasedDetails[0]?.ExistingPlanNetPrice ?? 0, - ValidityStart: currentDate, - ValidityEnd: addDays(currentDate, PurchasedDetails[0]?.NoOfDays), - CreatedBy: UserId, - TaxAmount: PurchasedDetails[0]?.TaxAmount ?? 0, - MobileNo: getSession("MobileNo"), - MailId: "ts@gmail.com", - Type: "FreeExtend" - }; - - const response = await dispatch(postInvoice(postData)).unwrap(); - - if (response?.data?.statusCode === 1 && response?.data?.SMSbody) { - await dispatch(sendSms({ body: response.data.SMSbody })); - setExtendModel(false); - } - - } catch (error) { - console.error("freeExtend error:", error); - } - }; + }, [isExpired, isExtend]); const handleCancel = () => { Logout(); setExtendModel(false); }; - const Logout = async () => { - const UserId = UserId; + const Logout = async () => { const status = 'N'; try { const res = await dispatch(GenerateLogout({ UserId, status })).unwrap(); if (res?.data?.statusCode === 1) { sessionStorage.clear(); - window.location.replace(`${commonSubDir}`); + window.location.replace(`${commonDirectory}`); } } catch (error) { console.error('Logout failed:', error); } }; - const handlePay = () => { - setExtendModel(false); - navigate(`${subDirectory}PricingPage`, { state: { AppName: getSession("AppName") } }); + const handlePay = async () => { + const response1 = await dispatch( + getPurchasedAppDetails({ AppId, UserId }) + ).unwrap(); + const PurchasedDetails = response1?.data?.data; + let data = { + MN: SessionMobileNo, + UN: UserName, + UD: UserId, + UT: UserType, + CD: CompId, + SD: SessionId || '', + AU: AuthToken, + Plandetails: PurchasedDetails?.[0], + }; + const encrypted = encryptObject(data); + const postData = { Url: encrypted, CreatedBy: UserId }; + try { + const res = await dispatch(PublicQrCodepost(postData)).unwrap(); + // navigate(`${commonDirectory}invoice-details`); + if (res?.data?.statusCode == 1) { + navigate(`${commonDirectory}invoice-details/${res?.data?.ReferenceNo}`); + setExtendModel(false); + } + } catch (error) { + console.error('Error generating QR code:', error); + } }; // ================= UI BLOCKS ================= const ExpiredBlock = () => ( - +
Subscription expired   - + RENEWAL NOW - +
); const ExpiringTodayBlock = () => (

Your application subscription will expire within   - {AppExpDate?.RemainingHours >= 1 ? AppExpDate?.RemainingHours : AppExpDate?.RemainingMinutes} - {" "} - {AppExpDate?.RemainingHours >= 1 ? "Hrs" : "Min"}   - + {AppExpDate?.RemainingHours >= 1 + ? AppExpDate?.RemainingHours + : AppExpDate?.RemainingMinutes} + {' '} + {AppExpDate?.RemainingHours >= 1 ? 'Hrs' : 'Min'}   + RENEWAL NOW

); const ExpiringDaysBlock = () => ( -

+

Your application subscription will expire within   {AppExpDate?.RemainingDays} days.   - + RENEWAL NOW

@@ -346,8 +188,9 @@ const PlanExpireNotification = ({ ss }) => { // ================= RETURN ================= return ( <> -
- {isExpired && isExtendExpired && } + {/*
*/} +
+ {isExtend && } {isExpiringToday && } @@ -357,8 +200,9 @@ const PlanExpireNotification = ({ ss }) => { {extendModel && ( )} diff --git a/src/Pages/ExtentedModal/ExtendSubscriptionModal.jsx b/src/Pages/ExtentedModal/ExtendSubscriptionModal.jsx index 2dd1d48..0ee0c80 100644 --- a/src/Pages/ExtentedModal/ExtendSubscriptionModal.jsx +++ b/src/Pages/ExtentedModal/ExtendSubscriptionModal.jsx @@ -1,12 +1,124 @@ import { Tooltip } from "antd"; import "./extendSubscribtionModel.scss"; import { IoClose } from "react-icons/io5"; +import { getPurchasedAppDetails, postInvoice } from "../../Features/BookingScreen/Pricing/Pricing"; +import { GlobalAppExpDateData } from "../../Features/BookingScreen/BookingData/BookingData"; +import { StoredSessionData } from "../../Features/ThemeChange/ThemeChange"; +import { useNavigate } from "react-router-dom"; +import { useDispatch } from "react-redux"; +import { sendSms } from "../../Features/Payment/PaymentDetails/PaymentDetails"; +import { useSelector } from "react-redux"; +import { encryptObject } from "../../Services/Others"; +import { PublicQrCodepost } from "../../Features/ConfigMasterPage/ConfigMasterPage"; const ExtendSubscriptionModal = ({ onClose, - onPayNow, - onContinueWithCredits }) => { + const navigate = useNavigate(); + const dispatch = useDispatch(); + const SessionData = useSelector(StoredSessionData); + const { + AppId, + UserId, + AppName, + SessionId, + AuthToken, + CompId, + SessionMobileNo, + UserName, + UserType, + } = SessionData; + // ================= DATE FORMAT ================= + const formatDate = (dateStr) => { + const date = new Date(dateStr); + return `${String(date.getDate()).padStart(2, '0')}-${String(date.getMonth() + 1).padStart(2, '0')}-${date.getFullYear()}`; + }; + // ================= DATE ADDITION ================= + function addDays(dateString, days) { + // Make it ISO-safe for iOS / WebView + const isoDate = dateString.replace(' ', 'T'); + const currentDate = new Date(isoDate); + + currentDate.setDate(currentDate.getDate() + Number(days)); + + return formatDate(currentDate); + } + + + // ================= FREE EXTEND ================= + const freeExtend = async () => { + try { + const now = new Date(); + const currentDate = formatDate(now); + + const response1 = await dispatch( + getPurchasedAppDetails({ AppId, UserId }) + ).unwrap(); + const PurchasedDetails = response1?.data?.data; + + if (!PurchasedDetails?.length) return; + + const postData = { + UserId, + AppId, + PricingId: PurchasedDetails[0]?.PricingId, + PurDate: currentDate, + NoofDays: 30, + PaymentMode: 27, + PaymentStatus: 'S', + LicenseStatus: PurchasedDetails[0]?.LicenseStatus, + Price: PurchasedDetails[0]?.Price ?? 0, + TaxId: PurchasedDetails[0]?.TaxId ?? 0, + NetPrice: PurchasedDetails[0]?.ExistingPlanNetPrice ?? 0, + ValidityStart: currentDate, + ValidityEnd: addDays(currentDate, PurchasedDetails[0]?.NoOfDays), + CreatedBy: UserId, + TaxAmount: PurchasedDetails[0]?.TaxAmount ?? 0, + MobileNo: SessionMobileNo, + MailId: 'ts@gmail.com', + Type: 'FreeExtend', + }; + + const response = await dispatch(postInvoice(postData)).unwrap(); + + if (response?.data?.statusCode === 1 && response?.data?.SMSbody) { + await dispatch(sendSms({ body: response.data.SMSbody })); + setExtendModel(false) + + } + } catch (error) { + console.error('freeExtend error:', error); + } + }; + + const handlePay = async () => { + const response1 = await dispatch( + getPurchasedAppDetails({ AppId, UserId }) + ).unwrap(); + const PurchasedDetails = response1?.data?.data; + let data = { + MN: SessionMobileNo, + UN: UserName, + UD: UserId, + UT: UserType, + CD: CompId, + SD: SessionId || "3308120220260447406469360642222", + AU: AuthToken, + Plandetails: PurchasedDetails?.[0], + }; + const encrypted = encryptObject(data); + const postData = { Url: encrypted, CreatedBy: UserId }; + try{ + const res = await dispatch(PublicQrCodepost(postData)).unwrap(); + // navigate(`${commonDirectory}invoice-details`); + if (res?.data?.statusCode == 1) { + navigate(`${commonDirectory}invoice-details/${res?.data?.ReferenceNo}`); + setExtendModel(false) + + } + }catch(error){console.error('Error generating QR code:', error); } + }; + return (
@@ -28,14 +140,14 @@ const ExtendSubscriptionModal = ({