diff --git a/src/app/home/components/Carousel.tsx b/src/app/home/components/Carousel.tsx index 7b92cb0..f3f42e4 100644 --- a/src/app/home/components/Carousel.tsx +++ b/src/app/home/components/Carousel.tsx @@ -1,7 +1,8 @@ 'use client' -import { FC, useState, useEffect } from 'react' -import { Swiper, SwiperSlide } from 'swiper/react'; +import { FC, useState, useEffect, useRef } from 'react' +import { Swiper, SwiperSlide, SwiperRef } from 'swiper/react'; import { Pagination } from 'swiper/modules'; +import { ArrowLeft2, ArrowRight2 } from 'iconsax-react'; import Image from 'next/image'; import Link from 'next/link'; import { useGetLanding } from '../hooks/useHomeData'; @@ -9,6 +10,9 @@ import { useGetLanding } from '../hooks/useHomeData'; const Carousel: FC = () => { const { data } = useGetLanding() const [isMobile, setIsMobile] = useState(false) + const swiperRef = useRef(null) + const [isBeginning, setIsBeginning] = useState(true) + const [isEnd, setIsEnd] = useState(false) useEffect(() => { const checkIsMobile = () => { @@ -30,7 +34,21 @@ const Carousel: FC = () => { return (
- + { + setIsBeginning(swiper.isBeginning) + setIsEnd(swiper.isEnd) + }} + onSwiper={(swiper) => { + setIsBeginning(swiper.isBeginning) + setIsEnd(swiper.isEnd) + }} + > {sliders.map((slider) => ( {slider.linkUrl ? ( @@ -55,6 +73,28 @@ const Carousel: FC = () => { ))} + + {/* Navigation buttons */} + +
) } diff --git a/src/app/profile/orders/page.tsx b/src/app/profile/orders/page.tsx index 2aebc23..82341db 100644 --- a/src/app/profile/orders/page.tsx +++ b/src/app/profile/orders/page.tsx @@ -1,7 +1,7 @@ 'use client' import Layout from '@/hoc/Layout' import { NextPage } from 'next' -import React, { useState, useMemo } from 'react' +import React, { useState } from 'react' import Menu from '../components/Menu' import { useGetOrders, useGetReturnOrder } from './hooks/useOrdersData' import { Order, ReturnOrder } from './types/Types' @@ -16,25 +16,6 @@ const Orders: NextPage = () => { const { data: ordersData } = useGetOrders(activeTab); const { data: returnOrderData } = useGetReturnOrder(); - // محاسبه تعداد سفارشات در هر تب از داده‌های اصلی - const tabCounts = useMemo(() => { - if (!ordersData?.results?.orders) return { current: 0, delivered: 0, returned: 0, cancelled: 0 }; - - return ordersData.results.orders.reduce((acc, order: Order) => { - const status = (order.status || 'pending').toLowerCase(); - if (['pending', 'processing', 'shipped'].includes(status)) { - acc.current++; - } else if (status === 'delivered') { - acc.delivered++; - } else if (status === 'returned') { - acc.returned++; - } else if (status === 'cancelled') { - acc.cancelled++; - } - return acc; - }, { current: 0, delivered: 0, returned: 0, cancelled: 0 }); - }, [ordersData]); - // تابع تبدیل وضعیت به فارسی const getStatusText = (status: string) => { const statusMap: { [key: string]: string } = { @@ -48,6 +29,9 @@ const Orders: NextPage = () => { return statusMap[status.toLowerCase()] || status; }; + console.log('ordersData', ordersData); + + return (
@@ -57,7 +41,12 @@ const Orders: NextPage = () => { {/* Orders List */} diff --git a/src/app/profile/orders/types/Types.ts b/src/app/profile/orders/types/Types.ts index 2ef182d..ca68de6 100644 --- a/src/app/profile/orders/types/Types.ts +++ b/src/app/profile/orders/types/Types.ts @@ -289,15 +289,20 @@ export interface OrderDetailResponse { }; } +export interface UserOrderCount { + processing: number; + delivered: number; + cancelled: number; + returned: number; +} + export interface OrdersResponse { status: number; success: boolean; results: { mappedOrders: MappedOrder[]; orders: Order[]; - shipmentAddress: ShipmentAddress; - orderStatus: string; - createdAt: string; + userOrderCount: UserOrderCount; }; } diff --git a/src/components/ManageData.tsx b/src/components/ManageData.tsx index aca925e..8080bcc 100644 --- a/src/components/ManageData.tsx +++ b/src/components/ManageData.tsx @@ -2,16 +2,24 @@ import { useProductStore } from "@/app/product/store/Store"; import { usePathname } from "next/navigation"; -import { useEffect } from "react"; +import { useEffect, useRef } from "react"; const ManageData = () => { const { setVariantId } = useProductStore() const pathname = usePathname() + const prevPathnameRef = useRef(pathname) useEffect(() => { - setVariantId('') - }, [pathname]); + const prevPath = prevPathnameRef.current + const isLeavingProduct = prevPath?.startsWith('/product/') && !pathname.startsWith('/product/') + + if (isLeavingProduct) { + setVariantId('') + } + + prevPathnameRef.current = pathname + }, [pathname, setVariantId]); return null } diff --git a/src/config/const.ts b/src/config/const.ts index e5f82ca..6e123ff 100644 --- a/src/config/const.ts +++ b/src/config/const.ts @@ -1,6 +1,6 @@ export const TOKEN_NAME = "sh_token"; export const REFRESH_TOKEN_NAME = "sh_refresh_token"; -export const BASE_URL = "https://shop-api.dev.danakcorp.com"; +export const BASE_URL = "https://api.fajrtabloshop.com"; // export const BASE_URL = "http://192.168.1.111:4000"; export const PRIMARY_COLOR = "#DA2129";