PluginProbe
Yatra – Travel Booking & Tour Operator Software / 3.0.13
Yatra – Travel Booking & Tour Operator Software v3.0.13
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 / components / booking / TaxDisplay.tsx

TaxDisplay.tsx in Yatra – Travel Booking & Tour Operator Software 3.0.13, at resources/js/components/booking/TaxDisplay.tsx

88 lines 2.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /**
2 * Tax Display Component
3 *
4 * Shows tax breakdown for booking forms and details
5 *
6 * @package Yatra.Components.Booking
7 * @since 3.0.0
8 */
9
10 import React from "react";
11 import { taxService } from "../../services/TaxService";
12 import { __ } from "../../lib/i18n";
13
14 interface TaxDisplayProps {
15 subtotal: number;
16 country?: string;
17 className?: string;
18 showBreakdown?: boolean;
19 }
20
21 const TaxDisplay: React.FC<TaxDisplayProps> = ({
22 subtotal,
23 country,
24 className = "",
25 showBreakdown = true,
26 }) => {
27 // Calculate tax
28 const taxCalculation = React.useMemo(() => {
29 return taxService.calculateBookingTax(subtotal, country);
30 }, [subtotal, country]);
31
32 // If tax is not enabled or no tax, don't display
33 if (!taxService.isTaxEnabled() || taxCalculation.tax_amount === 0) {
34 return null;
35 }
36
37 return (
38 <div className={`space-y-2 ${className}`}>
39 {/* Subtotal */}
40 <div className="flex justify-between text-sm">
41 <span className="text-gray-600 dark:text-gray-400">
42 {__("Subtotal", "yatra")}
43 </span>
44 <span className="font-medium text-gray-900 dark:text-gray-100">
45 {taxService.formatPrice(taxCalculation.subtotal)}
46 </span>
47 </div>
48
49 {/* Tax Breakdown */}
50 {showBreakdown && taxCalculation.taxes.length > 0 && (
51 <div className="space-y-1">
52 {taxCalculation.taxes.map((tax, index) => (
53 <div key={index} className="flex justify-between text-sm">
54 <span className="text-gray-600 dark:text-gray-400">
55 {tax.name} ({tax.formatted_rate})
56 </span>
57 <span className="font-medium text-gray-900 dark:text-gray-100">
58 {tax.formatted_amount}
59 </span>
60 </div>
61 ))}
62 </div>
63 )}
64
65 {/* Total */}
66 <div className="border-t pt-2">
67 <div className="flex justify-between">
68 <span className="font-semibold text-gray-900 dark:text-gray-100">
69 {__("Total", "yatra")}
70 </span>
71 <span className="font-bold text-lg text-gray-900 dark:text-gray-100">
72 {taxService.formatPrice(taxCalculation.total_amount)}
73 </span>
74 </div>
75 </div>
76
77 {/* Tax Inclusive Notice */}
78 {taxCalculation.tax_inclusive && (
79 <div className="text-xs text-gray-500 dark:text-gray-400 italic">
80 {__("* Tax included in price", "yatra")}
81 </div>
82 )}
83 </div>
84 );
85 };
86
87 export default TaxDisplay;
88