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:
@@ -43,7 +43,7 @@ export function GET() {
|
||||
<p>We may occasionally update this Privacy Policy, and we encourage you to periodically review it to stay informed about how we are protecting your information. We will post any changes on this page, and if the changes are significant, we will provide a more prominent notice.</p>
|
||||
|
||||
<h2>How To Contact Us</h2>
|
||||
<p>If you have any questions or comments about this Privacy Policy, or if you would like us to update information we have about you or your preferences, please contact us by email at <a href="mailto:contact@nepalirudraksha.com">contact@nepalirudraksha.com</a>.</p>
|
||||
<p>If you have any questions or comments about this Privacy Policy, or if you would like us to update information we have about you or your preferences, please contact us by email at <a href="mailto:nepali.rudrakshabeads@gmail.com">nepali.rudrakshabeads@gmail.com</a>.</p>
|
||||
|
||||
<p>Your privacy is of utmost importance to us. We commit to safeguarding your personal information in accordance with legal obligations. By using our app, you are accepting the practices outlined in this Privacy Policy. If you do not agree to the terms of this Privacy Policy, please refrain from using our app.</p>
|
||||
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
"use client";
|
||||
import React, { createContext, useContext, useState, useEffect } from "react";
|
||||
import axios from 'axios';
|
||||
|
||||
|
||||
const CurrencyContext = createContext();
|
||||
|
||||
@@ -15,6 +17,7 @@ export const CurrencyProvider = ({ children }) => {
|
||||
const [isLoading, setIsLoading] = useState(true);
|
||||
const [error, setError] = useState(null);
|
||||
|
||||
|
||||
const fetchExchangeRates = async () => {
|
||||
try {
|
||||
setIsLoading(true);
|
||||
@@ -23,60 +26,74 @@ export const CurrencyProvider = ({ children }) => {
|
||||
const cachedData = localStorage.getItem("exchangeRates");
|
||||
const cached = cachedData ? JSON.parse(cachedData) : null;
|
||||
|
||||
if (
|
||||
cached &&
|
||||
new Date().getTime() - cached.timestamp < 24 * 60 * 60 * 1000
|
||||
) {
|
||||
if (cached && new Date().getTime() - cached.timestamp < 24 * 60 * 60 * 1000) {
|
||||
setExchangeRates(cached.rates);
|
||||
setIsLoading(false);
|
||||
return;
|
||||
}
|
||||
|
||||
const currencies = Object.keys(SUPPORTED_CURRENCIES)
|
||||
.filter((key) => key !== "INR")
|
||||
.join(",");
|
||||
try {
|
||||
const currencies = Object.keys(SUPPORTED_CURRENCIES)
|
||||
.filter((key) => key !== "INR")
|
||||
.join(",");
|
||||
|
||||
const response = await fetch(
|
||||
`https://apilayer.net/api/live?access_key=9bcb30907dee1cda9866f7b49f0f8def¤cies=${currencies}&source=INR&format=1`
|
||||
);
|
||||
const response = await axios.get("https://apilayer.net/api/live", {
|
||||
params: {
|
||||
access_key: "9bcb30907dee1cda9866f7b49f0f8def",
|
||||
currencies: currencies,
|
||||
source: "INR",
|
||||
format: 1,
|
||||
},
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error("Failed to fetch exchange rates");
|
||||
const data = response.data;
|
||||
|
||||
if (!data.success) {
|
||||
throw new Error(data.error?.info || "API request failed");
|
||||
}
|
||||
|
||||
const rates = Object.keys(SUPPORTED_CURRENCIES).reduce(
|
||||
(acc, currency) => {
|
||||
if (currency === "INR") {
|
||||
acc[currency] = 1;
|
||||
} else {
|
||||
const rate = data.quotes?.[`INR${currency}`];
|
||||
if (!rate) {
|
||||
throw new Error(`Rate not found for ${currency}`);
|
||||
}
|
||||
acc[currency] = rate;
|
||||
}
|
||||
return acc;
|
||||
},
|
||||
{}
|
||||
);
|
||||
|
||||
localStorage.setItem(
|
||||
"exchangeRates",
|
||||
JSON.stringify({ rates, timestamp: new Date().getTime() })
|
||||
);
|
||||
|
||||
setExchangeRates(rates);
|
||||
} catch (error) {
|
||||
console.error("Error fetching exchange rates:", error);
|
||||
|
||||
setError("Failed to load currency conversion rates. Please try again later.");
|
||||
|
||||
if (cached) {
|
||||
console.log("Using older cached rates as fallback");
|
||||
setExchangeRates(cached.rates);
|
||||
} else {
|
||||
setExchangeRates(null);
|
||||
}
|
||||
}
|
||||
|
||||
const data = await response.json();
|
||||
if (!data.success) {
|
||||
throw new Error(data.error?.info || "API request failed");
|
||||
}
|
||||
|
||||
const rates = Object.keys(SUPPORTED_CURRENCIES).reduce(
|
||||
(acc, currency) => {
|
||||
if (currency === "INR") {
|
||||
acc[currency] = 1;
|
||||
} else {
|
||||
const rate = data.quotes?.[`INR${currency}`];
|
||||
acc[currency] = rate || null;
|
||||
}
|
||||
return acc;
|
||||
},
|
||||
{}
|
||||
);
|
||||
|
||||
const ratesData = {
|
||||
rates,
|
||||
timestamp: data.timestamp * 1000,
|
||||
};
|
||||
|
||||
localStorage.setItem("exchangeRates", JSON.stringify(ratesData));
|
||||
setExchangeRates(rates);
|
||||
} catch (err) {
|
||||
setError("Error fetching exchange rates");
|
||||
console.error("Exchange rate fetch error:", err);
|
||||
} finally {
|
||||
setIsLoading(false);
|
||||
} catch (error) {
|
||||
console.error("Error in exchange rate handling:", error);
|
||||
setError("Failed to load currency conversion rates");
|
||||
setIsLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
const convertPrice = (price) => {
|
||||
if (!price || typeof price !== "number") return price;
|
||||
if (!exchangeRates || !exchangeRates[selectedCurrency]) return price;
|
||||
|
||||
Reference in New Issue
Block a user