+ {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 = ({