@quantaroute/checkout 1.4.3 → 1.4.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.
@@ -26,6 +26,7 @@ import type {
26
26
  LocationAlternative,
27
27
  } from '../core/types';
28
28
  import { styles, COLORS } from '../styles/checkout.native';
29
+ import { AddressDetailsIcon, AddressLabelIcon } from './AddressLabelIcons.native';
29
30
 
30
31
  // ─── State (identical logic to web AddressForm) ───────────────────────────────
31
32
 
@@ -45,6 +46,7 @@ type FormState =
45
46
  alternatives: LocationAlternative[];
46
47
  selectedLocality: string;
47
48
  selectedLabel: AddressLabel;
49
+ labelText: string;
48
50
  fields: ManualFields;
49
51
  submitting: boolean;
50
52
  pincodeHasDelivery: boolean;
@@ -63,6 +65,7 @@ type FormAction =
63
65
  | { type: 'SET_FIELD'; key: keyof ManualFields; value: string }
64
66
  | { type: 'SET_LOCALITY'; locality: string }
65
67
  | { type: 'SET_LABEL'; label: AddressLabel }
68
+ | { type: 'SET_LABEL_TEXT'; value: string }
66
69
  | { type: 'SUBMIT_START' }
67
70
  | { type: 'SUBMIT_END' };
68
71
 
@@ -106,6 +109,7 @@ function reducer(state: FormState, action: FormAction): FormState {
106
109
  alternatives: action.alternatives || [],
107
110
  selectedLocality: action.adminInfo.locality,
108
111
  selectedLabel: 'home',
112
+ labelText: '',
109
113
  fields: { ...INITIAL_FIELDS, ...preFilled },
110
114
  submitting: false,
111
115
  pincodeHasDelivery: action.pincodeHasDelivery,
@@ -121,7 +125,14 @@ function reducer(state: FormState, action: FormAction): FormState {
121
125
  return { ...state, selectedLocality: action.locality };
122
126
  case 'SET_LABEL':
123
127
  if (state.status !== 'ready') return state;
124
- return { ...state, selectedLabel: action.label };
128
+ return {
129
+ ...state,
130
+ selectedLabel: action.label,
131
+ labelText: action.label === 'other' ? state.labelText : '',
132
+ };
133
+ case 'SET_LABEL_TEXT':
134
+ if (state.status !== 'ready') return state;
135
+ return { ...state, labelText: action.value.slice(0, 64) };
125
136
  case 'SUBMIT_START':
126
137
  if (state.status !== 'ready') return state;
127
138
  return { ...state, submitting: true };
@@ -214,8 +225,9 @@ const AddressForm: React.FC<AddressFormProps> = ({
214
225
  const handleSubmit = useCallback(() => {
215
226
  if (state.status !== 'ready') return;
216
227
  if (!state.fields.flatNumber.trim()) return;
228
+ if (state.selectedLabel === 'other' && !state.labelText.trim()) return;
217
229
 
218
- const { adminInfo, selectedLocality, selectedLabel, fields } = state;
230
+ const { adminInfo, selectedLocality, selectedLabel, labelText, fields } = state;
219
231
 
220
232
  const parts: string[] = [
221
233
  fields.flatNumber,
@@ -242,6 +254,7 @@ const AddressForm: React.FC<AddressFormProps> = ({
242
254
  ...fields,
243
255
  formattedAddress: parts.join(', '),
244
256
  label: selectedLabel,
257
+ ...(selectedLabel === 'other' ? { labelText: labelText.trim() } : {}),
245
258
  };
246
259
 
247
260
  dispatch({ type: 'SUBMIT_START' });
@@ -368,7 +381,7 @@ const AddressForm: React.FC<AddressFormProps> = ({
368
381
  <View style={styles.sectionHeader}>
369
382
  <Text style={styles.sectionHeaderIcon}>📍</Text>
370
383
  <Text style={[styles.sectionHeaderText, isDark && styles.sectionHeaderTextDark]}>
371
- Auto-detected from your pin
384
+ Auto-detected from your digipin
372
385
  </Text>
373
386
  </View>
374
387
 
@@ -457,20 +470,27 @@ const AddressForm: React.FC<AddressFormProps> = ({
457
470
 
458
471
  {/* Address label */}
459
472
  <View style={[styles.sectionDivider, isDark && styles.sectionDividerDark]} />
460
- <View style={styles.sectionHeader}>
461
- <Text style={[styles.sectionHeaderText, isDark && styles.sectionHeaderTextDark]}>
473
+ <View style={[styles.sectionHeader, styles.sectionHeaderCompact]}>
474
+ <Text
475
+ style={[
476
+ styles.sectionHeaderText,
477
+ styles.sectionHeaderTextCompact,
478
+ isDark && styles.sectionHeaderTextDark,
479
+ ]}
480
+ >
462
481
  Save as
463
482
  </Text>
464
483
  </View>
465
484
  <View style={styles.labelPicker}>
466
485
  {(
467
486
  [
468
- { value: 'home' as const, title: 'Home', icon: '🏠' },
469
- { value: 'work' as const, title: 'Work', icon: '💼' },
470
- { value: 'other' as const, title: 'Other', icon: '📍' },
487
+ { value: 'home' as const, title: 'Home' },
488
+ { value: 'work' as const, title: 'Work' },
489
+ { value: 'other' as const, title: 'Other' },
471
490
  ] as const
472
- ).map(({ value, title, icon }) => {
491
+ ).map(({ value, title }) => {
473
492
  const active = state.selectedLabel === value;
493
+ const iconColor = active ? COLORS.primary : COLORS.textMuted;
474
494
  return (
475
495
  <TouchableOpacity
476
496
  key={value}
@@ -484,9 +504,12 @@ const AddressForm: React.FC<AddressFormProps> = ({
484
504
  accessibilityRole="radio"
485
505
  accessibilityState={{ checked: active }}
486
506
  accessibilityLabel={title}
487
- activeOpacity={0.8}
507
+ activeOpacity={0.97}
488
508
  >
489
- <Text style={styles.labelPickerIcon}>{icon}</Text>
509
+ <AddressLabelIcon
510
+ label={value}
511
+ color={isDark && !active ? COLORS.textMutedDark : iconColor}
512
+ />
490
513
  <Text
491
514
  style={[
492
515
  styles.labelPickerText,
@@ -500,11 +523,39 @@ const AddressForm: React.FC<AddressFormProps> = ({
500
523
  );
501
524
  })}
502
525
  </View>
526
+ {state.selectedLabel === 'other' ? (
527
+ <View style={styles.labelTextField}>
528
+ <View style={styles.fieldLabel}>
529
+ <Text style={[styles.fieldLabelText, isDark && styles.fieldLabelTextDark]}>
530
+ Label name
531
+ </Text>
532
+ <Text style={styles.fieldRequired}>*</Text>
533
+ </View>
534
+ <TextInput
535
+ style={[
536
+ styles.fieldInput,
537
+ isDark && styles.fieldInputDark,
538
+ ]}
539
+ placeholder="e.g. Friend's home, Gym"
540
+ placeholderTextColor={isDark ? COLORS.textFaintDark : COLORS.textFaint}
541
+ value={state.labelText}
542
+ onChangeText={(value) =>
543
+ dispatch({ type: 'SET_LABEL_TEXT', value })
544
+ }
545
+ maxLength={64}
546
+ autoCapitalize="words"
547
+ returnKeyType="next"
548
+ />
549
+ </View>
550
+ ) : null}
503
551
 
504
552
  {/* Manual entry section */}
505
553
  <View style={[styles.sectionDivider, isDark && styles.sectionDividerDark]} />
506
554
  <View style={styles.sectionHeader}>
507
- <Text style={styles.sectionHeaderIcon}>🏠</Text>
555
+ <AddressDetailsIcon
556
+ color={isDark ? COLORS.textMutedDark : COLORS.textMuted}
557
+ size={14}
558
+ />
508
559
  <Text style={[styles.sectionHeaderText, isDark && styles.sectionHeaderTextDark]}>
509
560
  Your details
510
561
  </Text>
@@ -560,10 +611,15 @@ const AddressForm: React.FC<AddressFormProps> = ({
560
611
  style={[
561
612
  styles.btnPrimary,
562
613
  { flex: 1 },
563
- (state.submitting || !state.fields.flatNumber.trim()) && styles.btnDisabled,
614
+ (state.submitting || !state.fields.flatNumber.trim()
615
+ || (state.selectedLabel === 'other' && !state.labelText.trim())) && styles.btnDisabled,
564
616
  ]}
565
617
  onPress={handleSubmit}
566
- disabled={state.submitting || !state.fields.flatNumber.trim()}
618
+ disabled={
619
+ state.submitting
620
+ || !state.fields.flatNumber.trim()
621
+ || (state.selectedLabel === 'other' && !state.labelText.trim())
622
+ }
567
623
  activeOpacity={0.8}
568
624
  accessibilityRole="button"
569
625
  accessibilityLabel="Save address"
@@ -13,6 +13,7 @@ import type {
13
13
  CompleteAddress,
14
14
  LocationAlternative,
15
15
  } from '../core/types';
16
+ import { AddressLabelIcon } from './AddressLabelIcons';
16
17
 
17
18
  // ─── State ────────────────────────────────────────────────────────────────────
18
19
 
@@ -32,6 +33,7 @@ type FormState =
32
33
  alternatives: LocationAlternative[];
33
34
  selectedLocality: string; // Selected locality name (from adminInfo or alternatives)
34
35
  selectedLabel: AddressLabel;
36
+ labelText: string;
35
37
  fields: ManualFields;
36
38
  submitting: boolean;
37
39
  /** At least one India Post office with "Delivery" (not only "Non Delivery") */
@@ -51,6 +53,7 @@ type FormAction =
51
53
  | { type: 'SET_FIELD'; key: keyof ManualFields; value: string }
52
54
  | { type: 'SET_LOCALITY'; locality: string }
53
55
  | { type: 'SET_LABEL'; label: AddressLabel }
56
+ | { type: 'SET_LABEL_TEXT'; value: string }
54
57
  | { type: 'SUBMIT_START' }
55
58
  | { type: 'SUBMIT_END' };
56
59
 
@@ -107,6 +110,7 @@ function reducer(state: FormState, action: FormAction): FormState {
107
110
  alternatives: action.alternatives || [],
108
111
  selectedLocality: action.adminInfo.locality,
109
112
  selectedLabel: 'home',
113
+ labelText: '',
110
114
  fields: { ...INITIAL_FIELDS, ...preFilled },
111
115
  submitting: false,
112
116
  pincodeHasDelivery: action.pincodeHasDelivery,
@@ -122,7 +126,14 @@ function reducer(state: FormState, action: FormAction): FormState {
122
126
  return { ...state, selectedLocality: action.locality };
123
127
  case 'SET_LABEL':
124
128
  if (state.status !== 'ready') return state;
125
- return { ...state, selectedLabel: action.label };
129
+ return {
130
+ ...state,
131
+ selectedLabel: action.label,
132
+ labelText: action.label === 'other' ? state.labelText : '',
133
+ };
134
+ case 'SET_LABEL_TEXT':
135
+ if (state.status !== 'ready') return state;
136
+ return { ...state, labelText: action.value.slice(0, 64) };
126
137
  case 'SUBMIT_START':
127
138
  if (state.status !== 'ready') return state;
128
139
  return { ...state, submitting: true };
@@ -209,7 +220,9 @@ const AddressForm: React.FC<AddressFormProps> = ({
209
220
  e.preventDefault();
210
221
  if (state.status !== 'ready') return;
211
222
 
212
- const { adminInfo, selectedLocality, selectedLabel, fields } = state;
223
+ const { adminInfo, selectedLocality, selectedLabel, labelText, fields } = state;
224
+
225
+ if (selectedLabel === 'other' && !labelText.trim()) return;
213
226
 
214
227
  const parts: string[] = [
215
228
  fields.flatNumber,
@@ -236,6 +249,7 @@ const AddressForm: React.FC<AddressFormProps> = ({
236
249
  ...fields,
237
250
  formattedAddress: parts.join(', '),
238
251
  label: selectedLabel,
252
+ ...(selectedLabel === 'other' ? { labelText: labelText.trim() } : {}),
239
253
  };
240
254
 
241
255
  dispatch({ type: 'SUBMIT_START' });
@@ -325,7 +339,7 @@ const AddressForm: React.FC<AddressFormProps> = ({
325
339
  <fieldset className="qr-fieldset">
326
340
  <legend className="qr-fieldset__legend">
327
341
  <span className="qr-fieldset__icon" aria-hidden="true">📍</span>
328
- Auto-detected from your pin
342
+ Auto-detected from your digipin
329
343
  </legend>
330
344
 
331
345
  <div className="qr-auto-grid">
@@ -397,15 +411,15 @@ const AddressForm: React.FC<AddressFormProps> = ({
397
411
 
398
412
  {/* Address label */}
399
413
  <fieldset className="qr-fieldset">
400
- <legend className="qr-fieldset__legend">Save as</legend>
414
+ <legend className="qr-fieldset__legend qr-fieldset__legend--compact">Save as</legend>
401
415
  <div className="qr-label-picker" role="radiogroup" aria-label="Address label">
402
416
  {(
403
417
  [
404
- { value: 'home' as const, title: 'Home', icon: '🏠' },
405
- { value: 'work' as const, title: 'Work', icon: '💼' },
406
- { value: 'other' as const, title: 'Other', icon: '📍' },
418
+ { value: 'home' as const, title: 'Home' },
419
+ { value: 'work' as const, title: 'Work' },
420
+ { value: 'other' as const, title: 'Other' },
407
421
  ] as const
408
- ).map(({ value, title, icon }) => (
422
+ ).map(({ value, title }) => (
409
423
  <button
410
424
  key={value}
411
425
  type="button"
@@ -416,13 +430,35 @@ const AddressForm: React.FC<AddressFormProps> = ({
416
430
  }`}
417
431
  onClick={() => dispatch({ type: 'SET_LABEL', label: value })}
418
432
  >
419
- <span className="qr-label-picker__icon" aria-hidden="true">
420
- {icon}
433
+ <span className="qr-label-picker__icon">
434
+ <AddressLabelIcon label={value} />
421
435
  </span>
422
436
  <span>{title}</span>
423
437
  </button>
424
438
  ))}
425
439
  </div>
440
+ {state.selectedLabel === 'other' && (
441
+ <div className="qr-label-text-field">
442
+ <label className="qr-field__label" htmlFor="qr-labelText">
443
+ Label name
444
+ <span className="qr-required" aria-hidden="true">*</span>
445
+ </label>
446
+ <input
447
+ id="qr-labelText"
448
+ type="text"
449
+ className="qr-field__input"
450
+ placeholder="e.g. Friend's home, Gym"
451
+ value={state.labelText}
452
+ onChange={(e) =>
453
+ dispatch({ type: 'SET_LABEL_TEXT', value: e.target.value })
454
+ }
455
+ maxLength={64}
456
+ required
457
+ aria-required="true"
458
+ autoComplete="off"
459
+ />
460
+ </div>
461
+ )}
426
462
  </fieldset>
427
463
 
428
464
  {/* Manual entry section */}
@@ -535,7 +571,11 @@ const AddressForm: React.FC<AddressFormProps> = ({
535
571
  <button
536
572
  type="submit"
537
573
  className="qr-btn qr-btn--primary qr-btn--grow"
538
- disabled={state.submitting || !state.fields.flatNumber.trim()}
574
+ disabled={
575
+ state.submitting
576
+ || !state.fields.flatNumber.trim()
577
+ || (state.selectedLabel === 'other' && !state.labelText.trim())
578
+ }
539
579
  >
540
580
  {state.submitting ? (
541
581
  <>
@@ -0,0 +1,144 @@
1
+ import { View, StyleSheet } from 'react-native';
2
+ import type { AddressLabel } from '../core/types';
3
+
4
+ interface AddressLabelIconProps {
5
+ label: AddressLabel;
6
+ color: string;
7
+ size?: number;
8
+ }
9
+
10
+ const STROKE = 1.5;
11
+
12
+ /** Minimal View-drawn icons for Home / Work / Other (no react-native-svg). */
13
+ export function AddressLabelIcon({ label, color, size = 16 }: AddressLabelIconProps) {
14
+ switch (label) {
15
+ case 'home':
16
+ return (
17
+ <View style={[styles.wrap, { width: size, height: size }]}>
18
+ <View
19
+ style={{
20
+ width: 0,
21
+ height: 0,
22
+ borderLeftWidth: size * 0.5,
23
+ borderRightWidth: size * 0.5,
24
+ borderBottomWidth: size * 0.38,
25
+ borderLeftColor: 'transparent',
26
+ borderRightColor: 'transparent',
27
+ borderBottomColor: color,
28
+ marginBottom: -STROKE,
29
+ }}
30
+ />
31
+ <View
32
+ style={{
33
+ width: size * 0.68,
34
+ height: size * 0.48,
35
+ borderWidth: STROKE,
36
+ borderColor: color,
37
+ borderRadius: 1,
38
+ }}
39
+ />
40
+ </View>
41
+ );
42
+ case 'work':
43
+ return (
44
+ <View style={[styles.wrap, { width: size, height: size }]}>
45
+ <View
46
+ style={{
47
+ width: size * 0.42,
48
+ height: size * 0.22,
49
+ borderWidth: STROKE,
50
+ borderColor: color,
51
+ borderBottomWidth: 0,
52
+ borderTopLeftRadius: 2,
53
+ borderTopRightRadius: 2,
54
+ marginBottom: -STROKE,
55
+ }}
56
+ />
57
+ <View
58
+ style={{
59
+ width: size * 0.85,
60
+ height: size * 0.55,
61
+ borderWidth: STROKE,
62
+ borderColor: color,
63
+ borderRadius: 2,
64
+ }}
65
+ />
66
+ </View>
67
+ );
68
+ case 'other':
69
+ return (
70
+ <View style={[styles.wrap, { width: size, height: size }]}>
71
+ <View
72
+ style={{
73
+ width: size * 0.55,
74
+ height: size * 0.55,
75
+ borderWidth: STROKE,
76
+ borderColor: color,
77
+ borderRadius: size * 0.275,
78
+ }}
79
+ />
80
+ <View
81
+ style={{
82
+ width: 0,
83
+ height: 0,
84
+ borderLeftWidth: size * 0.22,
85
+ borderRightWidth: size * 0.22,
86
+ borderTopWidth: size * 0.32,
87
+ borderLeftColor: 'transparent',
88
+ borderRightColor: 'transparent',
89
+ borderTopColor: color,
90
+ marginTop: -STROKE * 2,
91
+ }}
92
+ />
93
+ </View>
94
+ );
95
+ }
96
+ }
97
+
98
+ /** Map-pin icon for address / location detail sections (section headers). */
99
+ export function AddressDetailsIcon({ color, size = 14 }: { color: string; size?: number }) {
100
+ return (
101
+ <View style={[styles.wrap, { width: size, height: size }]}>
102
+ <View
103
+ style={{
104
+ width: size * 0.52,
105
+ height: size * 0.52,
106
+ borderWidth: STROKE,
107
+ borderColor: color,
108
+ borderRadius: size * 0.26,
109
+ alignItems: 'center',
110
+ justifyContent: 'center',
111
+ }}
112
+ >
113
+ <View
114
+ style={{
115
+ width: size * 0.14,
116
+ height: size * 0.14,
117
+ borderRadius: size * 0.07,
118
+ backgroundColor: color,
119
+ }}
120
+ />
121
+ </View>
122
+ <View
123
+ style={{
124
+ width: 0,
125
+ height: 0,
126
+ borderLeftWidth: size * 0.22,
127
+ borderRightWidth: size * 0.22,
128
+ borderTopWidth: size * 0.28,
129
+ borderLeftColor: 'transparent',
130
+ borderRightColor: 'transparent',
131
+ borderTopColor: color,
132
+ marginTop: -STROKE * 2,
133
+ }}
134
+ />
135
+ </View>
136
+ );
137
+ }
138
+
139
+ const styles = StyleSheet.create({
140
+ wrap: {
141
+ alignItems: 'center',
142
+ justifyContent: 'center',
143
+ },
144
+ });
@@ -0,0 +1,46 @@
1
+ import type { AddressLabel } from '../core/types';
2
+
3
+ interface AddressLabelIconProps {
4
+ label: AddressLabel;
5
+ className?: string;
6
+ /** Native only — web uses `currentColor` via CSS */
7
+ color?: string;
8
+ }
9
+
10
+ /** Subtle stroke icons for Home / Work / Other address labels (web). */
11
+ export function AddressLabelIcon({ label, className }: AddressLabelIconProps) {
12
+ const shared = {
13
+ className,
14
+ 'aria-hidden': true as const,
15
+ viewBox: '0 0 24 24',
16
+ fill: 'none',
17
+ stroke: 'currentColor',
18
+ strokeWidth: 2,
19
+ strokeLinecap: 'round' as const,
20
+ strokeLinejoin: 'round' as const,
21
+ };
22
+
23
+ switch (label) {
24
+ case 'home':
25
+ return (
26
+ <svg {...shared}>
27
+ <path d="M3 9.5L12 3l9 6.5V20a1 1 0 01-1 1H5a1 1 0 01-1-1V9.5z" />
28
+ <path d="M9 21V12h6v9" />
29
+ </svg>
30
+ );
31
+ case 'work':
32
+ return (
33
+ <svg {...shared}>
34
+ <rect x="2" y="7" width="20" height="14" rx="2" />
35
+ <path d="M16 7V5a2 2 0 00-2-2h-4a2 2 0 00-2 2v2" />
36
+ </svg>
37
+ );
38
+ case 'other':
39
+ return (
40
+ <svg {...shared}>
41
+ <path d="M21 10c0 7-9 13-9 13S3 17 3 10a9 9 0 0118 0z" />
42
+ <circle cx="12" cy="10" r="3" />
43
+ </svg>
44
+ );
45
+ }
46
+ }
@@ -380,6 +380,7 @@ const CheckoutWidget: React.FC<CheckoutWidgetProps> = ({
380
380
  label: (saved.label === 'work' || saved.label === 'other'
381
381
  ? saved.label
382
382
  : 'home') as CompleteAddress['label'],
383
+ labelText: saved.label_text?.trim() || undefined,
383
384
  addressId: saved.id,
384
385
  };
385
386
  void finishAddress(complete);
@@ -433,6 +434,8 @@ const CheckoutWidget: React.FC<CheckoutWidgetProps> = ({
433
434
  street_name: address.streetName,
434
435
  full_address_json: address as unknown as Record<string, unknown>,
435
436
  label: address.label ?? 'home',
437
+ label_text:
438
+ address.label === 'other' ? (address.labelText?.trim() || null) : null,
436
439
  is_default: false,
437
440
  });
438
441
  } catch {
@@ -13,7 +13,7 @@ import { OSMView, LocationButton } from 'expo-osm-sdk';
13
13
  import type { OSMViewRef, MarkerConfig } from 'expo-osm-sdk';
14
14
  import * as Location from 'expo-location';
15
15
  import { getDigiPin, getLatLngFromDigiPin, formatDigiPin, isWithinIndia } from '../core/digipin';
16
- import { autocompleteAddress, looksLikeDigiPin } from '../core/api';
16
+ import { autocompleteAddress, looksLikeDigiPin, couldBeDigiPinInput } from '../core/api';
17
17
  import type { AutocompleteSuggestion } from '../core/api';
18
18
  import type { MapPinSelectorProps } from '../core/types';
19
19
  import { styles, COLORS } from '../styles/checkout.native';
@@ -150,6 +150,13 @@ const MapPinSelector: React.FC<MapPinSelectorProps> = ({
150
150
  return;
151
151
  }
152
152
 
153
+ // Partial DigiPin — wait for full code, skip autocomplete
154
+ if (couldBeDigiPinInput(trimmed)) {
155
+ setSuggestions([]);
156
+ setSearchLoading(false);
157
+ return;
158
+ }
159
+
153
160
  if (trimmed.length < 3) {
154
161
  setSuggestions([]);
155
162
  return;
@@ -2,7 +2,7 @@ import React, { useEffect, useRef, useState, useCallback, useId } from 'react';
2
2
  import maplibregl from 'maplibre-gl';
3
3
  import 'maplibre-gl/dist/maplibre-gl.css';
4
4
  import { getDigiPin, getLatLngFromDigiPin, formatDigiPin, isWithinIndia } from '../core/digipin';
5
- import { autocompleteAddress, looksLikeDigiPin } from '../core/api';
5
+ import { autocompleteAddress, looksLikeDigiPin, couldBeDigiPinInput } from '../core/api';
6
6
  import type { AutocompleteSuggestion } from '../core/api';
7
7
  import { useGeolocation } from '../hooks/useGeolocation';
8
8
  import type { MapPinSelectorProps } from '../core/types';
@@ -190,6 +190,14 @@ const MapPinSelector: React.FC<MapPinSelectorProps> = ({
190
190
  return;
191
191
  }
192
192
 
193
+ // Partial DigiPin (compact/spaced/dashed) — wait for full code, skip autocomplete
194
+ if (couldBeDigiPinInput(trimmed)) {
195
+ setSuggestions([]);
196
+ setDropdownOpen(false);
197
+ setSearchLoading(false);
198
+ return;
199
+ }
200
+
193
201
  // Address search — debounce 400 ms, need ≥ 3 chars
194
202
  if (trimmed.length < 3) {
195
203
  setSuggestions([]);
@@ -32,6 +32,12 @@ function LabelIcon({ label }: { label: string }) {
32
32
  return <PinIcon />;
33
33
  }
34
34
 
35
+ function formatAddressLabel(address: SavedAddress): string {
36
+ const custom = address.label_text?.trim();
37
+ if (address.label === 'other' && custom) return custom;
38
+ return address.label.charAt(0).toUpperCase() + address.label.slice(1);
39
+ }
40
+
35
41
  // ─── Address card ─────────────────────────────────────────────────────────────
36
42
 
37
43
  interface AddressCardProps {
@@ -64,7 +70,7 @@ function AddressCard({ address, onUse, onDelete, onSetDefault, deleting }: Addre
64
70
  <LabelIcon label={address.label} />
65
71
  </div>
66
72
  <span className="qr-addr-card__label">
67
- {address.label.charAt(0).toUpperCase() + address.label.slice(1)}
73
+ {formatAddressLabel(address)}
68
74
  </span>
69
75
  {address.is_default && (
70
76
  <span className="qr-addr-card__default-badge">Default</span>
package/src/core/api.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import type { LocationLookupResponse } from './types';
2
- import { isCompleteDigiPinInput } from './digipin';
2
+ import { isCompleteDigiPinInput, isPotentialDigiPinInput } from './digipin';
3
3
 
4
4
  const DEFAULT_BASE_URL = 'https://api.quantaroute.com';
5
5
 
@@ -235,6 +235,14 @@ export function looksLikeDigiPin(input: string): boolean {
235
235
  return isCompleteDigiPinInput(input);
236
236
  }
237
237
 
238
+ /**
239
+ * Returns true while the user is typing a DigiPin (compact, dashed, or spaced).
240
+ * Used to suppress address autocomplete until the code is complete or abandoned.
241
+ */
242
+ export function couldBeDigiPinInput(input: string): boolean {
243
+ return isPotentialDigiPinInput(input);
244
+ }
245
+
238
246
  /**
239
247
  * Call QuantaRoute's autocomplete API.
240
248
  * Minimum 3 characters required; max 10 suggestions.
@@ -82,6 +82,8 @@ export interface SavedAddress {
82
82
  building_name: string;
83
83
  street_name: string;
84
84
  label: string;
85
+ /** Custom display text when label is `other` */
86
+ label_text: string | null;
85
87
  is_default: boolean;
86
88
  created_at: string;
87
89
  updated_at: string;
@@ -104,6 +106,7 @@ export interface SavedAddressPayload {
104
106
  street_name?: string;
105
107
  full_address_json?: Record<string, unknown>;
106
108
  label?: string;
109
+ label_text?: string | null;
107
110
  is_default?: boolean;
108
111
  }
109
112
 
@@ -35,13 +35,22 @@ const BOUNDS = {
35
35
  /** Characters that appear in the official 4×4 DigiPin grid */
36
36
  const DIGIPIN_ALPHABET = 'FC98J327K456LMPT';
37
37
  const VALID_DIGIPIN_BODY = new RegExp(`^[${DIGIPIN_ALPHABET}]{10}$`, 'i');
38
+ const VALID_DIGIPIN_PREFIX = new RegExp(`^[${DIGIPIN_ALPHABET}]{1,10}$`, 'i');
39
+ /** Common separators: ASCII dash/underscore/dot plus Unicode dash variants */
40
+ const DIGIPIN_SEPARATORS = /[\s\-_\u2010-\u2015\u2212.]/g;
38
41
 
39
42
  /**
40
43
  * Normalise user input to a 10-character DigiPin body (no separators).
41
44
  * Accepts dashed, spaced, or compact forms — e.g. `4P3-J68-637F`, `4P3 J68 637F`, `4P3J68637F`.
42
45
  */
43
46
  export function normalizeDigiPinInput(input: string): string {
44
- return input.trim().toUpperCase().replace(/[\s\-_.]/g, '');
47
+ return input.trim().toUpperCase().replace(DIGIPIN_SEPARATORS, '');
48
+ }
49
+
50
+ /** True when normalised input is a non-empty prefix of a DigiPin (still being typed). */
51
+ export function isPotentialDigiPinInput(input: string): boolean {
52
+ const pin = normalizeDigiPinInput(input);
53
+ return pin.length > 0 && pin.length <= 10 && VALID_DIGIPIN_PREFIX.test(pin);
45
54
  }
46
55
 
47
56
  /** Canonical display format: XXX-XXX-XXXX */
package/src/core/types.ts CHANGED
@@ -91,6 +91,8 @@ export interface CompleteAddress {
91
91
  formattedAddress: string;
92
92
  /** Buyer-chosen label for saved-address book (defaults to home) */
93
93
  label?: AddressLabel;
94
+ /** Custom label text when `label` is `other` (e.g. "Friend's home") */
95
+ labelText?: string;
94
96
  /** Set when the buyer re-selected an existing saved row (skip createAddress). */
95
97
  addressId?: string;
96
98
  }