#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')
|
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();
|
||||||
|
|
@ -321,7 +320,6 @@ const BSLayout1 = () => {
|
||||||
};
|
};
|
||||||
return (
|
return (
|
||||||
<Suspense fallback={<CardSkeleton />}>
|
<Suspense fallback={<CardSkeleton />}>
|
||||||
{' '}
|
|
||||||
<>
|
<>
|
||||||
<Messages
|
<Messages
|
||||||
messageType={messageType}
|
messageType={messageType}
|
||||||
|
|
|
||||||
|
|
@ -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);
|
||||||
|
|
|
||||||
|
|
@ -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();
|
||||||
|
|
|
||||||
|
|
@ -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(() => {
|
||||||
|
// setcount((prevCount) => (prevCount >= 2 ? 0 : prevCount + 1));
|
||||||
|
// }, 22000);
|
||||||
|
// 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);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// 🎯 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(() => {
|
const interval = setInterval(() => {
|
||||||
setcount((prevCount) => (prevCount >= 2 ? 0 : prevCount + 1));
|
setcount((prev) => (prev >= 2 ? 0 : prev + 1));
|
||||||
}, 22000);
|
}, 22000);
|
||||||
|
|
||||||
return () => clearInterval(interval);
|
return () => clearInterval(interval);
|
||||||
}
|
}
|
||||||
}, [count == 2]);
|
}, [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
|
Subscription expired
|
||||||
<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'}
|
{AppExpDate?.RemainingHours >= 1 ? 'Hrs' : 'Min'}
|
||||||
<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
|
Your application subscription will expire within
|
||||||
<span className="NosDays">{AppExpDate?.RemainingDays}</span> days.
|
<span className="NosDays">{AppExpDate?.RemainingDays}</span> days.
|
||||||
<a onClick={handlePay} className="upgrdbtn">
|
<a onClick={handlePay} className="upgrdbtn">
|
||||||
RENEWAL NOW <ArrowUpOutlined />
|
RENEW NOW <ArrowUpOutlined />
|
||||||
</a>
|
</a>
|
||||||
</p>
|
</p>
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -82,8 +82,10 @@ 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) {
|
||||||
|
if(response?.data?.SMSbody){
|
||||||
await dispatch(sendSms({ body: response.data.SMSbody }));
|
await dispatch(sendSms({ body: response.data.SMSbody }));
|
||||||
|
}
|
||||||
setExtendModel(false)
|
setExtendModel(false)
|
||||||
navigate(`${subDirectory}app-page/home`);
|
navigate(`${subDirectory}app-page/home`);
|
||||||
}
|
}
|
||||||
|
|
@ -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)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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>
|
||||||
)}
|
)}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue