| @@ -71,8 +71,30 @@ | ||
| 71 | 71 | return Object.entries(map).map(([code, name]) => ({ code, name })); |
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 74 | /** |
| 75 | + * Country options shaped for SearchableSelect, each carrying its national flag. | |
| 76 | + * | |
| 77 | + * The flag base URL is localized by AdminAssetsProvider (`flagBase`), pointing at | |
| 78 | + * the SVG set the plugin already ships and the phone widget already uses — one | |
| 79 | + * source of flag assets for the whole product. Without that global the options | |
| 80 | + * are returned flagless rather than with broken images. | |
| 81 | + */ | |
| 82 | +export function getCountrySelectOptions(): Array<{ | |
| 83 | + value: string; | |
| 84 | + label: string; | |
| 85 | + icon?: string; | |
| 86 | +}> { | |
| 87 | + const base = (window as any).yatraAdmin?.flagBase || ""; | |
| 88 | + | |
| 89 | + return getCountryOptions().map((c) => ({ | |
| 90 | + value: c.code, | |
| 91 | + label: c.name, | |
| 92 | + icon: base ? base + c.code.toLowerCase() + ".svg" : undefined, | |
| 93 | + })); | |
| 94 | +} | |
| 95 | + | |
| 96 | +/** | |
| 75 | 97 | * Look up a single country's display name by ISO-3166 code. |
| 76 | 98 | * Returns the code itself when unknown — same fallback the PHP |
| 77 | 99 | * helper uses, so the two never disagree on rendering. |
| 78 | 100 | */ |