diff --git a/package-lock.json b/package-lock.json index 0ed4be4..afe2028 100644 --- a/package-lock.json +++ b/package-lock.json @@ -20,6 +20,7 @@ "@types/react-dom": "18.2.4", "axios": "^1.7.5", "client-only": "^0.0.1", + "cookie": "^1.0.2", "eslint": "8.41.0", "eslint-config-next": "^13.4.3", "framer-motion": "^10.12.16", @@ -1359,6 +1360,14 @@ "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==", "license": "MIT" }, + "node_modules/cookie": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-1.0.2.tgz", + "integrity": "sha512-9Kr/j4O16ISv8zBBhJoi4bXOYNTkFLOqSL3UDB0njXxCXNezjeyVrJyGOWtgfs/q2km1gwBcfH8q1yEGoMYunA==", + "engines": { + "node": ">=18" + } + }, "node_modules/copy-to-clipboard": { "version": "3.3.3", "resolved": "https://registry.npmjs.org/copy-to-clipboard/-/copy-to-clipboard-3.3.3.tgz", diff --git a/package.json b/package.json index 8825d58..d84ca34 100644 --- a/package.json +++ b/package.json @@ -27,6 +27,7 @@ "@types/react-dom": "18.2.4", "axios": "^1.7.5", "client-only": "^0.0.1", + "cookie": "^1.0.2", "eslint": "8.41.0", "eslint-config-next": "^13.4.3", "framer-motion": "^10.12.16", diff --git a/public/locales/ar/common.json b/public/locales/ar/common.json index 14bbc7d..947e97c 100644 --- a/public/locales/ar/common.json +++ b/public/locales/ar/common.json @@ -227,5 +227,7 @@ "$": "$", "apply": "تطبيق", "moreFilters": "المزيد من الفلاتر", - "clear": "مسح" + "clear": "مسح", + "tags" : "وسوم" + } diff --git a/public/locales/ar/navigation.json b/public/locales/ar/navigation.json index ff5cf7c..bc8527c 100644 --- a/public/locales/ar/navigation.json +++ b/public/locales/ar/navigation.json @@ -11,9 +11,11 @@ "navAccount": "الحساب", "navMyTrips": "رحلاتي", "navPassengersList": "قائمة الركاب", - "navBills": "الفواتير", + "navBills": "الفوترة", "discover-articles": "اكتشف أبرز المقالات حول جميع مواضيع الحياة. اكتب قصصك وشاركها", "custom-trip": "رحلة مخصصة", "Where to?": "إلى أين؟", - "Anywhere • Any week • Add guests": "في أي مكان • أي أسبوع • أضف الضيوف" + "Anywhere • Any week • Add guests": "في أي مكان • أي أسبوع • أضف الضيوف", + "text-select-language" : " اختر لغتك" + } diff --git a/public/locales/en/common.json b/public/locales/en/common.json index 3b1731f..1d9194c 100644 --- a/public/locales/en/common.json +++ b/public/locales/en/common.json @@ -228,5 +228,6 @@ "$": "$", "apply" : "Apply", "moreFilters": "More Filters", - "clear" : "Clear" + "clear" : "Clear", + "tags" : "Tags" } diff --git a/public/locales/en/navigation.json b/public/locales/en/navigation.json index a26acb4..35fb880 100644 --- a/public/locales/en/navigation.json +++ b/public/locales/en/navigation.json @@ -11,9 +11,11 @@ "navAccount": "Account", "navMyTrips": "My Trips", "navPassengersList": "Passengers List", - "navBills": "Bills", + "navBills": "Billing", "discover-articles": "Discover the most outstanding articles on all topics of life. Write your stories and share them", "custom-trip": "Custom Trip", "Where to?": "Where to?", - "Anywhere • Any week • Add guests": "Anywhere • Any week • Add guests" + "Anywhere • Any week • Add guests": "Anywhere • Any week • Add guests", + "text-select-language" : "Select your language" + } diff --git a/public/locales/id/common.json b/public/locales/id/common.json index 9699b2e..552094e 100644 --- a/public/locales/id/common.json +++ b/public/locales/id/common.json @@ -227,5 +227,7 @@ "$": "$", "apply": "Terapkan", "moreFilters": "Lebih Banyak Filter", - "clear": "Bersihkan" + "clear": "Bersihkan", + "tags" : "Tag" + } diff --git a/public/locales/id/navigation.json b/public/locales/id/navigation.json index 3ec7ef9..6872ede 100644 --- a/public/locales/id/navigation.json +++ b/public/locales/id/navigation.json @@ -11,9 +11,11 @@ "navAccount": "Akun", "navMyTrips": "Perjalanan Saya", "navPassengersList": "Daftar Penumpang", - "navBills": "Tagihan", + "navBills": "Penagihan", "discover-articles": "Temukan artikel paling menonjol tentang semua topik kehidupan. Tulis cerita Anda dan bagikan", "custom-trip": "Perjalanan Khusus", "Where to?": "Kemana?", - "Anywhere • Any week • Add guests": "Dimana saja • Minggu apa saja • Tambahkan tamu" + "Anywhere • Any week • Add guests": "Dimana saja • Minggu apa saja • Tambahkan tamu", + "text-select-language" : "Pilih bahasa Anda" + } diff --git a/public/locales/ru/common.json b/public/locales/ru/common.json index 0765a84..b5b0d01 100644 --- a/public/locales/ru/common.json +++ b/public/locales/ru/common.json @@ -227,5 +227,6 @@ "$": "$", "apply": "Применить", "moreFilters": "Больше фильтров", - "clear": "Очистить" + "clear": "Очистить", + "tags" : "Теги" } diff --git a/public/locales/ru/navigation.json b/public/locales/ru/navigation.json index c289778..f13bbd0 100644 --- a/public/locales/ru/navigation.json +++ b/public/locales/ru/navigation.json @@ -11,10 +11,12 @@ "navAccount": "Аккаунт", "navMyTrips": "Мои поездки", "navPassengersList": "Список пассажиров", - "navBills": "Счета", + "navBills": "Биллинг", "uploadPassword": "Загрузите изображение паспорта здесь", "discover-articles": "Откройте для себя самые выдающиеся статьи на все темы жизни. Пишите свои истории и делитесь ими", "custom-trip": "Индивидуальная поездка", "Where to?": "Куда?", - "Anywhere • Any week • Add guests": "В любом месте • Любая неделя • Добавить гостей" + "Anywhere • Any week • Add guests": "В любом месте • Любая неделя • Добавить гостей", + "text-select-language" : "Выберите ваш язык" + } diff --git a/src/app/[locale]/(account-pages)/bills/[slug]/page.tsx b/src/app/[locale]/(account-pages)/bills/[slug]/page.tsx index c69d6c4..c21666e 100644 --- a/src/app/[locale]/(account-pages)/bills/[slug]/page.tsx +++ b/src/app/[locale]/(account-pages)/bills/[slug]/page.tsx @@ -13,13 +13,34 @@ import { useTranslation } from "react-i18next"; import { BiCloudUpload } from "react-icons/bi"; import { HiOutlineTrash } from "react-icons/hi"; import { useRouter } from "next/router"; +import { useParams } from "next/navigation"; +// Define separate interfaces for different service types export type BillStatus = | "awaiting_payment" | "approved" | "rejected" | "pending"; +export interface PassengerData { + adults: { count: number; names: string[] }; + children: { count: number; names: string[] }; + infants: { count: number; names: string[] }; +} + +export interface TourDetailService { + tour_id: number; + tour: string; + tour_slug: string; + passenger_data: PassengerData; +} + +export interface CustomTripDetail { + total_price: number; + detail: string; // JSON string + destinations: string[]; +} + export interface Bill { id: number; title: string; @@ -27,7 +48,7 @@ export interface Bill { expiration_date: string; amount: number; status: BillStatus; - passengers: { type: string; count: number }[]; + passengers?: { type: string; count: number }[]; // Optional since custom_trip doesn't use this accountNumber: string; message?: string; uploadedImage?: { @@ -35,19 +56,17 @@ export interface Bill { size: string; src: string; }; - detail_service: { - passenger_data: { - adults: { count: number; names: string[] }; - children: { count: number; names: string[] }; - infants: { count: number; names: string[] }; - }; - }; + detail_service: TourDetailService | CustomTripDetail; transaction_receipt: string | null; card_number: string | number; + service: "tour" | "custom_trip"; // Added service field + description?: string; + rejected_description?: string; + object_id?: number; } interface BillDetailCardProps { - billId: number; + id: number; } const formatDate = (dateString: string): string => { @@ -59,13 +78,19 @@ const formatDate = (dateString: string): string => { }); }; -const BillDetailCard: React.FC = ({ billId }) => { +const BillDetailCard: React.FC = ({ id }) => { const [bill, setBill] = useState(null); const [uploadedFile, setUploadedFile] = useState(null); const [loadingUpload, setLoadingUpload] = useState(false); const [loading, setLoading] = useState(false); const { user } = useUserContext(); const { t } = useTranslation("form"); + const params = useParams(); + const slug = params?.slug; + + const billId = slug || id; + + console.log(billId, slug, id); const statusStyles: { [key in BillStatus]: JSX.Element } = { awaiting_payment: ( @@ -89,18 +114,31 @@ const BillDetailCard: React.FC = ({ billId }) => { ), }; + const handleFileChange = async (e: React.ChangeEvent) => { setLoadingUpload(true); const file = e.target.files?.[0]; if (file) { - const uploadedFile = await getImageURL(file); - setUploadedFile(uploadedFile.url); + try { + const uploadedFile = await getImageURL(file); + setUploadedFile(uploadedFile.url); + } catch (error) { + console.error("Error uploading file:", error); + toast.error(t("uploadFailed")); + } finally { + setLoadingUpload(false); + } + } else { setLoadingUpload(false); } }; + const getBillData = async () => { + if (!(Object.keys(user).length)) { + return; + } try { - const response = await axiosInstance(`/api/factors/${billId}/`, { + const response = await axiosInstance.get(`/api/factors/${billId}/`, { headers: { Authorization: `token ${user.token}`, }, @@ -114,7 +152,8 @@ const BillDetailCard: React.FC = ({ billId }) => { useEffect(() => { getBillData(); - }, [billId]); + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [billId, user]); const handleSubmit = () => { setLoading(true); @@ -135,6 +174,7 @@ const BillDetailCard: React.FC = ({ billId }) => { toast.success(t("transactionReceiptUpdated")); setLoading(false); setUploadedFile(null); + getBillData(); // Refresh bill data }) .catch((error) => { console.error(error); @@ -142,7 +182,8 @@ const BillDetailCard: React.FC = ({ billId }) => { setLoading(false); }); } else { - console.log(t("noFileSelected")); + toast.warn(t("noFileSelected")); + setLoading(false); } }; @@ -164,6 +205,7 @@ const BillDetailCard: React.FC = ({ billId }) => { ) .then(() => { toast.success(t("transactionReceiptDeleted")); + getBillData(); // Refresh bill data }) .catch((error) => { console.error(error); @@ -171,7 +213,7 @@ const BillDetailCard: React.FC = ({ billId }) => { }) .finally(() => { setLoading(false); - useRouter().reload(); + // useRouter().reload(); // Prefer refreshing bill data instead of full reload }); } }; @@ -180,6 +222,77 @@ const BillDetailCard: React.FC = ({ billId }) => { return

{t("loadingBillData")}

; } + // Function to parse custom trip details + const parseCustomTripDetails = (detail: string) => { + try { + const parsedDetail = JSON.parse(detail); + const beginTrip = parsedDetail["1"]; + const destinations = bill.detail_service.destinations; + return { beginTrip, destinations }; + } catch (error) { + console.error("Error parsing custom trip details:", error); + return { beginTrip: null, destinations: [] }; + } + }; + + const renderPassengerData = () => { + if (bill.service !== "tour") return null; + const detailService = bill.detail_service as TourDetailService; + const passengerData = detailService.passenger_data; + return ( +
+

{t("numberOfPassengers")}

+
+ {passengerData.adults.count > 0 && ( + + {passengerData.adults.names.join(", ")} ({t("adult")}) + + )} +
+
+ {passengerData.children.count > 0 && ( + + {passengerData.children.names.join(", ")} ({t("child")}) + + )} +
+
+ {passengerData.infants.count > 0 && ( + + {passengerData.infants.names.join(", ")} ({t("infant")}) + + )} +
+
+ ); + }; + + const renderCustomTripDetails = () => { + if (bill.service !== "custom_trip") return null; + const detailService = bill.detail_service as CustomTripDetail; + const { beginTrip, destinations } = parseCustomTripDetails(detailService.detail); + return ( +
+ {beginTrip && ( +
+

{t("beginTripCity")}:

+ {beginTrip.city} +
+ )} + {destinations && destinations.length > 0 && ( +
+

{t("destinations")}:

+
    + {destinations.map((destination, index) => ( +
  • {destination}
  • + ))} +
+
+ )} +
+ ); + }; + return (
@@ -206,33 +319,9 @@ const BillDetailCard: React.FC = ({ billId }) => { {formatDate(bill.expiration_date)}
-
-

{t("numberOfPassengers")}

-
- {!!bill.detail_service.passenger_data.adults.count && ( - - {bill.detail_service.passenger_data.adults.names.join(", ")} ( - {t("adult")}) - - )} -
-
- {!!bill.detail_service.passenger_data.children.count && ( - - {bill.detail_service.passenger_data.children.names.join(", ")} ( - {t("child")}) - - )} -
-
- {!!bill.detail_service.passenger_data.infants.count && ( - - {bill.detail_service.passenger_data.infants.names.join(", ")} ( - {t("infant")}) - - )} -
-
+ {/* Conditional Rendering Based on Service Type */} + {renderPassengerData()} + {renderCustomTripDetails()}
{t("tourPrice")}: @@ -245,7 +334,15 @@ const BillDetailCard: React.FC = ({ billId }) => { {bill.card_number} - +
@@ -293,17 +390,18 @@ const BillDetailCard: React.FC = ({ billId }) => { width={200} height={200} src={ - !!uploadedFile + uploadedFile ? uploadedFile : bill.transaction_receipt || "" } alt={t("currentReceipt")} + className="object-contain" /> ) : (
-

{t("uploadPassword")}

+

{t("uploadPassport")}

)} diff --git a/src/app/[locale]/(account-pages)/bills/page.tsx b/src/app/[locale]/(account-pages)/bills/page.tsx index cdd3f37..ca3eba3 100644 --- a/src/app/[locale]/(account-pages)/bills/page.tsx +++ b/src/app/[locale]/(account-pages)/bills/page.tsx @@ -83,11 +83,11 @@ const BillsPage: React.FC = () => { - + ) : bills.length > 0 ? ( bills.map((bill, index) => ( - + (bill.service === "custom_trip" || bill.service === "tour") && )) ) : (
diff --git a/src/app/[locale]/(account-pages)/my-trips/page.tsx b/src/app/[locale]/(account-pages)/my-trips/page.tsx index 1eaf64c..04144f9 100644 --- a/src/app/[locale]/(account-pages)/my-trips/page.tsx +++ b/src/app/[locale]/(account-pages)/my-trips/page.tsx @@ -8,6 +8,7 @@ import { useRouter } from "next/navigation"; import { useUserContext } from "@/components/contexts/userContext"; import { useTranslation } from "react-i18next"; import { StayDataType } from "@/data/types"; +import getLocalizedRoute from "@/utils/routes"; const MyTrips = () => { const router = useRouter(); @@ -17,7 +18,7 @@ const MyTrips = () => { useEffect(() => { if (!Object.keys(user).length) { - router.replace("/signup"); + router.replace(getLocalizedRoute("/signup")); } }, [user, router]); diff --git a/src/app/[locale]/(account-pages)/passengers-list/PassengerTable.tsx b/src/app/[locale]/(account-pages)/passengers-list/PassengerTable.tsx index 0fd9e57..6aad356 100644 --- a/src/app/[locale]/(account-pages)/passengers-list/PassengerTable.tsx +++ b/src/app/[locale]/(account-pages)/passengers-list/PassengerTable.tsx @@ -7,6 +7,7 @@ import { useRouter } from "next/navigation"; import { IoMdTrash } from "react-icons/io"; import { MdEdit } from "react-icons/md"; import { useTranslation } from "react-i18next"; +import getLocalizedRoute from "@/utils/routes"; interface Passenger { birthdate: string; @@ -66,7 +67,7 @@ const PassengerTable: FC = ({ data }) => { ))} diff --git a/src/app/[locale]/(client-components)/(HeroSearchForm)/GuestsInput.tsx b/src/app/[locale]/(client-components)/(HeroSearchForm)/GuestsInput.tsx index 7b574e3..5c123af 100644 --- a/src/app/[locale]/(client-components)/(HeroSearchForm)/GuestsInput.tsx +++ b/src/app/[locale]/(client-components)/(HeroSearchForm)/GuestsInput.tsx @@ -11,6 +11,7 @@ import { UserPlusIcon } from "@heroicons/react/24/outline"; import { GuestsObject } from "../type"; import { Context, useToursContext } from "@/components/contexts/tourDetails"; import { useTranslation } from "react-i18next"; +import getLocalizedRoute from "@/utils/routes"; export interface GuestsInputProps { fieldClassName?: string; @@ -93,7 +94,7 @@ const GuestsInput: FC = ({
)} diff --git a/src/app/[locale]/(client-components)/(HeroSearchForm2Mobile)/LocationInput.tsx b/src/app/[locale]/(client-components)/(HeroSearchForm2Mobile)/LocationInput.tsx index 278f63d..22b4676 100644 --- a/src/app/[locale]/(client-components)/(HeroSearchForm2Mobile)/LocationInput.tsx +++ b/src/app/[locale]/(client-components)/(HeroSearchForm2Mobile)/LocationInput.tsx @@ -1,6 +1,7 @@ "use client"; import { useToursContext } from "@/components/contexts/tourDetails"; +import getLocalizedRoute from "@/utils/routes"; import { MapPinIcon, MagnifyingGlassIcon } from "@heroicons/react/24/outline"; import { useRouter } from "next/navigation"; import React, { useState, useEffect, useRef, FC } from "react"; @@ -55,7 +56,7 @@ const LocationInput: FC = ({ return (
router.push(`/tours/${item?.slug}-${item?.id}`)} + onClick={() => router.push(getLocalizedRoute(`/tours/${item?.slug}-${item?.id}`))} key={item.id} > diff --git a/src/app/[locale]/(server-components)/SectionHero.tsx b/src/app/[locale]/(server-components)/SectionHero.tsx index 1f4e775..4b7277a 100644 --- a/src/app/[locale]/(server-components)/SectionHero.tsx +++ b/src/app/[locale]/(server-components)/SectionHero.tsx @@ -7,6 +7,7 @@ import HeroSearchForm from "../(client-components)/(HeroSearchForm)/HeroSearchFo import Image from "next/image"; import ButtonPrimary from "@/shared/ButtonPrimary"; import { useTranslation } from "react-i18next"; // Import useTranslation +import getLocalizedRoute from "@/utils/routes"; export interface SectionHeroProps { className?: string; @@ -43,7 +44,7 @@ const SectionHero: FC = ({ className = "" }) => { {t("planPilgrimage")} - + {t("startJourney")}
diff --git a/src/app/[locale]/about/SectionHero.tsx b/src/app/[locale]/about/SectionHero.tsx index 869a043..49b8aa7 100644 --- a/src/app/[locale]/about/SectionHero.tsx +++ b/src/app/[locale]/about/SectionHero.tsx @@ -1,6 +1,7 @@ import Image, { StaticImageData } from "next/image"; import React, { FC, ReactNode } from "react"; import ButtonPrimary from "@/shared/ButtonPrimary"; +import getLocalizedRoute from "@/utils/routes"; export interface SectionHeroProps { className?: string; @@ -27,10 +28,10 @@ const SectionHero: FC = ({ {subHeading} - {!!btnText && {btnText}} + {!!btnText && {btnText}}
- +
diff --git a/src/app/[locale]/about/page.tsx b/src/app/[locale]/about/page.tsx index a3b5076..6fc32ed 100644 --- a/src/app/[locale]/about/page.tsx +++ b/src/app/[locale]/about/page.tsx @@ -1,5 +1,5 @@ "use client" -import rightImg from "@/images/about-hero-right.png"; +import rightImg from "@/images/about-hero-right.jpg"; import React, { FC } from "react"; import SectionFounder from "./SectionFounder"; import SectionStatistic from "./SectionStatistic"; @@ -34,7 +34,7 @@ const PageAbout: FC = () => { - + {/* */} {/* */} diff --git a/src/app/[locale]/add-listing/[[...stepIndex]]/PageAddListing1.tsx b/src/app/[locale]/add-listing/[[...stepIndex]]/PageAddListing1.tsx index 431fd18..a1c65b8 100644 --- a/src/app/[locale]/add-listing/[[...stepIndex]]/PageAddListing1.tsx +++ b/src/app/[locale]/add-listing/[[...stepIndex]]/PageAddListing1.tsx @@ -8,6 +8,7 @@ import ConfirmModal from "@/shared/popUp"; import axiosInstance from "@/components/api/axios"; import { useUserContext } from "@/components/contexts/userContext"; import { useRouter } from "next/navigation"; +import getLocalizedRoute from "@/utils/routes"; export interface PageAddListing1Props { ageLabel : string ; @@ -39,7 +40,7 @@ const PageAddListing1: FC = ({ const [passengerAgeLable , setPassengerAgeLAble] = useState(ageLabel) if (!Object.keys(user).length) { - router.replace("/signup"); + router.replace(getLocalizedRoute("/signup")); } useEffect(() => { diff --git a/src/app/[locale]/add-listing/[[...stepIndex]]/PageAddListing10.tsx b/src/app/[locale]/add-listing/[[...stepIndex]]/PageAddListing10.tsx index 0a75d2e..e1164a7 100644 --- a/src/app/[locale]/add-listing/[[...stepIndex]]/PageAddListing10.tsx +++ b/src/app/[locale]/add-listing/[[...stepIndex]]/PageAddListing10.tsx @@ -29,7 +29,7 @@ const PageAddListing10: FC = () => { />
- + Edit diff --git a/src/app/[locale]/add-listing/[[...stepIndex]]/page.tsx b/src/app/[locale]/add-listing/[[...stepIndex]]/page.tsx index cd5ac50..2d19284 100644 --- a/src/app/[locale]/add-listing/[[...stepIndex]]/page.tsx +++ b/src/app/[locale]/add-listing/[[...stepIndex]]/page.tsx @@ -10,6 +10,7 @@ import axiosInstance from "@/components/api/axios"; import { useUserContext } from "@/components/contexts/userContext"; import { toast } from "react-toastify"; import ButtonSecondary from "@/shared/ButtonSecondary"; +import getLocalizedRoute from "@/utils/routes"; export interface CommonLayoutProps { children: React.ReactNode; @@ -95,7 +96,7 @@ const CommonLayout: FC = ({ params }) => { useEffect(() => { if (redirecting) { - router.replace("/my-trips"); + router.replace(getLocalizedRoute("/my-trips")); toast.success("Purchased Successfully "); } }, [redirecting, router]); diff --git a/src/app/[locale]/add-new-passenger/page.tsx b/src/app/[locale]/add-new-passenger/page.tsx index 7009ef9..95760aa 100644 --- a/src/app/[locale]/add-new-passenger/page.tsx +++ b/src/app/[locale]/add-new-passenger/page.tsx @@ -10,6 +10,7 @@ import axiosInstance from "@/components/api/axios"; import { useRouter } from "next/navigation"; import { useUserContext } from "@/components/contexts/userContext"; import { PhoneNumberUtil } from "google-libphonenumber"; +import getLocalizedRoute from "@/utils/routes"; export interface CommonLayoutProps { params: { @@ -132,7 +133,7 @@ const CommonLayout: FC = () => { } ); - router.push("/passengers-list"); + router.push(getLocalizedRoute("/passengers-list")); } catch (error: any) { console.error("Error saving passenger:", error); setErrors((prevErrors) => ({ ...prevErrors, request: error.message })); diff --git a/src/app/[locale]/blog/Card12.tsx b/src/app/[locale]/blog/Card12.tsx index d09df05..b3c1603 100644 --- a/src/app/[locale]/blog/Card12.tsx +++ b/src/app/[locale]/blog/Card12.tsx @@ -6,6 +6,7 @@ import SocialsShare from "@/shared/SocialsShare"; import { DEMO_POSTS } from "@/data/posts"; import Link from "next/link"; import Image from "next/image"; +import getLocalizedRoute from "@/utils/routes"; export interface Card12Props { className?: string; @@ -21,7 +22,7 @@ const Card12: FC = ({ return (
= ({

- + {post?.title}

diff --git a/src/app/[locale]/blog/Card13.tsx b/src/app/[locale]/blog/Card13.tsx index 54d30c1..bb28971 100644 --- a/src/app/[locale]/blog/Card13.tsx +++ b/src/app/[locale]/blog/Card13.tsx @@ -4,6 +4,7 @@ import { PostDataType } from "@/data/types"; import PostTypeFeaturedIcon from "@/components/PostTypeFeaturedIcon"; import Link from "next/link"; import Image from "next/image"; +import getLocalizedRoute from "@/utils/routes"; export interface Card13Props { className?: string; @@ -17,7 +18,7 @@ const Card13: FC = ({ className = "", post }) => {

- + {post?.title}

@@ -33,7 +34,7 @@ const Card13: FC = ({ className = "", post }) => {
- {!checked ? ( - <> -

Was this article helpfull ?

-
-
{ - setChecked(true); - }} - className="cursor-pointer hover:bg-green-200 nc-Tag flex items-center gap-1 bg-white text-sm text-neutral-600 dark:text-neutral-300 py-2 rounded-lg border border-neutral-100 md:px-4 dark:bg-neutral-700 dark:border-neutral-700 hover:border-neutral-200 dark:hover:border-neutral-6000 mr-2 mb-2" - > -

Yes

- -
-
{ - setChecked(true); - }} - className="cursor-pointer hover:bg-red-300 nc-Tag flex items-center gap-1 bg-white text-sm text-neutral-600 dark:text-neutral-300 py-2 rounded-lg border border-neutral-100 md:px-4 dark:bg-neutral-700 dark:border-neutral-700 hover:border-neutral-200 dark:hover:border-neutral-6000 mr-2 mb-2" - > -

No

- -
-
- - ) : ( -

Thank you

- )} -
- ); -} - -export default Survey; diff --git a/src/app/[locale]/blog/[...slug]/page.tsx b/src/app/[locale]/blog/[...slug]/page.tsx index 6939db1..6bf4ae2 100644 --- a/src/app/[locale]/blog/[...slug]/page.tsx +++ b/src/app/[locale]/blog/[...slug]/page.tsx @@ -18,6 +18,7 @@ import { BiLike, BiDislike } from "react-icons/bi"; import Survey from "./Survey"; import axiosInstance from "@/components/api/axios"; import { useTranslation } from "react-i18next"; // Import useTranslation +import getLocalizedRoute from "@/utils/routes"; const Page = ({ params, @@ -47,7 +48,7 @@ const Page = ({ return (
- {/* Translate badge name */} + {/* Translate badge name */}

{ return ( -
+
+

+ {t("tags")} : +

+
{blog?.tags.map((item) => ( - {item.name} - +
))}
+
); }; @@ -138,7 +143,7 @@ const Page = ({ key={post.id} className="relative aspect-w-3 aspect-h-4 rounded-3xl overflow-hidden group" > - +

- +
); }; @@ -172,7 +177,7 @@ const Page = ({ {renderContent()} {renderTags()}
- + {/* */} {/* Uncomment to render comments */} {/* {renderCommentForm()} */} {/* {renderCommentLists()} */} @@ -187,6 +192,7 @@ const Page = ({ }) .map((item, i) => i < 4 && renderPostRelated(item))} + {/* */} diff --git a/src/app/[locale]/custom-history/page.tsx b/src/app/[locale]/custom-history/page.tsx index 97fa299..a0259f6 100644 --- a/src/app/[locale]/custom-history/page.tsx +++ b/src/app/[locale]/custom-history/page.tsx @@ -6,6 +6,7 @@ import { TrashIcon } from '@heroicons/react/24/outline'; // Import the Trash ico import { FaWhatsapp } from "react-icons/fa"; import { useUserContext } from '@/components/contexts/userContext'; import { useRouter } from 'next/navigation'; +import getLocalizedRoute from '@/utils/routes'; export interface PageAddListing10Props {} @@ -35,7 +36,7 @@ const PageAddListing10: FC = () => { console.error('Error fetching custom trip orders:', error); }); } else { - router.replace("/signup"); + router.replace(getLocalizedRoute("/signup")); } }, [user, router]); diff --git a/src/app/[locale]/custom-trip/page.tsx b/src/app/[locale]/custom-trip/page.tsx index b73c77e..debda3a 100644 --- a/src/app/[locale]/custom-trip/page.tsx +++ b/src/app/[locale]/custom-trip/page.tsx @@ -11,6 +11,7 @@ import { useUserContext } from "@/components/contexts/userContext"; import { toast } from "react-toastify"; import NcInputNumber from "@/components/NcInputNumber"; import { useTranslation } from "react-i18next"; +import getLocalizedRoute from "@/utils/routes"; interface City { name: string; @@ -304,10 +305,10 @@ const CommonLayout: FC = () => { }, }).then((response) => { console.log(response); + toast.success(t("successMessage")); + router.push(getLocalizedRoute(`/bills/${response.data.factor_id}`)); }) - toast.success(t("successMessage")); - router.push("/custom-history"); } catch (error) { console.error("Error sending trip details:", error); } @@ -359,6 +360,7 @@ const CommonLayout: FC = () => { defaultValue={passengers.adults} onChange={(value) => handleChangeData(value, "adults")} max={20} + min={1} label={t("adults")} desc={t("adultsDesc")} /> diff --git a/src/app/[locale]/faq/Table.tsx b/src/app/[locale]/faq/Table.tsx index 9e3d033..bb95896 100644 --- a/src/app/[locale]/faq/Table.tsx +++ b/src/app/[locale]/faq/Table.tsx @@ -19,7 +19,7 @@ const Table: React.FC = ({ faq, isActive, onClick }) => { className="text-xl font-semibold flex justify-between items-center cursor-pointer" onClick={onClick} > - {faq.question} + {faq.translation} {isActive ? "-" : "+"} { const { t } = useTranslation("FAQ"); // Initialize useTranslation with the "common" namespace + const [faqs , setFaqs] = useState([]) const [activeIndex, setActiveIndex] = useState(null); - const faqs: FAQItem[] = [ - { - question: t("faqQuestion1"), // Translate the question - answer: t("faqAnswer1"), // Translate the answer - }, - { - question: t("faqQuestion2"), - answer: t("faqAnswer2"), - }, - { - question: t("faqQuestion3"), - answer: t("faqAnswer3"), - }, - { - question: t("faqQuestion4"), - answer: t("faqAnswer4"), - }, - { - question: t("faqQuestion5"), - answer: t("faqAnswer5"), - }, - { - question: t("faqQuestion6"), - answer: t("faqAnswer6"), - }, - { - question: t("faqQuestion7"), - answer: t("faqAnswer7"), - }, - { - question: t("faqQuestion8"), - answer: t("faqAnswer8"), - }, - { - question: t("faqQuestion9"), - answer: t("faqAnswer9"), - }, - { - question: t("faqQuestion10"), - answer: t("faqAnswer10"), - }, - ]; + // const faqs: FAQItem[] = [ + // { + // question: t("faqQuestion1"), // Translate the question + // answer: t("faqAnswer1"), // Translate the answer + // }, + // { + // question: t("faqQuestion2"), + // answer: t("faqAnswer2"), + // }, + // { + // question: t("faqQuestion3"), + // answer: t("faqAnswer3"), + // }, + // { + // question: t("faqQuestion4"), + // answer: t("faqAnswer4"), + // }, + // { + // question: t("faqQuestion5"), + // answer: t("faqAnswer5"), + // }, + // { + // question: t("faqQuestion6"), + // answer: t("faqAnswer6"), + // }, + // { + // question: t("faqQuestion7"), + // answer: t("faqAnswer7"), + // }, + // { + // question: t("faqQuestion8"), + // answer: t("faqAnswer8"), + // }, + // { + // question: t("faqQuestion9"), + // answer: t("faqAnswer9"), + // }, + // { + // question: t("faqQuestion10"), + // answer: t("faqAnswer10"), + // }, + // ]; const toggleFAQ = (index: number) => { if (activeIndex === index) { @@ -64,6 +66,14 @@ const FAQ: React.FC = () => { } }; + + useEffect(()=>{ + axiosInstance.get("api/home/faq/").then((res)=>{ + console.log(res); + setFaqs(res.data.results) + + }) + } , []) return (

{t("faqTitle")}

{/* Translate title */} diff --git a/src/app/[locale]/forgot-password/page.tsx b/src/app/[locale]/forgot-password/page.tsx index 01814c5..88fcbb7 100644 --- a/src/app/[locale]/forgot-password/page.tsx +++ b/src/app/[locale]/forgot-password/page.tsx @@ -12,6 +12,7 @@ import "react-toastify/dist/ReactToastify.css"; import { PhoneNumberUtil } from "google-libphonenumber"; // Import libphonenumber import { BiShow, BiHide } from "react-icons/bi"; import { useTranslation } from "react-i18next"; +import getLocalizedRoute from "@/utils/routes"; export interface PageSignUpProps {} @@ -119,7 +120,7 @@ const PageSignUp: FC = () => { }; setForm(formData); - router.push("/signup/methodes"); + router.push(getLocalizedRoute("/signup/methodes")); } catch (error: any) { console.error("Error fetching data:", error); if (error.response?.data?.errors?.length) { @@ -254,7 +255,7 @@ const PageSignUp: FC = () => { {/* Link to Sign In */}

{t("alreadyHaveAccount")}{" "} - + {t("signIn")}

diff --git a/src/app/[locale]/login/page.tsx b/src/app/[locale]/login/page.tsx index 98dc868..9819317 100644 --- a/src/app/[locale]/login/page.tsx +++ b/src/app/[locale]/login/page.tsx @@ -12,6 +12,7 @@ import "react-toastify/dist/ReactToastify.css"; import { PhoneNumberUtil } from "google-libphonenumber"; import { BiShow, BiHide } from "react-icons/bi"; import { useTranslation } from "react-i18next"; +import getLocalizedRoute from "@/utils/routes"; export interface PageLoginProps {} @@ -31,7 +32,7 @@ const PageLogin: FC = () => { // Redirect to home if the user is already logged in useEffect(() => { if (Object.keys(user).length) { - router.replace("/"); + router.replace(getLocalizedRoute("/")); } }, [user, router]); @@ -161,7 +162,7 @@ const PageLogin: FC = () => {