/** * Tax Display Component * * Shows tax breakdown for booking forms and details * * @package Yatra.Components.Booking * @since 3.0.0 */ import React from "react"; import { taxService } from "../../services/TaxService"; import { __ } from "../../lib/i18n"; interface TaxDisplayProps { subtotal: number; country?: string; className?: string; showBreakdown?: boolean; } const TaxDisplay: React.FC = ({ subtotal, country, className = "", showBreakdown = true, }) => { // Calculate tax const taxCalculation = React.useMemo(() => { return taxService.calculateBookingTax(subtotal, country); }, [subtotal, country]); // If tax is not enabled or no tax, don't display if (!taxService.isTaxEnabled() || taxCalculation.tax_amount === 0) { return null; } return (
{/* Subtotal */}
{__("Subtotal", "yatra")} {taxService.formatPrice(taxCalculation.subtotal)}
{/* Tax Breakdown */} {showBreakdown && taxCalculation.taxes.length > 0 && (
{taxCalculation.taxes.map((tax, index) => (
{tax.name} ({tax.formatted_rate}) {tax.formatted_amount}
))}
)} {/* Total */}
{__("Total", "yatra")} {taxService.formatPrice(taxCalculation.total_amount)}
{/* Tax Inclusive Notice */} {taxCalculation.tax_inclusive && (
{__("* Tax included in price", "yatra")}
)}
); }; export default TaxDisplay;