refactor: improvements in UI and book consultion option
- Login is not responsive - Add country field in book consultant any country - correct form submit of book consultant in mobile view - updatr email in privacy page - make home page slider responsive - redirect login whentokenexpired
This commit is contained in:
25
components/common/CurrencyTooltip.jsx
Normal file
25
components/common/CurrencyTooltip.jsx
Normal file
@@ -0,0 +1,25 @@
|
||||
// Create a new component for currency conversion explanation
|
||||
import React from 'react';
|
||||
import { Info } from 'lucide-react';
|
||||
import { useCurrency } from '@/app/contexts/currencyContext';
|
||||
|
||||
const CurrencyTooltip = () => {
|
||||
const { selectedCurrency, SUPPORTED_CURRENCIES } = useCurrency();
|
||||
|
||||
// Only show for non-INR currencies
|
||||
if (selectedCurrency === 'INR') return null;
|
||||
|
||||
return (
|
||||
<div className="relative inline-block group ml-2">
|
||||
<Info className="w-4 h-4 text-gray-400 cursor-help" />
|
||||
<div className="absolute bottom-full left-1/2 transform -translate-x-1/2 mb-2 w-64 p-2 bg-white border rounded shadow-lg
|
||||
text-xs text-gray-700 opacity-0 group-hover:opacity-100 transition-opacity duration-200 z-50">
|
||||
Prices are converted from Indian Rupees (₹) to {SUPPORTED_CURRENCIES[selectedCurrency]?.name}
|
||||
({SUPPORTED_CURRENCIES[selectedCurrency]?.symbol}) based on current exchange rates.
|
||||
Actual charges may vary at checkout.
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default CurrencyTooltip;
|
||||
57
components/common/Price.jsx
Normal file
57
components/common/Price.jsx
Normal file
@@ -0,0 +1,57 @@
|
||||
"use client";
|
||||
import React from 'react';
|
||||
import { useCurrency } from '@/app/contexts/currencyContext';
|
||||
|
||||
const Price = ({ amount, className = "" }) => {
|
||||
const { selectedCurrency, exchangeRates, isLoading, error, SUPPORTED_CURRENCIES } = useCurrency();
|
||||
|
||||
const convertPrice = (priceInINR) => {
|
||||
if (!priceInINR || isNaN(priceInINR)) return 0;
|
||||
|
||||
if (selectedCurrency === 'INR') return priceInINR;
|
||||
|
||||
if (!exchangeRates || isLoading) {
|
||||
return priceInINR;
|
||||
}
|
||||
|
||||
const rate = exchangeRates[selectedCurrency];
|
||||
|
||||
if (rate) {
|
||||
const convertedPrice = priceInINR * rate;
|
||||
return convertedPrice.toFixed(2);
|
||||
}
|
||||
|
||||
return priceInINR;
|
||||
};
|
||||
|
||||
const formatPrice = (price) => {
|
||||
const symbol = SUPPORTED_CURRENCIES[selectedCurrency]?.symbol || '₹';
|
||||
const convertedPrice = convertPrice(price);
|
||||
|
||||
if (error && selectedCurrency !== 'INR') {
|
||||
return `${symbol} ${convertedPrice} (approx)`;
|
||||
}
|
||||
|
||||
switch (selectedCurrency) {
|
||||
case 'MYR':
|
||||
return `${symbol} ${convertedPrice}`;
|
||||
case 'NPR':
|
||||
return `${symbol} ${convertedPrice}`;
|
||||
case 'INR':
|
||||
default:
|
||||
return `${symbol} ${price}`;
|
||||
}
|
||||
};
|
||||
|
||||
if (isLoading && selectedCurrency !== 'INR') {
|
||||
return <span className={className}>Loading price...</span>;
|
||||
}
|
||||
|
||||
return (
|
||||
<span className={className}>
|
||||
{formatPrice(amount)}
|
||||
</span>
|
||||
);
|
||||
};
|
||||
|
||||
export default Price;
|
||||
Reference in New Issue
Block a user