diff --git a/next.config.js b/next.config.js index 5deb430..e9cb40a 100644 --- a/next.config.js +++ b/next.config.js @@ -1,14 +1,14 @@ /** @type {import('next').NextConfig} */ const { i18n } = require("./next-i18next.config"); - - module.exports = { - eslint: { ignoreDuringBuilds: false, }, - + typescript: { + ignoreBuildErrors: true, + }, + images: { remotePatterns: [ { @@ -43,11 +43,9 @@ module.exports = { }, ], }, - }; - -// const nextConfig = { +// const nextConfig = { // reactStrictMode: false, // ignoreBuildErrors: true, // typescript: { @@ -60,5 +58,3 @@ module.exports = { // }; // module.exports = nextConfig; - - diff --git a/src/app/[locale]/(account-pages)/bills/[slug]/page.tsx b/src/app/[locale]/(account-pages)/bills/[slug]/page.tsx index 9f6abf9..b153154 100644 --- a/src/app/[locale]/(account-pages)/bills/[slug]/page.tsx +++ b/src/app/[locale]/(account-pages)/bills/[slug]/page.tsx @@ -1,3 +1,5 @@ +"use client" + import React, { useState } from "react"; import axiosInstance from "@/components/api/axios"; import ButtonPrimary from "@/shared/ButtonPrimary"; diff --git a/src/app/[locale]/custom-trip/page.tsx b/src/app/[locale]/custom-trip/page.tsx index 78ada83..b868afb 100644 --- a/src/app/[locale]/custom-trip/page.tsx +++ b/src/app/[locale]/custom-trip/page.tsx @@ -10,7 +10,7 @@ import { useRouter } from "next/navigation"; import { useUserContext } from "@/components/contexts/userContext"; import { toast } from "react-toastify"; import NcInputNumber from "@/components/NcInputNumber"; -import { useTranslation } from "react-i18next"; // Import useTranslation +import { useTranslation } from "react-i18next"; interface City { name: string; @@ -27,7 +27,7 @@ interface CommonLayoutProps {} const CommonLayout: FC = () => { const { user } = useUserContext(); const router = useRouter(); - const { t } = useTranslation("common"); // Initialize useTranslation with the "common" namespace + const { t } = useTranslation("common"); const [countries, setCountries] = useState([]); const [startCity, setStartCity] = useState(""); @@ -53,7 +53,6 @@ const CommonLayout: FC = () => { const [isFormValid, setIsFormValid] = useState(false); const [isContinueValid, setIsContinueValid] = useState(false); - // Number conversion arrays for display const special = [ "Zeroth", "First", "Second", "Third", "Fourth", "Fifth", "Sixth", "Seventh", "Eighth", "Ninth", "Tenth", "Eleventh", @@ -77,7 +76,8 @@ const CommonLayout: FC = () => { .then((response) => setCountries(response.data.results)) .catch((error) => console.error("Error fetching countries:", error)); }, []); - + console.log(destinations); + useEffect(() => { const lastDestination = destinations[destinations.length - 1]; if (lastDestination?.endCity) { @@ -87,7 +87,8 @@ const CommonLayout: FC = () => { .split("/")[2] .trim()}&to_city=${lastDestination.endCity.split("/")[2].trim()}` ) - .then((response) => setTransport(response.data)) + .then((response) => {setTransport(response.data) ;console.log(response); + }) .catch((error) => console.error("Error fetching transport options:", error) ); @@ -96,7 +97,8 @@ const CommonLayout: FC = () => { .get( `/api/trip/hotels/${lastDestination.endCity.split("/")[2].trim()}/` ) - .then((response) => setHotel(response.data.results)) + .then((response) => {setHotel(response.data.results) ; console.log(response); + }) .catch((error) => console.error("Error fetching hotels:", error)); } }, [destinations, startCity]); @@ -109,6 +111,54 @@ const CommonLayout: FC = () => { validateForm(); }, [startCity, startDate, passengers, destinations]); + const calculateTransportCost = ( + transport: any, + adults: number, + children: number, + infants: number + ) => { + console.log( + transport, + adults, + children, + infants, + transport.price * adults + + transport.price_child * children + + transport.price_infant * infants + ); + + return ( + transport.price * adults + + transport.price_child * children + + transport.price_infant * infants + ); + }; + + const calculateHotelCost = ( + hotel: any, + days: number, + adults: number, + children: number, + infants: number + ) => { + console.log( + hotel, + adults, + children, + infants, + (hotel.price_per_day * adults + + hotel.price_per_day_child * children + + hotel.price_per_day_infant * infants) * days + + ); + + return ( + (hotel.price_per_day * adults + + hotel.price_per_day_child * children + + hotel.price_per_day_infant * infants) * days + ); + }; + const updateEstimatedCost = () => { const totalCost = destinations.reduce((acc, destination) => { const transportCost = destination.transportCost * passengers; @@ -176,12 +226,23 @@ const CommonLayout: FC = () => { const selected = transport.find( (item) => item.transportaion.name === value ); - updatedDestinations[index].transportCost = selected?.price || 0; + updatedDestinations[index].transportCost = calculateTransportCost( + selected, + guestAdultsInputValue, + guestChildrenInputValue, + guestInfantsInputValue + ); } if (field === "hotel") { const selected = hotel.find((item) => item.name === value); - updatedDestinations[index].hotelCost = selected?.price_per_day || 0; + updatedDestinations[index].hotelCost = calculateHotelCost( + selected, + updatedDestinations[index].duration, + guestAdultsInputValue, + guestChildrenInputValue, + guestInfantsInputValue + ); } if (field === "duration") { @@ -228,7 +289,7 @@ const CommonLayout: FC = () => { price_estimate: JSON.stringify(estimatedCost), detail: JSON.stringify({ "1": { - title: t("beginTrip"), // Translate title + title: t("beginTrip"), city: `${startCity.split("/")[0].trim()}-${startCity .split("/")[1] .trim()} `, @@ -238,13 +299,13 @@ const CommonLayout: FC = () => { ...destinations.reduce<{ [key: number]: any }>( (acc, destination, index) => { acc[index + 2] = { - title: `${stringifyNumber(index + 1)} ${t("destination")}`, // Translate destination title + title: `${stringifyNumber(index + 1)} ${t("destination")}`, city: `${destination.endCity .split("/")[0] .trim()}-${destination.endCity.split("/")[1].trim()} `, transportation: destination.transport, hotel: destination.hotel, - duration: `${destination.duration} ${t("days")}`, // Translate days + duration: `${destination.duration} ${t("days")}`, finish_date: destination.finishDate.replace(/-/g, "/"), start_date: startDate.replace(/-/g, "/"), }; @@ -255,8 +316,11 @@ const CommonLayout: FC = () => { summary: { cost_estimate: estimatedCost.toString(), journery_schedule: `${startDate.replace(/-/g, "/")} ${t("to")} ${ - destinations[destinations.length - 1]?.finishDate.replace(/-/g, "/") - } ${t("days")} ${destinations.length}`, // Translate to and days + destinations[destinations.length - 1]?.finishDate.replace( + /-/g, + "/" + ) + } ${t("days")} ${destinations.length}`, }, }), }; @@ -267,7 +331,7 @@ const CommonLayout: FC = () => { "Content-Type": "application/json", }, }); - toast.success(t("successMessage")); // Translate success message + toast.success(t("successMessage")); router.push("/custom-history"); } catch (error) { console.error("Error sending trip details:", error);