fd57a35820
Release package / release (push) Successful in 1h12m42s
Co-authored-by: Thanh Quy - wolf <524H0124@student.tdtu.edu.vn> Reviewed-on: #28 Reviewed-by: TakahashiNguyen <takahashi.ng@icloud.com> Co-authored-by: TaNguyenThanhQuy <tanguyenthanhquy@noreply.localhost> Co-committed-by: TaNguyenThanhQuy <tanguyenthanhquy@noreply.localhost>
32 lines
655 B
TypeScript
32 lines
655 B
TypeScript
import { HTMLAttributes } from "react";
|
|
|
|
export interface PriceBadgeProps extends HTMLAttributes<HTMLSpanElement> {
|
|
price: number;
|
|
currency?: string;
|
|
className?: string;
|
|
}
|
|
|
|
export default function PriceBadge({
|
|
price,
|
|
currency = "VND",
|
|
className = "",
|
|
...props
|
|
}: PriceBadgeProps) {
|
|
const formattedPrice =
|
|
currency === "VND"
|
|
? price.toLocaleString("vi-VN", {
|
|
style: "currency",
|
|
currency: "VND",
|
|
})
|
|
: `${price.toFixed(2)} ${currency}`;
|
|
|
|
return (
|
|
<span
|
|
className={`text-sm font-bold text-(--color-primary) ${className}`}
|
|
{...props}
|
|
>
|
|
{formattedPrice}
|
|
</span>
|
|
);
|
|
}
|