allaw-ui 2.5.4 → 2.5.6
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.
|
@@ -4,6 +4,7 @@ var LOCAL_STORAGE_KEYS = {
|
|
|
4
4
|
START_TIME: "startTimeBilling",
|
|
5
5
|
ACCUMULATED_TIME: "accumulatedTime",
|
|
6
6
|
IS_RUNNING: "isRunning",
|
|
7
|
+
HAS_STARTED_BEFORE: "hasStartedBefore",
|
|
7
8
|
};
|
|
8
9
|
var BillingCount = function (_a) {
|
|
9
10
|
var onEnd = _a.onEnd, setIsStarted = _a.setIsStarted, resetTimer = _a.resetTimer, pauseTimer = _a.pauseTimer;
|
|
@@ -12,17 +13,20 @@ var BillingCount = function (_a) {
|
|
|
12
13
|
var intervalRef = useRef(null);
|
|
13
14
|
// --- Au premier render, on relit le localStorage
|
|
14
15
|
useEffect(function () {
|
|
15
|
-
var savedAccumulated = getAccumulatedTime();
|
|
16
|
+
var savedAccumulated = getAccumulatedTime();
|
|
16
17
|
var savedIsRunning = localStorage.getItem(LOCAL_STORAGE_KEYS.IS_RUNNING) === "true";
|
|
17
|
-
var savedStartTime = getStartTime();
|
|
18
|
-
|
|
18
|
+
var savedStartTime = getStartTime();
|
|
19
|
+
var hasStartedBefore = localStorage.getItem(LOCAL_STORAGE_KEYS.HAS_STARTED_BEFORE) === "true"; // ✅ Vérifier si un chrono a déjà été utilisé
|
|
20
|
+
if (savedAccumulated > 0) {
|
|
19
21
|
setElapsedSeconds(savedAccumulated);
|
|
20
22
|
}
|
|
21
|
-
if (savedIsRunning && savedStartTime > 0) {
|
|
23
|
+
if (hasStartedBefore && savedIsRunning && savedStartTime > 0) {
|
|
24
|
+
// ✅ Reprendre seulement si le chrono a déjà été lancé au moins une fois
|
|
22
25
|
setIsRunning(true);
|
|
23
26
|
setIsStarted && setIsStarted(true);
|
|
24
27
|
}
|
|
25
28
|
else {
|
|
29
|
+
// ✅ Ne pas démarrer automatiquement si aucun chrono n'a été lancé
|
|
26
30
|
setIsRunning(false);
|
|
27
31
|
setIsStarted && setIsStarted(false);
|
|
28
32
|
}
|
|
@@ -50,6 +54,8 @@ var BillingCount = function (_a) {
|
|
|
50
54
|
// --- Sur changement de resetTimer/pauseTimer
|
|
51
55
|
// on applique la logique de reset, de pause ou de start
|
|
52
56
|
useEffect(function () {
|
|
57
|
+
var hasStartedBefore = localStorage.getItem(LOCAL_STORAGE_KEYS.HAS_STARTED_BEFORE) === "true";
|
|
58
|
+
var savedAccumulated = getAccumulatedTime();
|
|
53
59
|
if (resetTimer) {
|
|
54
60
|
resetTimerHandler();
|
|
55
61
|
}
|
|
@@ -57,7 +63,10 @@ var BillingCount = function (_a) {
|
|
|
57
63
|
pauseTimerHandler();
|
|
58
64
|
}
|
|
59
65
|
else if (!pauseTimer && !resetTimer) {
|
|
60
|
-
|
|
66
|
+
// ⚠️ Ne lance le chrono que s'il est déjà en cours ou s'il y a du temps accumulé
|
|
67
|
+
if (hasStartedBefore && savedAccumulated > 0) {
|
|
68
|
+
startTimerHandler();
|
|
69
|
+
}
|
|
61
70
|
}
|
|
62
71
|
}, [resetTimer, pauseTimer]);
|
|
63
72
|
// --- Fonctions utilitaires ---
|
|
@@ -76,7 +85,8 @@ var BillingCount = function (_a) {
|
|
|
76
85
|
var startTimerHandler = function () {
|
|
77
86
|
var isRunningFlag = localStorage.getItem(LOCAL_STORAGE_KEYS.IS_RUNNING) === "true";
|
|
78
87
|
if (!isRunningFlag) {
|
|
79
|
-
//
|
|
88
|
+
// ✅ Indiquer que le chrono a été démarré au moins une fois
|
|
89
|
+
localStorage.setItem(LOCAL_STORAGE_KEYS.HAS_STARTED_BEFORE, "true");
|
|
80
90
|
localStorage.setItem(LOCAL_STORAGE_KEYS.START_TIME, Date.now().toString());
|
|
81
91
|
localStorage.setItem(LOCAL_STORAGE_KEYS.IS_RUNNING, "true");
|
|
82
92
|
setIsRunning(true);
|
|
@@ -103,6 +113,7 @@ var BillingCount = function (_a) {
|
|
|
103
113
|
// On remet tout à zéro
|
|
104
114
|
var resetTimerHandler = function () {
|
|
105
115
|
clearTimerData();
|
|
116
|
+
localStorage.setItem(LOCAL_STORAGE_KEYS.HAS_STARTED_BEFORE, "false");
|
|
106
117
|
setElapsedSeconds(0);
|
|
107
118
|
setIsRunning(false);
|
|
108
119
|
setIsStarted && setIsStarted(false);
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
max-width: 768px;
|
|
5
5
|
padding: 2.5rem;
|
|
6
6
|
flex-direction: column;
|
|
7
|
-
justify-content:
|
|
7
|
+
justify-content: center;
|
|
8
8
|
align-items: center;
|
|
9
9
|
gap: 16px;
|
|
10
10
|
border-radius: 16px;
|
|
@@ -19,10 +19,11 @@
|
|
|
19
19
|
.stepper-content {
|
|
20
20
|
width: 100%;
|
|
21
21
|
flex: 1;
|
|
22
|
+
margin: 20px 0;
|
|
22
23
|
overflow-y: auto;
|
|
23
24
|
display: flex;
|
|
24
25
|
flex-direction: column;
|
|
25
|
-
align-items:
|
|
26
|
+
align-items: center;
|
|
26
27
|
font-family: "Open Sans", sans-serif;
|
|
27
28
|
font-size: 16px;
|
|
28
29
|
font-weight: 400;
|