@campxdev/react-blueprint 0.1.50 → 0.1.51
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/package.json
CHANGED
|
@@ -26,24 +26,41 @@ export const Tutorial = ({
|
|
|
26
26
|
setRun(true);
|
|
27
27
|
}, []);
|
|
28
28
|
|
|
29
|
-
useEffect(() => {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
}, [userTours, tourName, startTour]);
|
|
29
|
+
// useEffect(() => {
|
|
30
|
+
// if (userTours && !userTours.includes(tourName)) {
|
|
31
|
+
// startTour();
|
|
32
|
+
// }
|
|
33
|
+
// }, [userTours, tourName, startTour]);
|
|
34
34
|
|
|
35
35
|
const handleJoyrideCallback = (data: CallBackProps) => {
|
|
36
|
-
|
|
36
|
+
console.log(data);
|
|
37
|
+
const { action, status, lifecycle, type } = data;
|
|
38
|
+
const reqData = {
|
|
39
|
+
tourName: tourName,
|
|
40
|
+
skipped: false,
|
|
41
|
+
completed: false,
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
// Check if the tour is skipped or completed
|
|
45
|
+
if (
|
|
46
|
+
action === ACTIONS.SKIP &&
|
|
47
|
+
lifecycle === "complete" &&
|
|
48
|
+
type === "tour:end"
|
|
49
|
+
) {
|
|
50
|
+
reqData.skipped = true;
|
|
51
|
+
} else if (action === ACTIONS.RESET) {
|
|
52
|
+
reqData.completed = true;
|
|
53
|
+
}
|
|
37
54
|
|
|
38
|
-
if (
|
|
39
|
-
setRun(false);
|
|
40
|
-
completeTour().catch((err) => {
|
|
55
|
+
if (reqData.skipped || reqData.completed) {
|
|
56
|
+
setRun(false); // Stop the tour
|
|
57
|
+
completeTour(reqData).catch((err) => {
|
|
41
58
|
console.error("Failed to mark tour as complete:", err);
|
|
42
59
|
});
|
|
43
60
|
}
|
|
44
61
|
};
|
|
45
62
|
|
|
46
|
-
const completeTour = async () => {
|
|
63
|
+
const completeTour = async (reqData: any) => {
|
|
47
64
|
try {
|
|
48
65
|
if (!userTours.includes(tourName)) {
|
|
49
66
|
localStorage.setItem(
|
|
@@ -51,7 +68,7 @@ export const Tutorial = ({
|
|
|
51
68
|
JSON.stringify([...JSON.parse(userTours), tourName])
|
|
52
69
|
);
|
|
53
70
|
}
|
|
54
|
-
await axios.post("/square/tours/complete", {
|
|
71
|
+
await axios.post("/square/tours/complete", { reqData });
|
|
55
72
|
} catch (error) {
|
|
56
73
|
console.error("Error completing the tour:", error);
|
|
57
74
|
}
|