@autobusal/order-confirm 1.0.1 → 1.1.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/CHANGELOG.md +20 -0
- package/OrderConfirm.tsx +2 -0
- package/Telegram/Telegram.tsx +43 -0
- package/Telegram/styles.ts +10 -0
- package/package.json +1 -1
- package/services.ts +37 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,26 @@
|
|
|
3
3
|
All notable changes to this package are documented here. This project follows
|
|
4
4
|
[Keep a Changelog](https://keepachangelog.com/) and [Semantic Versioning](https://semver.org/).
|
|
5
5
|
|
|
6
|
+
## [1.1.1] - 2026-07-25
|
|
7
|
+
|
|
8
|
+
### Fixed
|
|
9
|
+
|
|
10
|
+
- The "Connect Telegram" addon widget now also renders on `reserved` order
|
|
11
|
+
confirmations, not just `purchased` ones - a reserve-then-pay-later
|
|
12
|
+
booking has no other page offering the binding link, so it was a dead
|
|
13
|
+
end for the Telegram addon on that path.
|
|
14
|
+
|
|
15
|
+
## [1.1.0] - 2026-07-25
|
|
16
|
+
|
|
17
|
+
### Added
|
|
18
|
+
|
|
19
|
+
- **Post-purchase Telegram addon binding.** When a purchased order has a
|
|
20
|
+
Telegram notification addon still awaiting binding, the "purchased"
|
|
21
|
+
confirmation page now shows a "Connect Telegram" deep link (polls obtapi's
|
|
22
|
+
`GET /api/orders/telegram/status?hash=...` every 4s until bound). Mirrors
|
|
23
|
+
magus's account-level `AccountTelegram` binding flow, but order-scoped
|
|
24
|
+
since a guest checkout has no account to bind against.
|
|
25
|
+
|
|
6
26
|
## [1.0.1] - 2026-07-19
|
|
7
27
|
|
|
8
28
|
### Security
|
package/OrderConfirm.tsx
CHANGED
|
@@ -5,6 +5,7 @@ import { BiErrorAlt } from 'react-icons/bi';
|
|
|
5
5
|
import { IoReturnUpBackOutline } from 'react-icons/io5';
|
|
6
6
|
import { Meta, Button } from '@autobusal/common';
|
|
7
7
|
import Reason from './Reason';
|
|
8
|
+
import Telegram from './Telegram/Telegram';
|
|
8
9
|
import { Title, Actions } from './styles';
|
|
9
10
|
import { useUserStore } from '@autobusal/providers/stores/user';
|
|
10
11
|
|
|
@@ -62,6 +63,7 @@ const OrderConfirm = ({ t }: Props): (JSX.Element | null) => {
|
|
|
62
63
|
|
|
63
64
|
<>
|
|
64
65
|
{ (type === 'cancelled' && message !== '') && <Reason message={ message } t={ t } /> }
|
|
66
|
+
{ ((type === 'purchased' || type === 'reserved') && hash) && <Telegram hash={ hash } t={ t } /> }
|
|
65
67
|
</>
|
|
66
68
|
|
|
67
69
|
<Actions>
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { TFunction } from 'i18next';
|
|
2
|
+
import { Button } from '@autobusal/common';
|
|
3
|
+
import { useGetOrderTelegramStatus } from '../services';
|
|
4
|
+
import { Container } from './styles';
|
|
5
|
+
|
|
6
|
+
interface Props {
|
|
7
|
+
hash: string
|
|
8
|
+
t: TFunction<'common'>
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
// Edited: Ferjolt Ozuni - Date: 2026-07-25
|
|
12
|
+
// Mirrors magus's account-level AccountTelegram.tsx, but order-scoped: a
|
|
13
|
+
// guest checkout has no account to bind against, so this reflects the
|
|
14
|
+
// order_addons row's own pending-token/chat_id state instead (see
|
|
15
|
+
// obtapi's Orders\AddonsController::telegram()). Renders nothing if the
|
|
16
|
+
// Telegram addon wasn't purchased on this order, or once bound - the
|
|
17
|
+
// binding is a one-time step, not something to keep displaying.
|
|
18
|
+
const Telegram = ({ hash, t }: Props): (JSX.Element | null) => {
|
|
19
|
+
const { data, isFetching } = useGetOrderTelegramStatus(hash);
|
|
20
|
+
|
|
21
|
+
if (isFetching || !data?.purchased || data.bound) {
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
if (!data.link) {
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return (
|
|
30
|
+
<Container className="box">
|
|
31
|
+
<p>{ t('order_confirm.telegram.instructions') }</p>
|
|
32
|
+
|
|
33
|
+
<a href={ data.link } target="_blank" rel="noreferrer">
|
|
34
|
+
<Button
|
|
35
|
+
type="button"
|
|
36
|
+
text={ t('order_confirm.telegram.connect') }
|
|
37
|
+
/>
|
|
38
|
+
</a>
|
|
39
|
+
</Container>
|
|
40
|
+
);
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export default Telegram;
|
package/package.json
CHANGED
package/services.ts
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { useQuery, UseQueryResult } from '@tanstack/react-query';
|
|
2
|
+
import { apiClient } from '@autobusal/providers';
|
|
3
|
+
|
|
4
|
+
export interface OrderTelegramStatus {
|
|
5
|
+
purchased: boolean
|
|
6
|
+
available?: boolean
|
|
7
|
+
bound?: boolean
|
|
8
|
+
link?: string
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
// Edited: Ferjolt Ozuni - Date: 2026-07-25
|
|
12
|
+
// Order-scoped equivalent of magus's Account/Telegram/services.ts
|
|
13
|
+
// useGetTelegramStatus - a guest checkout has no account to bind against,
|
|
14
|
+
// so the pending token/chat_id live on the order_addons row instead (see
|
|
15
|
+
// obtapi's Orders\AddonsController::telegram()).
|
|
16
|
+
export const useGetOrderTelegramStatus = (hash: string): UseQueryResult<OrderTelegramStatus> => (
|
|
17
|
+
useQuery({
|
|
18
|
+
queryKey: ['order-telegram-status', hash],
|
|
19
|
+
queryFn: async () => (
|
|
20
|
+
await apiClient
|
|
21
|
+
.get('/api/orders/telegram/status', {
|
|
22
|
+
params: { hash }
|
|
23
|
+
})
|
|
24
|
+
.then(response => (
|
|
25
|
+
response.data
|
|
26
|
+
))
|
|
27
|
+
),
|
|
28
|
+
// Poll while unbound, so "bound" flips true right after the buyer taps
|
|
29
|
+
// the deep link and messages the bot - no manual refresh needed.
|
|
30
|
+
// refetchIntervalInBackground is required: tapping the link backgrounds
|
|
31
|
+
// this tab (switching to the Telegram app/site), which is exactly when
|
|
32
|
+
// the poll needs to keep running - react-query pauses refetchInterval
|
|
33
|
+
// on a hidden tab by default.
|
|
34
|
+
refetchInterval: (query) => (query.state.data?.bound ? false : 4000),
|
|
35
|
+
refetchIntervalInBackground: true
|
|
36
|
+
})
|
|
37
|
+
);
|