| @@ -9,8 +9,18 @@ | ||
| 9 | 9 | apiUrl?: string; |
| 10 | 10 | restUrl?: string; |
| 11 | 11 | nonce?: string; |
| 12 | 12 | brandLogoUrl?: string; |
| 13 | + /** | |
| 14 | + * Operator-facing brand name. When the White Label module is | |
| 15 | + * active (Agency-tier only) and the operator has filled in | |
| 16 | + * "Plugin name" in WL settings, this is THAT value — otherwise | |
| 17 | + * it's "Yatra". Use this everywhere instead of hardcoding | |
| 18 | + * "Yatra" so the UI reflects the operator's brand for resellers. | |
| 19 | + * | |
| 20 | + * Injected by AdminAssetsProvider via `yatra_get_brand_name()`. | |
| 21 | + */ | |
| 22 | + brandName?: string; | |
| 13 | 23 | pluginUrl?: string; |
| 14 | 24 | currentUserAvatar?: string; |
| 15 | 25 | currentUser?: number; |
| 16 | 26 | siteUrl?: string; |
| @@ -25,13 +35,15 @@ | ||
| 25 | 35 | proVersion?: string | null; |
| 26 | 36 | translations?: Record<string, string>; |
| 27 | 37 | locale?: string; |
| 28 | 38 | emailAutomationEnabled?: boolean; |
| 39 | + emailTemplateOverridesEnabled?: boolean; | |
| 29 | 40 | tripConsentEnabled?: boolean; |
| 30 | 41 | additionalServicesEnabled?: boolean; |
| 31 | 42 | abandonedBookingRecoveryEnabled?: boolean; |
| 32 | 43 | dynamicPricingEnabled?: boolean; |
| 33 | 44 | dynamicFormFieldEnabled?: boolean; |
| 45 | + bookingFormConditionsEnabled?: boolean; | |
| 34 | 46 | advancedDiscountEnabled?: boolean; |
| 35 | 47 | showGoogleCalendarSettingsUI?: boolean; |
| 36 | 48 | showMailchimpSettingsUI?: boolean; |
| 37 | 49 | showFacebookPixelSettingsUI?: boolean; |
| @@ -36,8 +48,19 @@ | ||
| 36 | 48 | showMailchimpSettingsUI?: boolean; |
| 37 | 49 | showFacebookPixelSettingsUI?: boolean; |
| 38 | 50 | showGoogleAnalyticsSettingsUI?: boolean; |
| 39 | 51 | flexiblePaymentsEnabled?: boolean; |
| 52 | + // Growth + Agency tier modules — set by their respective Pro | |
| 53 | + // modules via yatra_admin_localized_data filter, OR by the | |
| 54 | + // free plugin's AdminAssetsProvider (canonical source via | |
| 55 | + // ModuleManager::isModuleEnabled). useModules() also writes | |
| 56 | + // these at runtime once /modules resolves. | |
| 57 | + aiAssistantEnabled?: boolean; | |
| 58 | + whiteLabelEnabled?: boolean; | |
| 59 | + whatsappEnabled?: boolean; | |
| 60 | + channelManagerEnabled?: boolean; | |
| 61 | + webhooksEnabled?: boolean; | |
| 62 | + scheduledPaymentsEnabled?: boolean; | |
| 40 | 63 | currency?: string; |
| 41 | 64 | date_format?: string; |
| 42 | 65 | time_format?: string; |
| 43 | 66 | calendar_name?: string; |
| @@ -96,8 +119,33 @@ | ||
| 96 | 119 | connected?: boolean; |
| 97 | 120 | redirect_uri?: string; |
| 98 | 121 | last_sync?: string | null; |
| 99 | 122 | }; |
| 123 | + // Team & Access (Agency-tier) — injected by Team module's | |
| 124 | + // LocalizedData service. Absent when module isn't installed. | |
| 125 | + teamEnabled?: boolean; | |
| 126 | + /** | |
| 127 | + * Forward-looking "keep access on module disable" setting. | |
| 128 | + * Only consulted when the Team & Access module is DISABLED: | |
| 129 | + * - `false` (default): yatra_* caps are stripped for non-admin | |
| 130 | + * users until the module is re-enabled. | |
| 131 | + * - `true`: WP-native role machinery keeps resolving caps from | |
| 132 | + * the stored role records — team members keep their access | |
| 133 | + * even after disabling the module. | |
| 134 | + * | |
| 135 | + * When the module is enabled, this setting is irrelevant — | |
| 136 | + * caps resolve normally through the full layered chain (admin | |
| 137 | + * fallback, expiry, revoke, role, grant). | |
| 138 | + */ | |
| 139 | + teamKeepAccessOnModuleDisable?: boolean; | |
| 140 | + isWpAdmin?: boolean; | |
| 141 | + userCaps?: string[]; | |
| 142 | + userScopes?: { | |
| 143 | + destinations: number[]; | |
| 144 | + activities: number[]; | |
| 145 | + trips: number[]; | |
| 146 | + categories: number[]; | |
| 147 | + }; | |
| 100 | 148 | }; |
| 101 | 149 | } |
| 102 | 150 | } |
| 103 | 151 | |
| @@ -161,16 +209,45 @@ | ||
| 161 | 209 | ...args, |
| 162 | 210 | ); |
| 163 | 211 | } |
| 164 | 212 | |
| 165 | -export { __, _x, sprintf }; | |
| 213 | +/** | |
| 214 | + * Operator brand name — "Yatra" by default, or whatever the operator | |
| 215 | + * has set in the White Label module (Agency tier). | |
| 216 | + * | |
| 217 | + * Use this in user-visible strings instead of hardcoding "Yatra": | |
| 218 | + * | |
| 219 | + * const brand = brandName(); | |
| 220 | + * sprintf(__("%s role", "yatra"), brand) // "Acme role" if rebranded | |
| 221 | + * | |
| 222 | + * Always pass the brand as an interpolated argument so the translatable | |
| 223 | + * string stays generic — that keeps `make-pot` extraction working AND | |
| 224 | + * means a translator only has to translate "%s role" once, regardless | |
| 225 | + * of brand. | |
| 226 | + */ | |
| 227 | +function brandName(): string { | |
| 228 | + if (typeof window === "undefined") return "Yatra"; | |
| 229 | + return (window.yatraAdmin?.brandName as string | undefined) || "Yatra"; | |
| 230 | +} | |
| 166 | 231 | |
| 232 | +export { __, _x, sprintf, brandName }; | |
| 233 | + | |
| 167 | 234 | /** |
| 168 | 235 | * Get translated string with number |
| 169 | 236 | * @param single - Single form |
| 170 | 237 | * @param plural - Plural form |
| 171 | 238 | * @param number - Number to determine form |
| 239 | + * @param textDomain - Optional text domain; accepted for API parity with | |
| 240 | + * WordPress's own `_n()` so call sites that already pass | |
| 241 | + * `"yatra"` as a fourth arg type-check. Currently | |
| 242 | + * unused — `__()` does its own domain resolution via | |
| 243 | + * the translations map injected on `window.yatraAdmin`. | |
| 172 | 244 | * @returns Translated string |
| 173 | 245 | */ |
| 174 | -export const _n = (single: string, plural: string, number: number): string => { | |
| 246 | +export const _n = ( | |
| 247 | + single: string, | |
| 248 | + plural: string, | |
| 249 | + number: number, | |
| 250 | + _textDomain?: string, | |
| 251 | +): string => { | |
| 175 | 252 | return number === 1 ? __(single) : __(plural); |
| 176 | 253 | }; |