| @@ -7,8 +7,22 @@ | ||
| 7 | 7 | import { apiClient } from "../lib/api-client"; |
| 8 | 8 | import { __ } from "../lib/i18n"; |
| 9 | 9 | import { useToast } from "../components/ui/toast"; |
| 10 | 10 | |
| 11 | +/** | |
| 12 | + * Plan tier a module belongs to. | |
| 13 | + * | |
| 14 | + * - `free` — bundled with the free Yatra plugin, no license required. | |
| 15 | + * - `personal` — unlocked by the entry-level Pro license. | |
| 16 | + * - `growth` — middle tier (AI Assistant + the same-band modules). | |
| 17 | + * - `agency` — top tier (white-label + agency-only modules). | |
| 18 | + * | |
| 19 | + * `growth` was previously missing from this union even though | |
| 20 | + * `Modules.tsx` already renders a `module.plan === "growth"` badge, which | |
| 21 | + * surfaced a `TS2367` "no overlap" warning on every type-check. | |
| 22 | + */ | |
| 23 | +export type ModulePlan = "free" | "personal" | "growth" | "agency"; | |
| 24 | + | |
| 11 | 25 | export interface ModuleDefinition { |
| 12 | 26 | slug: string; |
| 13 | 27 | name: string; |
| 14 | 28 | description?: string; |
| @@ -18,8 +32,10 @@ | ||
| 18 | 32 | is_core?: boolean; |
| 19 | 33 | is_premium?: boolean; |
| 20 | 34 | is_available?: boolean; |
| 21 | 35 | requires_pro?: boolean; |
| 36 | + requires_agency?: boolean; | |
| 37 | + plan?: ModulePlan; | |
| 22 | 38 | purchase_url?: string; |
| 23 | 39 | video_url?: string; |
| 24 | 40 | enabled: boolean; |
| 25 | 41 | tags?: string[]; |
| @@ -121,8 +137,48 @@ | ||
| 121 | 137 | window.yatraAdmin.advancedDiscountEnabled = enabledModules.some( |
| 122 | 138 | (m) => |
| 123 | 139 | m.slug === "advanced_discount" || m.slug === "advanced-discount", |
| 124 | 140 | ); |
| 141 | + // AI Assistant + White Label + WhatsApp control top-level | |
| 142 | + // sidebar menus. Updating these flags here means the menu | |
| 143 | + // appears / disappears instantly when the operator toggles | |
| 144 | + // any of them — Layout.tsx re-evaluates its memoized menuItems | |
| 145 | + // on the `yatra-modules-updated` event dispatched below. | |
| 146 | + window.yatraAdmin.aiAssistantEnabled = enabledModules.some( | |
| 147 | + (m) => m.slug === "ai_assistant" || m.slug === "ai-assistant", | |
| 148 | + ); | |
| 149 | + window.yatraAdmin.whiteLabelEnabled = enabledModules.some( | |
| 150 | + (m) => m.slug === "white_label" || m.slug === "white-label", | |
| 151 | + ); | |
| 152 | + window.yatraAdmin.whatsappEnabled = enabledModules.some( | |
| 153 | + (m) => m.slug === "whatsapp", | |
| 154 | + ); | |
| 155 | + // Channel Manager controls a top-level Agency-only sidebar menu. | |
| 156 | + // Updating this flag here means the menu appears / disappears | |
| 157 | + // instantly when the operator toggles the module — Layout.tsx | |
| 158 | + // re-evaluates its memoized menuItems on the | |
| 159 | + // `yatra-modules-updated` event dispatched below. | |
| 160 | + window.yatraAdmin.channelManagerEnabled = enabledModules.some( | |
| 161 | + (m) => m.slug === "channel_manager" || m.slug === "channel-manager", | |
| 162 | + ); | |
| 163 | + // Webhooks — Agency-only sidebar menu, same instant-toggle pattern. | |
| 164 | + window.yatraAdmin.webhooksEnabled = enabledModules.some( | |
| 165 | + (m) => m.slug === "webhooks", | |
| 166 | + ); | |
| 167 | + // Scheduled Payments — decides whether Payments is a plain menu item | |
| 168 | + // or a parent with All Payments / Scheduled beneath it. Same | |
| 169 | + // instant-toggle pattern, so the submenu appears and disappears as the | |
| 170 | + // module is switched, without reloading the admin. | |
| 171 | + window.yatraAdmin.scheduledPaymentsEnabled = enabledModules.some( | |
| 172 | + (m) => | |
| 173 | + m.slug === "scheduled_payments" || m.slug === "scheduled-payments", | |
| 174 | + ); | |
| 175 | + // Team & Access — Agency-only sidebar menu. Also drives the | |
| 176 | + // teamEnabled flag that <Can/> reads to decide whether the | |
| 177 | + // capability gates apply (vs admin fallback). | |
| 178 | + window.yatraAdmin.teamEnabled = enabledModules.some( | |
| 179 | + (m) => m.slug === "team", | |
| 180 | + ); | |
| 125 | 181 | // Add flags for Pro feature modules |
| 126 | 182 | window.yatraAdmin.showMailchimpSettingsUI = enabledModules.some( |
| 127 | 183 | (m) => m.slug === "mailchimp", |
| 128 | 184 | ); |
| @@ -234,8 +290,48 @@ | ||
| 234 | 290 | ); |
| 235 | 291 | window.yatraAdmin.advancedDiscountEnabled = enabledModules.some( |
| 236 | 292 | (m) => |
| 237 | 293 | m.slug === "advanced_discount" || m.slug === "advanced-discount", |
| 294 | + ); | |
| 295 | + // AI Assistant + White Label + WhatsApp control top-level | |
| 296 | + // sidebar menus. Updating these flags here means the menu | |
| 297 | + // appears / disappears instantly when the operator toggles | |
| 298 | + // any of them — Layout.tsx re-evaluates its memoized menuItems | |
| 299 | + // on the `yatra-modules-updated` event dispatched below. | |
| 300 | + window.yatraAdmin.aiAssistantEnabled = enabledModules.some( | |
| 301 | + (m) => m.slug === "ai_assistant" || m.slug === "ai-assistant", | |
| 302 | + ); | |
| 303 | + window.yatraAdmin.whiteLabelEnabled = enabledModules.some( | |
| 304 | + (m) => m.slug === "white_label" || m.slug === "white-label", | |
| 305 | + ); | |
| 306 | + window.yatraAdmin.whatsappEnabled = enabledModules.some( | |
| 307 | + (m) => m.slug === "whatsapp", | |
| 308 | + ); | |
| 309 | + // Channel Manager controls a top-level Agency-only sidebar menu. | |
| 310 | + // Updating this flag here means the menu appears / disappears | |
| 311 | + // instantly when the operator toggles the module — Layout.tsx | |
| 312 | + // re-evaluates its memoized menuItems on the | |
| 313 | + // `yatra-modules-updated` event dispatched below. | |
| 314 | + window.yatraAdmin.channelManagerEnabled = enabledModules.some( | |
| 315 | + (m) => m.slug === "channel_manager" || m.slug === "channel-manager", | |
| 316 | + ); | |
| 317 | + // Webhooks — Agency-only sidebar menu, same instant-toggle pattern. | |
| 318 | + window.yatraAdmin.webhooksEnabled = enabledModules.some( | |
| 319 | + (m) => m.slug === "webhooks", | |
| 320 | + ); | |
| 321 | + // Scheduled Payments — decides whether Payments is a plain menu item | |
| 322 | + // or a parent with All Payments / Scheduled beneath it. Same | |
| 323 | + // instant-toggle pattern, so the submenu appears and disappears as the | |
| 324 | + // module is switched, without reloading the admin. | |
| 325 | + window.yatraAdmin.scheduledPaymentsEnabled = enabledModules.some( | |
| 326 | + (m) => | |
| 327 | + m.slug === "scheduled_payments" || m.slug === "scheduled-payments", | |
| 328 | + ); | |
| 329 | + // Team & Access — Agency-only sidebar menu. Also drives the | |
| 330 | + // teamEnabled flag that <Can/> reads to decide whether the | |
| 331 | + // capability gates apply (vs admin fallback). | |
| 332 | + window.yatraAdmin.teamEnabled = enabledModules.some( | |
| 333 | + (m) => m.slug === "team", | |
| 238 | 334 | ); |
| 239 | 335 | // Add flags for Pro feature modules |
| 240 | 336 | window.yatraAdmin.showMailchimpSettingsUI = enabledModules.some( |
| 241 | 337 | (m) => m.slug === "mailchimp", |