#210 Plan Expire Modal and Redirection Issue solving
This commit is contained in:
parent
b27a87d389
commit
749d7286d0
|
|
@ -102,9 +102,8 @@ const ComboSalesBillTable = lazy(
|
|||
import('../../Components/BSBillingTables/ComboSalesBillTable/ComboSalesBillTable.jsx')
|
||||
);
|
||||
const SalesCountComponent = lazy(() => import('../SalesCountComponent.jsx'));
|
||||
const PlanExpireNotification = lazy(
|
||||
() => import('../PlanExpireNotification.jsx')
|
||||
);
|
||||
// const PlanExpireNotification = lazy(() => import('../PlanExpireNotification.jsx'));
|
||||
import PlanExpireNotification from '../PlanExpireNotification.jsx';
|
||||
|
||||
const BSLayout1 = () => {
|
||||
const dispatch = useDispatch();
|
||||
|
|
@ -321,7 +320,6 @@ const BSLayout1 = () => {
|
|||
};
|
||||
return (
|
||||
<Suspense fallback={<CardSkeleton />}>
|
||||
{' '}
|
||||
<>
|
||||
<Messages
|
||||
messageType={messageType}
|
||||
|
|
|
|||
|
|
@ -133,10 +133,10 @@ const BranchTransferComponent = lazy(
|
|||
const BSExpireProductsList = lazy(
|
||||
() => import('../../Components/UtillComponents/BSExpireProductsList.jsx')
|
||||
);
|
||||
const PlanExpireNotification = lazy(
|
||||
() => import('../PlanExpireNotification.jsx')
|
||||
);
|
||||
|
||||
// const PlanExpireNotification = lazy(
|
||||
// () => import('../PlanExpireNotification.jsx')
|
||||
// );
|
||||
import PlanExpireNotification from '../PlanExpireNotification.jsx';
|
||||
const BSLayout2 = () => {
|
||||
const dispatch = useDispatch();
|
||||
const elementRef = useRef(null);
|
||||
|
|
|
|||
|
|
@ -102,17 +102,17 @@ const ComboSalesBillTable = lazy(
|
|||
() =>
|
||||
import('../../Components/BSBillingTables/ComboSalesBillTable/ComboSalesBillTable.jsx')
|
||||
);
|
||||
const PlanExpireNotification = lazy(
|
||||
() => import('../PlanExpireNotification.jsx')
|
||||
);
|
||||
// const PlanExpireNotification = lazy(
|
||||
// () => import('../PlanExpireNotification.jsx')
|
||||
// );
|
||||
import PlanExpireNotification from '../PlanExpireNotification.jsx';
|
||||
const BSNavbar1 = lazy(() => import('../../Components/BSNavbar/BSNavbar1'));
|
||||
const BSNavbar2 = lazy(() => import('../../Components/BSNavbar/BSNavbar2'));
|
||||
// Scss
|
||||
import '../../../../Styles/BookingScreen/Template/BSLayout3/BSLayout3.scss';
|
||||
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 dispatch = useDispatch();
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
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 { ArrowUpOutlined } from '@ant-design/icons';
|
||||
import { StoredSessionData } from '../../../Features/ThemeChange/ThemeChange';
|
||||
|
|
@ -38,22 +38,65 @@ const PlanExpireNotification = () => {
|
|||
UserName,
|
||||
UserType,
|
||||
} = SessionData;
|
||||
console.log('SessionData', AppExpDate);
|
||||
const [count, setcount] = useState(0);
|
||||
const animations = ['example1', 'example2', 'example3'];
|
||||
let ss = animations[count];
|
||||
|
||||
// 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]);
|
||||
|
||||
useEffect(() => {
|
||||
if (
|
||||
AppExpDate?.RemainingDays <= 7 ||
|
||||
AppExpDate?.PlanType?.toLowerCase() === 'extend'
|
||||
) {
|
||||
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);
|
||||
}
|
||||
};
|
||||
|
||||
// 🎯 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((prevCount) => (prevCount >= 2 ? 0 : prevCount + 1));
|
||||
setcount((prev) => (prev >= 2 ? 0 : prev + 1));
|
||||
}, 22000);
|
||||
|
||||
return () => clearInterval(interval);
|
||||
}
|
||||
}, [count == 2]);
|
||||
}, [AppExpDate?.RemainingDays]);
|
||||
|
||||
// ================= DATE FORMAT =================
|
||||
const formatDate = (dateStr) => {
|
||||
|
|
@ -126,7 +169,7 @@ const PlanExpireNotification = () => {
|
|||
const res = await dispatch(PublicQrCodepost(postData)).unwrap();
|
||||
// navigate(`${commonDirectory}invoice-details`);
|
||||
if (res?.data?.statusCode == 1) {
|
||||
navigate(`${commonDirectory}invoice-detail/${res?.data?.ReferenceNo}`);
|
||||
navigate(`${commonDirectory}/home/invoice-detail/${res?.data?.ReferenceNo}`);
|
||||
setExtendModel(false);
|
||||
}
|
||||
} catch (error) {
|
||||
|
|
@ -149,7 +192,7 @@ const PlanExpireNotification = () => {
|
|||
>
|
||||
Subscription expired
|
||||
<a onClick={handlePay} className="upgrdbtn">
|
||||
RENEWAL NOW <ArrowUpOutlined />
|
||||
RENEW NOW <ArrowUpOutlined />
|
||||
</a>
|
||||
</div>
|
||||
);
|
||||
|
|
@ -164,7 +207,7 @@ const PlanExpireNotification = () => {
|
|||
</span>{' '}
|
||||
{AppExpDate?.RemainingHours >= 1 ? 'Hrs' : 'Min'}
|
||||
<a onClick={handlePay} className="upgrdbtn">
|
||||
RENEWAL NOW <ArrowUpOutlined />
|
||||
RENEW NOW <ArrowUpOutlined />
|
||||
</a>
|
||||
</p>
|
||||
);
|
||||
|
|
@ -182,7 +225,7 @@ const PlanExpireNotification = () => {
|
|||
Your application subscription will expire within
|
||||
<span className="NosDays">{AppExpDate?.RemainingDays}</span> days.
|
||||
<a onClick={handlePay} className="upgrdbtn">
|
||||
RENEWAL NOW <ArrowUpOutlined />
|
||||
RENEW NOW <ArrowUpOutlined />
|
||||
</a>
|
||||
</p>
|
||||
);
|
||||
|
|
|
|||
|
|
@ -82,8 +82,10 @@ const ExtendSubscriptionModal = ({
|
|||
|
||||
const response = await dispatch(postInvoice(postData)).unwrap();
|
||||
|
||||
if (response?.data?.statusCode === 1 && response?.data?.SMSbody) {
|
||||
if (response?.data?.statusCode === 1) {
|
||||
if(response?.data?.SMSbody){
|
||||
await dispatch(sendSms({ body: response.data.SMSbody }));
|
||||
}
|
||||
setExtendModel(false)
|
||||
navigate(`${subDirectory}app-page/home`);
|
||||
}
|
||||
|
|
@ -113,7 +115,7 @@ const ExtendSubscriptionModal = ({
|
|||
const res = await dispatch(PublicQrCodepost(postData)).unwrap();
|
||||
// navigate(`${commonDirectory}invoice-details`);
|
||||
if (res?.data?.statusCode == 1) {
|
||||
navigate(`${commonDirectory}invoice-detail/${res?.data?.ReferenceNo}`);
|
||||
navigate(`${commonDirectory}/home/invoice-detail/${res?.data?.ReferenceNo}`);
|
||||
setExtendModel(false)
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -748,7 +748,7 @@ const WholesaleBookingPage = () => {
|
|||
}}
|
||||
className="upgrdbtn"
|
||||
>
|
||||
RENEWAL NOW <ArrowUpOutlined />
|
||||
RENEW NOW <ArrowUpOutlined />
|
||||
</a>
|
||||
</span>
|
||||
) : AppExpDate?.RemainingDays < 1 ? (
|
||||
|
|
@ -766,7 +766,7 @@ const WholesaleBookingPage = () => {
|
|||
}}
|
||||
className="upgrdbtn"
|
||||
>
|
||||
RENEWAL NOW <ArrowUpOutlined />
|
||||
RENEW NOW <ArrowUpOutlined />
|
||||
</a>
|
||||
</p>
|
||||
) : (
|
||||
|
|
@ -782,7 +782,7 @@ const WholesaleBookingPage = () => {
|
|||
}}
|
||||
className="upgrdbtn"
|
||||
>
|
||||
RENEWAL NOW <ArrowUpOutlined />
|
||||
RENEW NOW <ArrowUpOutlined />
|
||||
</a>
|
||||
</p>
|
||||
)}
|
||||
|
|
|
|||
Loading…
Reference in New Issue