@autobusal/order-confirm 1.1.2 → 1.2.0
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/CHANGELOG.md +16 -0
- package/OrderConfirm.tsx +50 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,8 +1,24 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.2.0
|
|
4
|
+
|
|
5
|
+
- Announces `purchase` on arrival, for a **purchased** order only — a reservation is not revenue and a cancelled attempt certainly is not. Cleared as it fires, so refreshing this page (a plain URL with the buyer's order number on it) cannot report the same sale twice.
|
|
6
|
+
|
|
3
7
|
All notable changes to this package are documented here. This project follows
|
|
4
8
|
[Keep a Changelog](https://keepachangelog.com/) and [Semantic Versioning](https://semver.org/).
|
|
5
9
|
|
|
10
|
+
## [1.1.3] - 2026-08-01
|
|
11
|
+
|
|
12
|
+
### Changed
|
|
13
|
+
|
|
14
|
+
- **The confirmation moves on to the order after five seconds**, where the
|
|
15
|
+
tickets and the invoice actually are. A dead-end success page turned
|
|
16
|
+
downloading the thing you had just bought into a hunt. Only for purchased
|
|
17
|
+
and reserved: a cancellation has nothing to go to, and bouncing someone
|
|
18
|
+
off a notice they may still be reading would be its own small insult.
|
|
19
|
+
Cleared on unmount, so pressing a button first does not leave a second
|
|
20
|
+
navigation queued behind the one you chose.
|
|
21
|
+
|
|
6
22
|
## [1.1.2] - 2026-07-30
|
|
7
23
|
|
|
8
24
|
### Fixed
|
package/OrderConfirm.tsx
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { useEffect } from 'react';
|
|
1
2
|
import { TFunction } from 'i18next';
|
|
2
3
|
import { useSearchParams, useParams, useNavigate, Navigate } from 'react-router-dom';
|
|
3
4
|
import { AiOutlineCheck } from 'react-icons/ai';
|
|
@@ -8,6 +9,7 @@ import Reason from './Reason';
|
|
|
8
9
|
import Telegram from './Telegram/Telegram';
|
|
9
10
|
import { Title, Actions } from './styles';
|
|
10
11
|
import { useUserStore } from '@autobusal/providers/stores/user';
|
|
12
|
+
import { flush } from '@autobusal/providers/Setup/commerce';
|
|
11
13
|
|
|
12
14
|
interface Props {
|
|
13
15
|
t: TFunction<'common'>
|
|
@@ -22,6 +24,10 @@ const escapeHtml = (value: string): string => (
|
|
|
22
24
|
}[char] as string))
|
|
23
25
|
);
|
|
24
26
|
|
|
27
|
+
// long enough to read the confirmation and its order number, short enough
|
|
28
|
+
// that nobody wonders whether the page has finished
|
|
29
|
+
const REDIRECT_AFTER = 5000;
|
|
30
|
+
|
|
25
31
|
const OrderConfirm = ({ t }: Props): (JSX.Element | null) => {
|
|
26
32
|
const [ searchParams ] = useSearchParams();
|
|
27
33
|
|
|
@@ -33,19 +39,62 @@ const OrderConfirm = ({ t }: Props): (JSX.Element | null) => {
|
|
|
33
39
|
|
|
34
40
|
const { data: UserData } = useUserStore();
|
|
35
41
|
|
|
42
|
+
/**
|
|
43
|
+
* Edited: Ferjolt Ozuni - Date: 2026-08-05
|
|
44
|
+
*
|
|
45
|
+
* Only a PURCHASE counts. A reservation is not revenue and a cancelled
|
|
46
|
+
* attempt certainly is not, and reporting either as a sale is the kind of
|
|
47
|
+
* error that is never noticed because the number only ever looks good.
|
|
48
|
+
*
|
|
49
|
+
* flush() clears as it fires, so refreshing this page - which a buyer
|
|
50
|
+
* reasonably might, it is a plain URL with their order number on it -
|
|
51
|
+
* cannot report the same sale twice.
|
|
52
|
+
*/
|
|
53
|
+
useEffect(() => {
|
|
54
|
+
if (type === 'purchased' && hash) {
|
|
55
|
+
flush(hash);
|
|
56
|
+
}
|
|
57
|
+
}, [type, hash]);
|
|
58
|
+
|
|
36
59
|
const isAllowed = ['reserved', 'cancelled', 'purchased'].includes(String(type));
|
|
37
60
|
|
|
38
61
|
if (!isAllowed) {
|
|
39
62
|
return <Navigate to="/" />;
|
|
40
63
|
}
|
|
41
64
|
|
|
65
|
+
const destination = UserData ? '/account/orders' : `/viewtrip/${ hash }`;
|
|
66
|
+
|
|
42
67
|
const onManage = (): void => {
|
|
43
68
|
// a logged-in user shouldn't be sent to the public order-lookup form (which
|
|
44
69
|
// email-gates access to their OWN order) - send them into their account
|
|
45
70
|
// orders where the order is listed. Guests use the public lookup.
|
|
46
|
-
navigate(
|
|
71
|
+
navigate(destination);
|
|
47
72
|
};
|
|
48
73
|
|
|
74
|
+
/**
|
|
75
|
+
* Edited: Ferjolt Ozuni - Date: 2026-08-01
|
|
76
|
+
*
|
|
77
|
+
* Read the confirmation, then go to the order itself - where the tickets
|
|
78
|
+
* and the invoice actually are. Leaving people on a dead-end success page
|
|
79
|
+
* turned downloading the thing they had just bought into a hunt.
|
|
80
|
+
*
|
|
81
|
+
* Only for the outcomes that produce an order to go TO. A cancellation
|
|
82
|
+
* has nothing to download, and bouncing someone off a cancellation notice
|
|
83
|
+
* they may still be reading would be its own small insult.
|
|
84
|
+
*
|
|
85
|
+
* Cleared on unmount, so pressing a button first does not leave a second
|
|
86
|
+
* navigation queued behind the one the user chose.
|
|
87
|
+
*/
|
|
88
|
+
useEffect(() => {
|
|
89
|
+
if (type !== 'purchased' && type !== 'reserved') {
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
const timer = setTimeout(() => navigate(destination), REDIRECT_AFTER);
|
|
94
|
+
|
|
95
|
+
return () => clearTimeout(timer);
|
|
96
|
+
}, [ type, destination, navigate ]);
|
|
97
|
+
|
|
49
98
|
const onBack = (): void => {
|
|
50
99
|
navigate(UserData ? '/account' : '/');
|
|
51
100
|
};
|