| @@ -7,8 +7,10 @@ | ||
| 7 | 7 | * @since 3.0.0 |
| 8 | 8 | */ |
| 9 | 9 | |
| 10 | 10 | import { formatYatraMoney } from "../lib/currency-display"; |
| 11 | +import { apiClient } from "../lib/api-client"; | |
| 12 | +import { API_ENDPOINTS } from "../lib/api-endpoints"; | |
| 11 | 13 | |
| 12 | 14 | interface TaxDetails { |
| 13 | 15 | tax_amount: number; |
| 14 | 16 | tax_rate: number; |
| @@ -55,11 +57,13 @@ | ||
| 55 | 57 | * Load tax settings from API |
| 56 | 58 | */ |
| 57 | 59 | async loadTaxSettings(): Promise<void> { |
| 58 | 60 | try { |
| 59 | - const response = await fetch("/wp-json/yatra/v1/settings"); | |
| 60 | - const settings = await response.json(); | |
| 61 | - this.taxSettings = settings; | |
| 61 | + // Through the shared client so the REST nonce is sent — a bare fetch() | |
| 62 | + // was answered with 401 on every admin booking form, so tax settings | |
| 63 | + // never actually loaded here. | |
| 64 | + const settings = await apiClient.get(API_ENDPOINTS.SETTINGS); | |
| 65 | + this.taxSettings = (settings as any)?.data ?? settings; | |
| 62 | 66 | } catch (error) { |
| 63 | 67 | console.error("Failed to load tax settings:", error); |
| 64 | 68 | } |
| 65 | 69 | } |