PluginProbe
Yatra – Travel Booking & Tour Operator Software / 3.0.2.7
Yatra – Travel Booking & Tour Operator Software v3.0.2.7
3.0.16 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 All 84 releases
yatra / resources / js / App.tsx

App.tsx in Yatra – Travel Booking & Tour Operator Software 3.0.2.7, at resources/js/App.tsx

330 lines 11.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import React, { useMemo, useState, useEffect } from "react";
2 import Layout from "./components/Layout";
3 import Dashboard from "./pages/Dashboard";
4 import Trips from "./pages/Trips";
5 import TripForm from "./pages/TripForm";
6 import Activities from "./pages/Activities";
7 import ActivityForm from "./pages/ActivityForm";
8 import Destinations from "./pages/Destinations";
9 import DestinationForm from "./pages/DestinationForm";
10 import Categories from "./pages/Categories";
11 import CategoryForm from "./pages/CategoryForm";
12 import DifficultyLevels from "./pages/DifficultyLevels";
13 import DifficultyLevelForm from "./pages/DifficultyLevelForm";
14 import Bookings from "./pages/Bookings";
15 import BookingForm from "./pages/BookingForm";
16 import ViewBooking from "./pages/ViewBooking";
17 import Customers from "./pages/Customers";
18 import CustomerForm from "./pages/CustomerForm";
19 import ViewCustomer from "./pages/ViewCustomer";
20 import Reviews from "./pages/Reviews";
21 import ReviewForm from "./pages/ReviewForm";
22 import ViewReview from "./pages/ViewReview";
23 import Reports from "./pages/Reports";
24 import Tools from "./components/Tools";
25 import Settings from "./pages/Settings";
26 import ItemTypes from "./pages/ItemTypes";
27 import ItemTypeForm from "./pages/ItemTypeForm";
28 import Items from "./pages/Items";
29 import ItemForm from "./pages/ItemForm";
30 import Itinerary from "./pages/Itinerary";
31 import ItineraryForm from "./pages/ItineraryForm";
32 import Discounts from "./pages/Discounts";
33 import DiscountForm from "./pages/DiscountForm";
34 import Payments from "./pages/Payments";
35 import PaymentForm from "./pages/PaymentForm";
36 import ViewPayment from "./pages/ViewPayment";
37 import TravelerCategories from "./pages/TravelerCategories";
38 import TravelerCategoryForm from "./pages/TravelerCategoryForm";
39 import Availability from "./pages/Availability";
40 import AvailabilityForm from "./pages/AvailabilityForm";
41 import RecurringRuleForm from "./pages/RecurringRuleForm";
42 import Departures from "./pages/Departures";
43 import DepartureForm from "./pages/DepartureForm";
44 import ViewDeparture from "./pages/ViewDeparture";
45 import Enquiries from "./pages/Enquiries";
46 import ViewEnquiry from "./pages/ViewEnquiry";
47 import EnquiryForm from "./pages/EnquiryForm";
48 import Modules from "./pages/Modules";
49 import Travelers from "./pages/Travelers";
50 import GoogleCalendar from "./pages/GoogleCalendar";
51 import AdditionalServices from "./pages/AdditionalServices";
52 import AdditionalServicesForm from "./pages/AdditionalServicesForm";
53 import TripConsent from "./pages/TripConsent";
54 import TripConsentForm from "./pages/TripConsentForm";
55 import EmailAutomation from "./pages/EmailAutomation";
56 import EmailTemplateForm from "./pages/EmailTemplateForm";
57 import EmailSequenceForm from "./pages/EmailSequenceForm";
58 import AbandonedRecovery from "./pages/AbandonedRecovery";
59 import DynamicPricing from "./pages/DynamicPricing";
60 import DynamicPricingRuleForm from "./pages/DynamicPricingRuleForm";
61 import Attributes from "./pages/Attributes";
62 import AttributeForm from "./pages/AttributeForm";
63 import License from "./pages/License";
64
65 const App: React.FC = () => {
66 // Force re-render on URL change
67 const [urlKey, setUrlKey] = useState(0);
68
69 useEffect(() => {
70 const handleLocationChange = () => {
71 setUrlKey((prev) => prev + 1);
72 };
73
74 // Listen for popstate (back/forward button)
75 window.addEventListener("popstate", handleLocationChange);
76
77 // Also check periodically (fallback for direct navigation)
78 const interval = setInterval(() => {
79 const currentSearch = window.location.search;
80 if (currentSearch !== (window as any).__lastSearch) {
81 (window as any).__lastSearch = currentSearch;
82 handleLocationChange();
83 }
84 }, 100);
85
86 return () => {
87 window.removeEventListener("popstate", handleLocationChange);
88 clearInterval(interval);
89 };
90 }, []);
91
92 // Get subpage, tab, and action from URL query parameters
93 const subpage = useMemo(() => {
94 const params = new URLSearchParams(window.location.search);
95 return params.get("subpage") || "dashboard";
96 }, [urlKey]);
97
98 const tab = useMemo(() => {
99 const params = new URLSearchParams(window.location.search);
100 return params.get("tab") || "all";
101 }, [urlKey]);
102
103 const action = useMemo(() => {
104 const params = new URLSearchParams(window.location.search);
105 return params.get("action");
106 }, [urlKey, subpage]);
107
108 // Render the appropriate page based on subpage, tab, and action parameters
109 const renderPage = () => {
110 switch (subpage.toLowerCase()) {
111 case "trips":
112 // Handle trips tabs
113 switch (tab.toLowerCase()) {
114 case "activities":
115 // Check if we're creating or editing an activity
116 if (action === "create" || action === "edit") {
117 return <ActivityForm />;
118 }
119 return <Activities />;
120 case "destinations":
121 // Check if we're creating or editing a destination
122 if (action === "create" || action === "edit") {
123 return <DestinationForm />;
124 }
125 return <Destinations />;
126 case "categories":
127 // Check if we're creating or editing a category
128 if (action === "create" || action === "edit") {
129 return <CategoryForm />;
130 }
131 return <Categories />;
132 case "difficulty-levels":
133 // Check if we're creating or editing a difficulty level
134 if (action === "create" || action === "edit") {
135 return <DifficultyLevelForm />;
136 }
137 return <DifficultyLevels />;
138 case "availability":
139 // Check if we're creating or editing a recurring rule
140 if (action === "create-rule" || action === "edit-rule") {
141 return <RecurringRuleForm />;
142 }
143 // Check if we're creating or editing an availability date
144 if (action === "create" || action === "edit") {
145 return <AvailabilityForm />;
146 }
147 return <Availability />;
148 case "additional-services":
149 // Check if we're creating or editing a service
150 if (action === "create" || action === "edit") {
151 return <AdditionalServicesForm />;
152 }
153 return <AdditionalServices />;
154 case "trip-consent":
155 // Check if we're creating or editing a consent form
156 if (action === "create" || action === "edit") {
157 return <TripConsentForm />;
158 }
159 return <TripConsent />;
160 case "attributes":
161 // Check if we're creating or editing an attribute
162 if (action === "create" || action === "edit") {
163 return <AttributeForm />;
164 }
165 return <Attributes />;
166 case "all":
167 default:
168 // Check if we're creating or editing a trip
169 if (action === "create" || action === "edit") {
170 return <TripForm />;
171 }
172 return <Trips />;
173 }
174 case "bookings":
175 // Check if we're viewing, creating, or editing a booking
176 if (action === "view") {
177 return <ViewBooking />;
178 }
179 if (action === "create" || action === "edit") {
180 return <BookingForm />;
181 }
182 return <Bookings />;
183 case "customers":
184 // Check if we're viewing, creating, or editing a customer
185 if (action === "view") {
186 return <ViewCustomer />;
187 }
188 if (action === "create" || action === "edit") {
189 return <CustomerForm />;
190 }
191 return <Customers />;
192 case "travelers":
193 return <Travelers />;
194 case "enquiries":
195 // Check if we're viewing or editing an enquiry
196 if (action === "view") {
197 return <ViewEnquiry />;
198 }
199 if (action === "edit" || action === "new") {
200 return <EnquiryForm />;
201 }
202 return <Enquiries />;
203 case "reviews":
204 // Check if we're viewing, creating, or editing a review
205 if (action === "view") {
206 return <ViewReview />;
207 }
208 if (action === "create" || action === "edit") {
209 return <ReviewForm />;
210 }
211 return <Reviews />;
212 case "email-automation":
213 // Check if we're creating or editing a template or sequence
214 if (action === "create" && tab === "template") {
215 return <EmailTemplateForm />;
216 }
217 if (action === "edit" && tab === "template") {
218 return <EmailTemplateForm />;
219 }
220 if (action === "create" && tab === "sequence") {
221 return <EmailSequenceForm />;
222 }
223 if (action === "edit" && tab === "sequence") {
224 return <EmailSequenceForm />;
225 }
226 // Default: if action is edit without tab, assume template
227 if (action === "edit") {
228 return <EmailTemplateForm />;
229 }
230 return <EmailAutomation />;
231 case "itinerary":
232 // Handle itinerary tabs
233 switch (tab.toLowerCase()) {
234 case "item-types":
235 // Check if we're creating or editing an item type
236 if (action === "create" || action === "edit") {
237 return <ItemTypeForm />;
238 }
239 return <ItemTypes />;
240 case "items":
241 // Check if we're creating or editing an item
242 if (action === "create" || action === "edit") {
243 return <ItemForm />;
244 }
245 return <Items />;
246 case "itinerary":
247 // Check if we're creating or editing an itinerary entry
248 if (action === "create" || action === "edit") {
249 return <ItineraryForm />;
250 }
251 return <Itinerary />;
252 default:
253 return <ItemTypes />;
254 }
255 case "departures":
256 // Check if we're viewing, creating, or editing a departure
257 if (action === "view") {
258 return <ViewDeparture />;
259 }
260 if (action === "create" || action === "edit") {
261 return <DepartureForm />;
262 }
263 return <Departures />;
264 case "discounts":
265 // Check if we're creating or editing a discount
266 if (action === "create" || action === "edit") {
267 return <DiscountForm />;
268 }
269 return <Discounts />;
270 case "payments":
271 // Check if we're viewing, creating, or editing a payment
272 if (action === "view") {
273 return <ViewPayment />;
274 }
275 if (action === "create" || action === "edit") {
276 return <PaymentForm />;
277 }
278 return <Payments />;
279 case "traveler-categories":
280 // Check if we're creating or editing a traveler category
281 if (action === "create" || action === "edit") {
282 return <TravelerCategoryForm />;
283 }
284 return <TravelerCategories />;
285 case "reports":
286 return <Reports />;
287 case "tools":
288 return <Tools />;
289 case "settings":
290 return <Settings />;
291 case "modules":
292 return <Modules />;
293 case "google-calendar":
294 return <GoogleCalendar />;
295 case "additional-services":
296 // Check if we're creating or editing a service
297 if (action === "create" || action === "edit") {
298 return <AdditionalServicesForm />;
299 }
300 return <AdditionalServices />;
301 case "trip-consent":
302 // Check if we're creating or editing a consent form
303 if (action === "create" || action === "edit") {
304 return <TripConsentForm />;
305 }
306 return <TripConsent />;
307 case "abandoned-recovery":
308 return <AbandonedRecovery tab={tab} />;
309 case "dynamic-pricing":
310 if (
311 action === "create-pricing-rule" ||
312 action === "edit-pricing-rule"
313 ) {
314 return <DynamicPricingRuleForm />;
315 }
316
317 return <DynamicPricing />;
318 case "license":
319 return <License />;
320 case "dashboard":
321 default:
322 return <Dashboard />;
323 }
324 };
325
326 return <Layout>{renderPage()}</Layout>;
327 };
328
329 export default App;
330