tp-react-elements-dev 1.4.0 → 1.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/SessionTimeOut/SessionTimeOut.d.ts +2 -1
- package/dist/index.esm.js +11 -12
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +11 -12
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -53687,7 +53687,7 @@ const secondsToMMSS = (totalSeconds) => {
|
|
|
53687
53687
|
return `${formattedMinutes}:${formattedSeconds}`;
|
|
53688
53688
|
};
|
|
53689
53689
|
const promptBeforeValue = 120000;
|
|
53690
|
-
const SessionTimeOut = ({ sessionTime, handleSubmitSession, onSessionExpire, }) => {
|
|
53690
|
+
const SessionTimeOut = ({ sessionTime, handleSubmitSession, onSessionExpire, handleSessionCancel }) => {
|
|
53691
53691
|
const [openConfirmModal, setOpenConfirmModal] = React$1.useState(false);
|
|
53692
53692
|
const expiryDetails = sessionTime;
|
|
53693
53693
|
const providedTimestamp = new Date(expiryDetails).getTime();
|
|
@@ -53695,20 +53695,19 @@ const SessionTimeOut = ({ sessionTime, handleSubmitSession, onSessionExpire, })
|
|
|
53695
53695
|
const remainingTime = providedTimestamp - currentTimestamp;
|
|
53696
53696
|
const timeout = remainingTime;
|
|
53697
53697
|
const promptBeforeIdle = Math.min(promptBeforeValue, timeout - 1000);
|
|
53698
|
-
const [remainingTimeInSeconds, setRemainingTimeInSeconds] = React$1.useState(
|
|
53699
|
-
const [formattedRemainingTime, setFormattedRemainingTime] = React$1.useState(
|
|
53698
|
+
const [remainingTimeInSeconds, setRemainingTimeInSeconds] = React$1.useState(Math.ceil(timeout / 1000));
|
|
53699
|
+
const [formattedRemainingTime, setFormattedRemainingTime] = React$1.useState(secondsToMMSS(Math.ceil(timeout / 1000)));
|
|
53700
53700
|
const onIdle = () => {
|
|
53701
53701
|
if (sessionTime) {
|
|
53702
53702
|
onSessionExpire();
|
|
53703
53703
|
}
|
|
53704
53704
|
};
|
|
53705
|
-
const onActive = () => {
|
|
53706
|
-
setOpenConfirmModal(false);
|
|
53707
|
-
};
|
|
53708
53705
|
const handleSubmit = () => {
|
|
53709
53706
|
handleSubmitSession();
|
|
53707
|
+
handleCancel();
|
|
53710
53708
|
};
|
|
53711
53709
|
const handleCancel = () => {
|
|
53710
|
+
handleSessionCancel();
|
|
53712
53711
|
setOpenConfirmModal(false);
|
|
53713
53712
|
};
|
|
53714
53713
|
const onPrompt = () => {
|
|
@@ -53717,24 +53716,24 @@ const SessionTimeOut = ({ sessionTime, handleSubmitSession, onSessionExpire, })
|
|
|
53717
53716
|
const { getRemainingTime, activate } = se({
|
|
53718
53717
|
onIdle,
|
|
53719
53718
|
onPrompt,
|
|
53720
|
-
onActive,
|
|
53721
53719
|
promptBeforeIdle,
|
|
53722
53720
|
timeout,
|
|
53723
|
-
throttle:
|
|
53721
|
+
throttle: 1000, // Adjust throttle to reduce delays
|
|
53724
53722
|
});
|
|
53725
53723
|
React$1.useEffect(() => {
|
|
53726
53724
|
const interval = setInterval(() => {
|
|
53727
53725
|
const remainingSeconds = Math.ceil(getRemainingTime() / 1000);
|
|
53728
53726
|
setRemainingTimeInSeconds(promptBeforeIdle !== promptBeforeValue ? remainingSeconds : 0);
|
|
53729
53727
|
const formattedTime = secondsToMMSS(remainingSeconds);
|
|
53730
|
-
setFormattedRemainingTime(promptBeforeIdle !== promptBeforeValue ? formattedTime : "
|
|
53731
|
-
},
|
|
53728
|
+
setFormattedRemainingTime(promptBeforeIdle !== promptBeforeValue ? formattedTime : "00:00");
|
|
53729
|
+
}, 1000); // Adjust interval to 1000 ms
|
|
53732
53730
|
return () => {
|
|
53733
53731
|
clearInterval(interval);
|
|
53734
53732
|
};
|
|
53735
|
-
}, [promptBeforeIdle]);
|
|
53733
|
+
}, [promptBeforeIdle, getRemainingTime]);
|
|
53736
53734
|
const sessionMessage = `Your session will expire in ${formattedRemainingTime} seconds. Do you want to extend the session?`;
|
|
53737
|
-
|
|
53735
|
+
console.log(promptBeforeIdle, 'promptBeforeIdle');
|
|
53736
|
+
return (jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: jsxRuntimeExports.jsx(ConfirmationDialog, { openConfirmDialog: openConfirmModal, handleCancel: handleCancel, onClickSubmit: handleSubmit, text: sessionMessage }) }));
|
|
53738
53737
|
};
|
|
53739
53738
|
|
|
53740
53739
|
exports.DeleteField = DeleteField;
|