nyuchimzizi
Mzizi — an open-architecture project of the Bundu Foundation, operated and developed by Nyuchi. Built on the Five African Minerals palette.
Built by Nyuchi Africav4.0.39
Route fare display with breakdown by segment, applicable discounts, and total. Supports multi-currency display. Used in Transport for route cost estimation before booking.
View the full component source code below.
import * as React from "react"
import { cn } from "@/lib/utils"
interface FareSegment {
label: string
amount: number
}
interface FareCalculatorProps extends React.ComponentProps<"div"> {
segments: FareSegment[]
currency?: string
discount?: { label: string; amount: number }
total?: number
}
function FareCalculator({ segments, currency = "MXT", discount, total, loading = false, className, ...props }: FareCalculatorProps) {
const computedTotal = total ?? segments.reduce((sum, s) => sum + s.amount, 0) - (discount?.amount ?? 0)
return (
<div
data-slot="fare-calculator" data-portal="https://design.nyuchi.com/components/fare-calculator" role="article"
className={cn("rounded-[var(--radius-lg,14px)] border border-border bg-card p-4", className)}
{...props}
>
<div className="text-xs font-medium text-muted-foreground">Fare breakdown</div>
<div className="mt-2 space-y-1.5">
{segments.map((seg, i) => (
<div key={i} className="flex items-center justify-between text-sm">
<span className="text-muted-foreground">{seg.label}</span>
<span className="tabular-nums">{seg.amount.toFixed(2)} {currency}</span>
</div>
))}
{discount && (
<div className="flex items-center justify-between text-sm text-[var(--color-malachite,#64FFDA)]">
<span>{discount.label}</span>
<span className="tabular-nums">-{discount.amount.toFixed(2)} {currency}</span>
</div>
)}
</div>
<div className="mt-3 flex items-center justify-between border-t border-border pt-3">
<span className="text-sm font-medium">Total</span>
<span className="text-base font-bold tabular-nums">{computedTotal.toFixed(2)} {currency}</span>
</div>
</div>
)
}
export { FareCalculator }
export type { FareCalculatorProps }
npx shadcn@latest add https://mzizi.dev/api/v1/ui/fare-calculatorFetch this component's metadata and source code from the registry API.
/api/v1/ui/fare-calculator