#210 Plan Expire Modal and Redirection Issue solving

This commit is contained in:
karthikalakshmi 2026-03-03 10:27:23 +05:30
parent b27a87d389
commit 749d7286d0
9 changed files with 90 additions and 47 deletions

View File

@ -102,9 +102,8 @@ const ComboSalesBillTable = lazy(
import('../../Components/BSBillingTables/ComboSalesBillTable/ComboSalesBillTable.jsx') import('../../Components/BSBillingTables/ComboSalesBillTable/ComboSalesBillTable.jsx')
); );
const SalesCountComponent = lazy(() => import('../SalesCountComponent.jsx')); const SalesCountComponent = lazy(() => import('../SalesCountComponent.jsx'));
const PlanExpireNotification = lazy( // const PlanExpireNotification = lazy(() => import('../PlanExpireNotification.jsx'));
() => import('../PlanExpireNotification.jsx') import PlanExpireNotification from '../PlanExpireNotification.jsx';
);
const BSLayout1 = () => { const BSLayout1 = () => {
const dispatch = useDispatch(); const dispatch = useDispatch();
@ -320,8 +319,7 @@ const BSLayout1 = () => {
setListOfInvoices(false); setListOfInvoices(false);
}; };
return ( return (
<Suspense fallback={<CardSkeleton />}> <Suspense fallback={<CardSkeleton />}>
{' '}
<> <>
<Messages <Messages
messageType={messageType} messageType={messageType}
@ -673,7 +671,7 @@ const BSLayout1 = () => {
/> />
)} )}
</> </>
</Suspense> </Suspense>
); );
}; };

View File

@ -133,10 +133,10 @@ const BranchTransferComponent = lazy(
const BSExpireProductsList = lazy( const BSExpireProductsList = lazy(
() => import('../../Components/UtillComponents/BSExpireProductsList.jsx') () => import('../../Components/UtillComponents/BSExpireProductsList.jsx')
); );
const PlanExpireNotification = lazy( // const PlanExpireNotification = lazy(
() => import('../PlanExpireNotification.jsx') // () => import('../PlanExpireNotification.jsx')
); // );
import PlanExpireNotification from '../PlanExpireNotification.jsx';
const BSLayout2 = () => { const BSLayout2 = () => {
const dispatch = useDispatch(); const dispatch = useDispatch();
const elementRef = useRef(null); const elementRef = useRef(null);
@ -328,7 +328,7 @@ const BSLayout2 = () => {
setListOfInvoices(false); setListOfInvoices(false);
}; };
return ( return (
<Suspense fallback={<CardSkeleton />}> <Suspense fallback={<CardSkeleton />}>
<> <>
<Messages <Messages
messageType={messageType} messageType={messageType}
@ -684,7 +684,7 @@ const BSLayout2 = () => {
<LayoutSubCategoryFetcher /> <LayoutSubCategoryFetcher />
</> </>
</Suspense> </Suspense>
); );
}; };

View File

@ -102,17 +102,17 @@ const ComboSalesBillTable = lazy(
() => () =>
import('../../Components/BSBillingTables/ComboSalesBillTable/ComboSalesBillTable.jsx') import('../../Components/BSBillingTables/ComboSalesBillTable/ComboSalesBillTable.jsx')
); );
const PlanExpireNotification = lazy( // const PlanExpireNotification = lazy(
() => import('../PlanExpireNotification.jsx') // () => import('../PlanExpireNotification.jsx')
); // );
import PlanExpireNotification from '../PlanExpireNotification.jsx';
const BSNavbar1 = lazy(() => import('../../Components/BSNavbar/BSNavbar1')); const BSNavbar1 = lazy(() => import('../../Components/BSNavbar/BSNavbar1'));
const BSNavbar2 = lazy(() => import('../../Components/BSNavbar/BSNavbar2')); const BSNavbar2 = lazy(() => import('../../Components/BSNavbar/BSNavbar2'));
// Scss // Scss
import '../../../../Styles/BookingScreen/Template/BSLayout3/BSLayout3.scss'; import '../../../../Styles/BookingScreen/Template/BSLayout3/BSLayout3.scss';
import CardSkeleton from '../../../../Components/Skeleton/CardSkeleton.jsx'; import CardSkeleton from '../../../../Components/Skeleton/CardSkeleton.jsx';
const subDirectory = import.meta.env.BASE_URL;
const commonDirectory = import.meta.env.COMMON_BASE_URL;
const BSLayout3 = () => { const BSLayout3 = () => {
const dispatch = useDispatch(); const dispatch = useDispatch();
@ -625,7 +625,7 @@ const BSLayout3 = () => {
/> />
)} )}
</> </>
</Suspense> </Suspense>
); );
}; };

View File

@ -612,7 +612,7 @@ const BSLayout4 = () => {
/> />
)} )}
</> </>
</Suspense> </Suspense>
); );
}; };

View File

@ -603,7 +603,7 @@ const BSLayout5 = () => {
/> />
)} )}
</> </>
</Suspense> </Suspense>
); );
}; };

View File

@ -625,7 +625,7 @@ const BSLayout6 = () => {
)} )}
</div> </div>
</> </>
</Suspense> </Suspense>
); );
}; };
export default BSLayout6; export default BSLayout6;

View File

@ -1,5 +1,5 @@
import { useSelector } from 'react-redux'; import { useSelector } from 'react-redux';
import { GlobalAppExpDateData } from '../../../Features/BookingScreen/BookingData/BookingData'; import { ChangeAppExpDateData, getAppSubscriptionDate, GlobalAppExpDateData } from '../../../Features/BookingScreen/BookingData/BookingData';
import { useNavigate } from 'react-router-dom'; import { useNavigate } from 'react-router-dom';
import { ArrowUpOutlined } from '@ant-design/icons'; import { ArrowUpOutlined } from '@ant-design/icons';
import { StoredSessionData } from '../../../Features/ThemeChange/ThemeChange'; import { StoredSessionData } from '../../../Features/ThemeChange/ThemeChange';
@ -38,22 +38,65 @@ const PlanExpireNotification = () => {
UserName, UserName,
UserType, UserType,
} = SessionData; } = SessionData;
console.log('SessionData', AppExpDate);
const [count, setcount] = useState(0); const [count, setcount] = useState(0);
const animations = ['example1', 'example2', 'example3']; const animations = ['example1', 'example2', 'example3'];
let ss = animations[count]; let ss = animations[count];
useEffect(() => { // useEffect(() => {
if ( // if (
AppExpDate?.RemainingDays <= 7 || // AppExpDate?.RemainingDays <= 7 ||
AppExpDate?.PlanType?.toLowerCase() === 'extend' // AppExpDate?.PlanType?.toLowerCase() === 'extend'
) { // ) {
const interval = setInterval(() => { // const interval = setInterval(() => {
setcount((prevCount) => (prevCount >= 2 ? 0 : prevCount + 1)); // setcount((prevCount) => (prevCount >= 2 ? 0 : prevCount + 1));
}, 22000); // }, 22000);
return () => clearInterval(interval); // return () => clearInterval(interval);
// }
// }, [count == 2]);
useEffect(() => {
if (!AppExpDate || !SessionData) return;
let interval;
const fetchExpDate = async () => {
const { CompId, BranchId, AppId } = SessionData;
const res = await dispatch(
getAppSubscriptionDate({ CompId, BranchId, AppId })
).unwrap();
const expData = res?.data?.data?.[0];
if (!expData) return;
dispatch(ChangeAppExpDateData(expData));
// If renewed stop interval
if (expData.RemainingDays > 1 && interval) {
clearInterval(interval);
} }
}, [count == 2]); };
// 🎯 Only when less than 1 day start checking
if (AppExpDate.RemainingDays <= 1) {
interval = setInterval(fetchExpDate, 60000); // 1 minute
}
return () => {
if (interval) clearInterval(interval);
};
}, [AppExpDate?.RemainingDays]);
useEffect(() => {
if (AppExpDate?.RemainingDays <= 7) {
const interval = setInterval(() => {
setcount((prev) => (prev >= 2 ? 0 : prev + 1));
}, 22000);
return () => clearInterval(interval);
}
}, [AppExpDate?.RemainingDays]);
// ================= DATE FORMAT ================= // ================= DATE FORMAT =================
const formatDate = (dateStr) => { const formatDate = (dateStr) => {
@ -126,7 +169,7 @@ const PlanExpireNotification = () => {
const res = await dispatch(PublicQrCodepost(postData)).unwrap(); const res = await dispatch(PublicQrCodepost(postData)).unwrap();
// navigate(`${commonDirectory}invoice-details`); // navigate(`${commonDirectory}invoice-details`);
if (res?.data?.statusCode == 1) { if (res?.data?.statusCode == 1) {
navigate(`${commonDirectory}invoice-detail/${res?.data?.ReferenceNo}`); navigate(`${commonDirectory}/home/invoice-detail/${res?.data?.ReferenceNo}`);
setExtendModel(false); setExtendModel(false);
} }
} catch (error) { } catch (error) {
@ -149,7 +192,7 @@ const PlanExpireNotification = () => {
> >
Subscription expired &nbsp; Subscription expired &nbsp;
<a onClick={handlePay} className="upgrdbtn"> <a onClick={handlePay} className="upgrdbtn">
RENEWAL NOW <ArrowUpOutlined /> RENEW NOW <ArrowUpOutlined />
</a> </a>
</div> </div>
); );
@ -164,7 +207,7 @@ const PlanExpireNotification = () => {
</span>{' '} </span>{' '}
{AppExpDate?.RemainingHours >= 1 ? 'Hrs' : 'Min'} &nbsp; {AppExpDate?.RemainingHours >= 1 ? 'Hrs' : 'Min'} &nbsp;
<a onClick={handlePay} className="upgrdbtn"> <a onClick={handlePay} className="upgrdbtn">
RENEWAL NOW <ArrowUpOutlined /> RENEW NOW <ArrowUpOutlined />
</a> </a>
</p> </p>
); );
@ -182,7 +225,7 @@ const PlanExpireNotification = () => {
Your application subscription will expire within &nbsp; Your application subscription will expire within &nbsp;
<span className="NosDays">{AppExpDate?.RemainingDays}</span> days. &nbsp; <span className="NosDays">{AppExpDate?.RemainingDays}</span> days. &nbsp;
<a onClick={handlePay} className="upgrdbtn"> <a onClick={handlePay} className="upgrdbtn">
RENEWAL NOW <ArrowUpOutlined /> RENEW NOW <ArrowUpOutlined />
</a> </a>
</p> </p>
); );

View File

@ -82,9 +82,11 @@ const ExtendSubscriptionModal = ({
const response = await dispatch(postInvoice(postData)).unwrap(); const response = await dispatch(postInvoice(postData)).unwrap();
if (response?.data?.statusCode === 1 && response?.data?.SMSbody) { if (response?.data?.statusCode === 1) {
await dispatch(sendSms({ body: response.data.SMSbody })); if(response?.data?.SMSbody){
setExtendModel(false) await dispatch(sendSms({ body: response.data.SMSbody }));
}
setExtendModel(false)
navigate(`${subDirectory}app-page/home`); navigate(`${subDirectory}app-page/home`);
} }
} catch (error) { } catch (error) {
@ -113,7 +115,7 @@ const ExtendSubscriptionModal = ({
const res = await dispatch(PublicQrCodepost(postData)).unwrap(); const res = await dispatch(PublicQrCodepost(postData)).unwrap();
// navigate(`${commonDirectory}invoice-details`); // navigate(`${commonDirectory}invoice-details`);
if (res?.data?.statusCode == 1) { if (res?.data?.statusCode == 1) {
navigate(`${commonDirectory}invoice-detail/${res?.data?.ReferenceNo}`); navigate(`${commonDirectory}/home/invoice-detail/${res?.data?.ReferenceNo}`);
setExtendModel(false) setExtendModel(false)
} }

View File

@ -748,7 +748,7 @@ const WholesaleBookingPage = () => {
}} }}
className="upgrdbtn" className="upgrdbtn"
> >
RENEWAL NOW <ArrowUpOutlined /> RENEW NOW <ArrowUpOutlined />
</a> </a>
</span> </span>
) : AppExpDate?.RemainingDays < 1 ? ( ) : AppExpDate?.RemainingDays < 1 ? (
@ -766,7 +766,7 @@ const WholesaleBookingPage = () => {
}} }}
className="upgrdbtn" className="upgrdbtn"
> >
RENEWAL NOW <ArrowUpOutlined /> RENEW NOW <ArrowUpOutlined />
</a> </a>
</p> </p>
) : ( ) : (
@ -782,7 +782,7 @@ const WholesaleBookingPage = () => {
}} }}
className="upgrdbtn" className="upgrdbtn"
> >
RENEWAL NOW <ArrowUpOutlined /> RENEW NOW <ArrowUpOutlined />
</a> </a>
</p> </p>
)} )}