update
This commit is contained in:
37
Frontend/src/shared/components/CurrencyIcon.tsx
Normal file
37
Frontend/src/shared/components/CurrencyIcon.tsx
Normal file
@@ -0,0 +1,37 @@
|
||||
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 || 'VND';
|
||||
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;
|
||||
|
||||
Reference in New Issue
Block a user