PluginProbe
Yatra – Travel Booking & Tour Operator Software / 3.0.10
Yatra – Travel Booking & Tour Operator Software v3.0.10
3.0.15 3.0.14 3.0.14.1 3.0.14.2 3.0.12 3.0.13 3.0.11 3.0.10 3.0.9 3.0.8 3.0.7 3.0.6 3.0.5 3.0.5.1 3.0.4 3.0.3 3.0.2.9 3.0.2.7 3.0.2.8 3.0.2.6 trunk 1.0.0 2.0.0 2.0.1 2.0.10 All 83 releases
yatra / resources / js / lib / plugin-utils.ts

plugin-utils.ts in Yatra – Travel Booking & Tour Operator Software 3.0.10, at resources/js/lib/plugin-utils.ts

78 lines 1.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /**
2 * Plugin utility functions
3 */
4
5 /**
6 * Check if the Pro plugin is active
7 * @returns {boolean} True if Pro plugin is active, false otherwise
8 */
9 export const isProPluginActive = (): boolean => {
10 const raw = (window as any).yatraAdmin?.isPro;
11 let isPro = false;
12
13 if (
14 raw === true ||
15 raw === "true" ||
16 raw === 1 ||
17 raw === "1" ||
18 raw === "yes"
19 ) {
20 isPro = true;
21 } else if (
22 raw === false ||
23 raw === "false" ||
24 raw === 0 ||
25 raw === "0" ||
26 raw === "no"
27 ) {
28 isPro = false;
29 }
30 return isPro;
31 };
32
33 /**
34 * Check if a specific module is active
35 * @param moduleName - The name of the module to check (e.g., 'email_automation')
36 * @returns {boolean} True if the module is active, false otherwise
37 */
38 export const isModuleActive = (moduleName: string): boolean => {
39 if (!isProPluginActive()) {
40 return false;
41 }
42 if (!moduleName || typeof moduleName !== "string") {
43 return false;
44 }
45
46 // Convert module name to camelCase with 'Enabled' suffix (e.g., 'email_automation' -> 'emailAutomationEnabled')
47 const camelCaseName = moduleName.replace(/_([a-z])/g, (_, letter) =>
48 letter.toUpperCase(),
49 );
50 const localizedKey = camelCaseName + "Enabled";
51
52 const raw = (window as any).yatraAdmin?.[localizedKey];
53 let isActive = false;
54
55 if (
56 raw === true ||
57 raw === "true" ||
58 raw === 1 ||
59 raw === "1" ||
60 raw === "yes"
61 ) {
62 isActive = true;
63 } else if (
64 raw === false ||
65 raw === "false" ||
66 raw === 0 ||
67 raw === "0" ||
68 raw === "no"
69 ) {
70 isActive = false;
71 }
72 return isActive;
73 };
74
75 /** Yatra Pro + Email Automation module (DB templates, sequences, logs). */
76 export const isEmailAutomationModuleEnabled = (): boolean =>
77 isModuleActive("email_automation");
78