PluginProbe
Yatra – Travel Booking & Tour Operator Software / 3.0.16
Yatra – Travel Booking & Tour Operator Software v3.0.16
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 / lib / meal-plan-labels.ts

meal-plan-labels.ts in Yatra – Travel Booking & Tour Operator Software 3.0.16, at resources/js/lib/meal-plan-labels.ts

53 lines 1.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /**
2 * Trip meal_plan field: canonical slugs and translated labels (admin + consistency with PHP).
3 */
4 import { __ } from "./i18n";
5
6 export type MealPlanSlug =
7 | ""
8 | "breakfast"
9 | "half_board"
10 | "full_board"
11 | "all_inclusive"
12 | "none";
13
14 /** Options for <select> (value + translated label). */
15 export const MEAL_PLAN_SELECT_OPTIONS: {
16 value: MealPlanSlug;
17 label: string;
18 }[] = [
19 { value: "", label: __("Select meal plan", "yatra") },
20 { value: "breakfast", label: __("Breakfast Only", "yatra") },
21 {
22 value: "half_board",
23 label: __("Half Board (Breakfast + Dinner)", "yatra"),
24 },
25 { value: "full_board", label: __("Full Board (All Meals)", "yatra") },
26 { value: "all_inclusive", label: __("All Inclusive", "yatra") },
27 { value: "none", label: __("No Meals Included", "yatra") },
28 ];
29
30 /** Normalize legacy or odd casing to canonical slug key (underscore form). */
31 export function normalizeMealPlanSlug(raw: string): string {
32 return String(raw || "")
33 .trim()
34 .toLowerCase()
35 .replace(/[\s-]+/g, "_");
36 }
37
38 /** Translated label for a stored slug, or title-cased fallback for unknown values. */
39 export function getMealPlanLabel(raw: string): string {
40 const key = normalizeMealPlanSlug(raw) as MealPlanSlug;
41 const row = MEAL_PLAN_SELECT_OPTIONS.find((o) => o.value === key);
42 if (row) {
43 return row.label;
44 }
45 if (!key) {
46 return "";
47 }
48 return key
49 .split("_")
50 .map((p) => p.charAt(0).toUpperCase() + p.slice(1).toLowerCase())
51 .join(" ");
52 }
53