@autobusal/routes-order 1.40.3 → 1.41.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.
@@ -445,19 +445,24 @@ const Checkout = ({ values, step1, step2, step3, isPartner, t, onStore, onBack }
445
445
  * collected or undefined, so a failure stops the chain with the offending
446
446
  * form's own error messages already on screen.
447
447
  */
448
+ const [ payNotice, setPayNotice ] = useState<string | null>(null);
449
+
448
450
  const onPay = async (): Promise<void> => {
451
+ // Claude - 2026-11-05: under the Pay button, in the site's own look (they were alert()s)
449
452
  if (action === undefined) {
450
- alert(t('routes_order.step5.choose_payment'));
453
+ setPayNotice(t('routes_order.step5.choose_payment'));
451
454
 
452
455
  return;
453
456
  }
454
457
 
455
458
  if (addonWhatsapp && addonWhatsappNumber.trim().length < 5) {
456
- alert(t('routes_order.step5.addons.whatsapp.phone_error'));
459
+ setPayNotice(t('routes_order.step5.addons.whatsapp.phone_error'));
457
460
 
458
461
  return;
459
462
  }
460
463
 
464
+ setPayNotice(null);
465
+
461
466
  let person: PersonData | undefined;
462
467
 
463
468
  await passenger.handleSubmit((data) => { person = data; })();
@@ -650,6 +655,7 @@ const Checkout = ({ values, step1, step2, step3, isPartner, t, onStore, onBack }
650
655
  pending={ isPending }
651
656
  t={ t }
652
657
  onPay={ onPay }
658
+ notice={ payNotice }
653
659
  payments={ (
654
660
  <Payments
655
661
  selected={ action ?? '' }
@@ -1,7 +1,7 @@
1
1
  import { TFunction } from 'i18next';
2
2
  import { MdDone } from 'react-icons/md';
3
3
  import { AiOutlineInfoCircle } from 'react-icons/ai';
4
- import { Button } from '@autobusal/common';
4
+ import { Button, FormNotice } from '@autobusal/common';
5
5
  import About from '../../Step5/Summary/About/About';
6
6
  import Amount from '../../Step5/Summary/Amount/Amount';
7
7
  import { Container, Panel, Actions, Notice, Local } from './styles';
@@ -54,6 +54,8 @@ interface Props {
54
54
  pending: boolean
55
55
  t: TFunction<'common'>
56
56
  onPay: () => void
57
+ /* Claude - 2026-11-05: why Pay did not go ahead, said under the button */
58
+ notice?: string | null
57
59
  /** coupon form, rendered directly above the totals it affects */
58
60
  children?: React.ReactNode
59
61
  /** payment-method picker, rendered directly above the button that uses it */
@@ -70,7 +72,7 @@ interface Props {
70
72
  * page and scrolled away while add-ons were being ticked - so the number
71
73
  * changed out of sight of the person it was changing for.
72
74
  */
73
- const Sidebar = ({ step1, step2, step3, fare, addons, coupon, total, local, surcharge, comission, action, single, pending, t, onPay, children, payments }: Props): JSX.Element => (
75
+ const Sidebar = ({ step1, step2, step3, fare, addons, coupon, total, local, surcharge, comission, action, single, pending, t, onPay, notice, children, payments }: Props): JSX.Element => (
74
76
  <Container>
75
77
  <Panel className="box">
76
78
  <SubTitle>
@@ -158,7 +160,7 @@ const Sidebar = ({ step1, step2, step3, fare, addons, coupon, total, local, surc
158
160
  onClick={ onPay }
159
161
  />
160
162
 
161
- { action === undefined && (
163
+ { notice ? <FormNotice message={ notice } /> : action === undefined && (
162
164
  <Notice>{ t('routes_order.step5.choose_payment') }</Notice>
163
165
  ) }
164
166
  </Actions>
@@ -11,6 +11,24 @@ import { SubTitle } from '../../styles';
11
11
  import { Container, NoticeEmail } from './styles';
12
12
  import { BillingData } from '@autobusal/providers/types/persons';
13
13
 
14
+ /*
15
+ * Claude - 2026-11-06 (audit 2026-10-28, low): "I agree to the {{terms}}" as
16
+ * text with the link as an element. It used to be rendered as HTML - stored
17
+ * XSS the day an admin can edit translations.
18
+ */
19
+ const SLOT = '\u0001';
20
+
21
+ const Terms = ({ text, name }: { text: string, name: string }): JSX.Element => {
22
+ const [before, ...rest] = text.split(SLOT);
23
+
24
+ return (
25
+ <span>
26
+ { before }
27
+ { rest.length > 0 && <><a href="/page/terms" target="_blank" rel="noopener">{ name }</a>{ rest.join('') }</> }
28
+ </span>
29
+ );
30
+ };
31
+
14
32
  interface Props {
15
33
  t: TFunction<'common'>
16
34
  errors: FieldErrors
@@ -233,11 +251,7 @@ const Billing = ({ errors, t, refs, only }: Props): JSX.Element => {
233
251
  <label className="single">
234
252
  <input type="checkbox" value="1" aria-required="true" { ...refs('terms', Validate('required', t)) } />&nbsp;
235
253
 
236
- <span dangerouslySetInnerHTML={{
237
- __html: t('routes_order.step5.billing.terms', {
238
- terms: `<a href="/page/terms" target="_blank">${ t('routes_order.step5.billing.terms_name') }</a>`
239
- })
240
- }} />
254
+ <Terms text={ t('routes_order.step5.billing.terms', { terms: SLOT, interpolation: { escapeValue: false } }) } name={ t('routes_order.step5.billing.terms_name') } />
241
255
  </label>
242
256
 
243
257
  { Display(errors.terms) }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@autobusal/routes-order",
3
- "version": "1.40.3",
3
+ "version": "1.41.1",
4
4
  "author": "Ferjolt Ozuni",
5
5
  "type": "module",
6
6
  "main": "index.ts",