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
|
@@ -2,6 +2,7 @@ export interface SessionTimeOutProps {
|
|
|
2
2
|
sessionTime: string;
|
|
3
3
|
handleSubmitSession: () => void;
|
|
4
4
|
onSessionExpire: () => void;
|
|
5
|
+
handleSessionCancel: () => void;
|
|
5
6
|
}
|
|
6
|
-
declare const SessionTimeOut: ({ sessionTime, handleSubmitSession, onSessionExpire, }: SessionTimeOutProps) => import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
declare const SessionTimeOut: ({ sessionTime, handleSubmitSession, onSessionExpire, handleSessionCancel }: SessionTimeOutProps) => import("react/jsx-runtime").JSX.Element;
|
|
7
8
|
export default SessionTimeOut;
|
package/dist/index.esm.js
CHANGED
|
@@ -53667,7 +53667,7 @@ const secondsToMMSS = (totalSeconds) => {
|
|
|
53667
53667
|
return `${formattedMinutes}:${formattedSeconds}`;
|
|
53668
53668
|
};
|
|
53669
53669
|
const promptBeforeValue = 120000;
|
|
53670
|
-
const SessionTimeOut = ({ sessionTime, handleSubmitSession, onSessionExpire, }) => {
|
|
53670
|
+
const SessionTimeOut = ({ sessionTime, handleSubmitSession, onSessionExpire, handleSessionCancel }) => {
|
|
53671
53671
|
const [openConfirmModal, setOpenConfirmModal] = useState(false);
|
|
53672
53672
|
const expiryDetails = sessionTime;
|
|
53673
53673
|
const providedTimestamp = new Date(expiryDetails).getTime();
|
|
@@ -53675,20 +53675,19 @@ const SessionTimeOut = ({ sessionTime, handleSubmitSession, onSessionExpire, })
|
|
|
53675
53675
|
const remainingTime = providedTimestamp - currentTimestamp;
|
|
53676
53676
|
const timeout = remainingTime;
|
|
53677
53677
|
const promptBeforeIdle = Math.min(promptBeforeValue, timeout - 1000);
|
|
53678
|
-
const [remainingTimeInSeconds, setRemainingTimeInSeconds] = useState(
|
|
53679
|
-
const [formattedRemainingTime, setFormattedRemainingTime] = useState(
|
|
53678
|
+
const [remainingTimeInSeconds, setRemainingTimeInSeconds] = useState(Math.ceil(timeout / 1000));
|
|
53679
|
+
const [formattedRemainingTime, setFormattedRemainingTime] = useState(secondsToMMSS(Math.ceil(timeout / 1000)));
|
|
53680
53680
|
const onIdle = () => {
|
|
53681
53681
|
if (sessionTime) {
|
|
53682
53682
|
onSessionExpire();
|
|
53683
53683
|
}
|
|
53684
53684
|
};
|
|
53685
|
-
const onActive = () => {
|
|
53686
|
-
setOpenConfirmModal(false);
|
|
53687
|
-
};
|
|
53688
53685
|
const handleSubmit = () => {
|
|
53689
53686
|
handleSubmitSession();
|
|
53687
|
+
handleCancel();
|
|
53690
53688
|
};
|
|
53691
53689
|
const handleCancel = () => {
|
|
53690
|
+
handleSessionCancel();
|
|
53692
53691
|
setOpenConfirmModal(false);
|
|
53693
53692
|
};
|
|
53694
53693
|
const onPrompt = () => {
|
|
@@ -53697,24 +53696,24 @@ const SessionTimeOut = ({ sessionTime, handleSubmitSession, onSessionExpire, })
|
|
|
53697
53696
|
const { getRemainingTime, activate } = se({
|
|
53698
53697
|
onIdle,
|
|
53699
53698
|
onPrompt,
|
|
53700
|
-
onActive,
|
|
53701
53699
|
promptBeforeIdle,
|
|
53702
53700
|
timeout,
|
|
53703
|
-
throttle:
|
|
53701
|
+
throttle: 1000, // Adjust throttle to reduce delays
|
|
53704
53702
|
});
|
|
53705
53703
|
useEffect(() => {
|
|
53706
53704
|
const interval = setInterval(() => {
|
|
53707
53705
|
const remainingSeconds = Math.ceil(getRemainingTime() / 1000);
|
|
53708
53706
|
setRemainingTimeInSeconds(promptBeforeIdle !== promptBeforeValue ? remainingSeconds : 0);
|
|
53709
53707
|
const formattedTime = secondsToMMSS(remainingSeconds);
|
|
53710
|
-
setFormattedRemainingTime(promptBeforeIdle !== promptBeforeValue ? formattedTime : "
|
|
53711
|
-
},
|
|
53708
|
+
setFormattedRemainingTime(promptBeforeIdle !== promptBeforeValue ? formattedTime : "00:00");
|
|
53709
|
+
}, 1000); // Adjust interval to 1000 ms
|
|
53712
53710
|
return () => {
|
|
53713
53711
|
clearInterval(interval);
|
|
53714
53712
|
};
|
|
53715
|
-
}, [promptBeforeIdle]);
|
|
53713
|
+
}, [promptBeforeIdle, getRemainingTime]);
|
|
53716
53714
|
const sessionMessage = `Your session will expire in ${formattedRemainingTime} seconds. Do you want to extend the session?`;
|
|
53717
|
-
|
|
53715
|
+
console.log(promptBeforeIdle, 'promptBeforeIdle');
|
|
53716
|
+
return (jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: jsxRuntimeExports.jsx(ConfirmationDialog, { openConfirmDialog: openConfirmModal, handleCancel: handleCancel, onClickSubmit: handleSubmit, text: sessionMessage }) }));
|
|
53718
53717
|
};
|
|
53719
53718
|
|
|
53720
53719
|
export { DeleteField, FormRenderWrapper as RenderForm, SessionTimeOut as SessionTimeoutField, useFormValidatingContext };
|