@autobusal/routes-order 1.33.3 → 1.33.4
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 +6 -0
- package/Checkout/Checkout.tsx +2 -1
- package/Step5/Payments/Payments.tsx +11 -3
- package/Step5/utilities.ts +5 -0
- package/package.json +1 -1
- package/services.ts +11 -3
- package/types.ts +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.33.4
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
|
|
7
|
+
- **Complimentary in the web checkout.** An operator/employee selling on their OWN operator's route is offered the zero-cost Complimentary option the mobile app already had - the route-aware flag comes from `/api/funds/allowed?route=...` and the ownership rule is re-checked server-side at payment time. (Audit decision BOOK-07; needs obtapi >= 2.4.37.)
|
|
8
|
+
|
|
3
9
|
## 1.33.3
|
|
4
10
|
|
|
5
11
|
### Fixed
|
package/Checkout/Checkout.tsx
CHANGED
|
@@ -114,7 +114,7 @@ const Checkout = ({ values, step1, step2, step3, isPartner, t, onStore, onBack }
|
|
|
114
114
|
* answers it from cache - this reads the answer, it does not fetch it a
|
|
115
115
|
* second time.
|
|
116
116
|
*/
|
|
117
|
-
const { data: paymentsData } = useGetPayments();
|
|
117
|
+
const { data: paymentsData } = useGetPayments(step2.id);
|
|
118
118
|
|
|
119
119
|
const singleMethod = getAvailablePayments(paymentsData, isPartner ?? false).length === 1;
|
|
120
120
|
|
|
@@ -447,6 +447,7 @@ const Checkout = ({ values, step1, step2, step3, isPartner, t, onStore, onBack }
|
|
|
447
447
|
<Payments
|
|
448
448
|
selected={ action ?? '' }
|
|
449
449
|
isPartner={ isPartner ?? false }
|
|
450
|
+
routeId={ step2.id }
|
|
450
451
|
t={ t }
|
|
451
452
|
onChange={ onAction }
|
|
452
453
|
/>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useEffect } from 'react';
|
|
2
2
|
import { TFunction } from 'i18next';
|
|
3
3
|
import { RiSecurePaymentLine } from 'react-icons/ri';
|
|
4
|
-
import { FaRegHandPaper, FaMoneyBill } from 'react-icons/fa';
|
|
4
|
+
import { FaRegHandPaper, FaMoneyBill, FaGift } from 'react-icons/fa';
|
|
5
5
|
import { AiOutlineCreditCard } from 'react-icons/ai';
|
|
6
6
|
import { Inline } from '@autobusal/common';
|
|
7
7
|
import { SubTitle } from '../../styles';
|
|
@@ -12,12 +12,13 @@ import { getAvailablePayments } from '../utilities';
|
|
|
12
12
|
interface Props {
|
|
13
13
|
selected: string
|
|
14
14
|
isPartner: boolean
|
|
15
|
+
routeId?: number | string
|
|
15
16
|
t: TFunction<'common'>
|
|
16
17
|
onChange: (action: string) => void
|
|
17
18
|
}
|
|
18
19
|
|
|
19
|
-
const Payments = ({ selected, isPartner, t, onChange }: Props): JSX.Element | null => {
|
|
20
|
-
const { data, isLoading, isSuccess } = useGetPayments();
|
|
20
|
+
const Payments = ({ selected, isPartner, routeId, t, onChange }: Props): JSX.Element | null => {
|
|
21
|
+
const { data, isLoading, isSuccess } = useGetPayments(routeId);
|
|
21
22
|
|
|
22
23
|
const available = getAvailablePayments(data, isPartner);
|
|
23
24
|
|
|
@@ -90,6 +91,13 @@ const Payments = ({ selected, isPartner, t, onChange }: Props): JSX.Element | nu
|
|
|
90
91
|
</ButtonPayment>
|
|
91
92
|
) }
|
|
92
93
|
|
|
94
|
+
{ (data?.complimentary && !isPartner) && (
|
|
95
|
+
<ButtonPayment type="button" $selected={ selected === 'complimentary' } onClick={ () => onChange('complimentary') }>
|
|
96
|
+
<FaGift />
|
|
97
|
+
{ t('routes_order.step5.actions.complimentary') }
|
|
98
|
+
</ButtonPayment>
|
|
99
|
+
) }
|
|
100
|
+
|
|
93
101
|
{ (data?.bkt || isPartner) && (
|
|
94
102
|
<ButtonPayment type="button" $selected={ selected === 'bkt' } onClick={ () => onChange('bkt') }>
|
|
95
103
|
<AiOutlineCreditCard />
|
package/Step5/utilities.ts
CHANGED
|
@@ -51,6 +51,11 @@ export const getAvailablePayments = (data?: ActionData, isPartner = false): stri
|
|
|
51
51
|
if (data.reserve && !isPartner) { available.push('reserve'); }
|
|
52
52
|
if (data.funds && !isPartner) { available.push('funds', 'cash'); }
|
|
53
53
|
|
|
54
|
+
// Claude - 2026-08-22 (audit decision BOOK-07): an operator/employee on
|
|
55
|
+
// their own operator's route pays nothing - the flag is route-aware
|
|
56
|
+
// (services.ts) and re-checked server-side at payment time.
|
|
57
|
+
if (data.complimentary && !isPartner) { available.push('complimentary'); }
|
|
58
|
+
|
|
54
59
|
if (data.bkt || isPartner) { available.push('bkt'); }
|
|
55
60
|
if (data.stripe || isPartner) { available.push('stripe'); }
|
|
56
61
|
if (data.mollie || isPartner) { available.push('mollie'); }
|
package/package.json
CHANGED
package/services.ts
CHANGED
|
@@ -222,12 +222,20 @@ export const useGetCoupon = (routeId: number, total: number): UseMutationResult<
|
|
|
222
222
|
})
|
|
223
223
|
);
|
|
224
224
|
|
|
225
|
-
|
|
225
|
+
/*
|
|
226
|
+
* Claude - 2026-08-22 (audit decision BOOK-07): asks with the route being
|
|
227
|
+
* sold, so the API can offer Complimentary to an operator/employee on
|
|
228
|
+
* their own operator's route. External routes carry string ids and can
|
|
229
|
+
* never be own inventory, so those simply don't send the parameter.
|
|
230
|
+
*/
|
|
231
|
+
export const useGetPayments = (routeId?: number | string): UseQueryResult<ActionData> => (
|
|
226
232
|
useQuery({
|
|
227
|
-
queryKey: ['allowed-funds'],
|
|
233
|
+
queryKey: ['allowed-funds', { routeId }],
|
|
228
234
|
queryFn: async () => (
|
|
229
235
|
await apiClient
|
|
230
|
-
.get('/api/funds/allowed'
|
|
236
|
+
.get('/api/funds/allowed', {
|
|
237
|
+
params: typeof routeId === 'number' ? { route: routeId } : {}
|
|
238
|
+
})
|
|
231
239
|
.then(response => (
|
|
232
240
|
response.data
|
|
233
241
|
))
|