Files
Hotel-Booking/Frontend/src/shared/components/CurrencyIcon.tsx
Iliyan Angelov e43a95eafb updates
2025-12-09 00:14:21 +02:00

38 lines
893 B
TypeScript

import React from 'react';
import { useCurrency } from '../../features/payments/contexts/CurrencyContext';
import { getCurrencySymbol } from '../utils/format';
interface CurrencyIconProps {
className?: string;
size?: number;
currency?: string;
}
const CurrencyIcon: React.FC<CurrencyIconProps> = ({
className = '',
size = 24,
currency
}) => {
const { currency: contextCurrency } = useCurrency();
const currencyToUse = currency || contextCurrency || 'USD';
const symbol = getCurrencySymbol(currencyToUse);
return (
<div
className={`flex items-center justify-center font-semibold ${className}`}
style={{
width: `${size}px`,
height: `${size}px`,
fontSize: `${size * 0.6}px`,
lineHeight: 1
}}
title={`${currencyToUse} currency symbol`}
>
{symbol}
</div>
);
};
export default CurrencyIcon;