diff --git a/package-lock.json b/package-lock.json index c51ab61..56253a7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -30708,6 +30708,126 @@ "resolved": "https://registry.npmjs.org/zone.js/-/zone.js-0.8.29.tgz", "integrity": "sha512-mla2acNCMkWXBD+c+yeUrBUrzOxYMNFdQ6FGfigGGtEVBPJx07BQeJekjt9DmH1FtZek4E9rE1eRR9qQpxACOQ==", "peer": true + }, + "node_modules/@next/swc-darwin-arm64": { + "version": "14.2.3", + "resolved": "https://registry.npmjs.org/@next/swc-darwin-arm64/-/swc-darwin-arm64-14.2.3.tgz", + "integrity": "sha512-3pEYo/RaGqPP0YzwnlmPN2puaF2WMLM3apt5jLW2fFdXD9+pqcoTzRk+iZsf8ta7+quAe4Q6Ms0nR0SFGFdS1A==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@next/swc-darwin-x64": { + "version": "14.2.3", + "resolved": "https://registry.npmjs.org/@next/swc-darwin-x64/-/swc-darwin-x64-14.2.3.tgz", + "integrity": "sha512-6adp7waE6P1TYFSXpY366xwsOnEXM+y1kgRpjSRVI2CBDOcbRjsJ67Z6EgKIqWIue52d2q/Mx8g9MszARj8IEA==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@next/swc-linux-arm64-gnu": { + "version": "14.2.3", + "resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-gnu/-/swc-linux-arm64-gnu-14.2.3.tgz", + "integrity": "sha512-cuzCE/1G0ZSnTAHJPUT1rPgQx1w5tzSX7POXSLaS7w2nIUJUD+e25QoXD/hMfxbsT9rslEXugWypJMILBj/QsA==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@next/swc-linux-arm64-musl": { + "version": "14.2.3", + "resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-musl/-/swc-linux-arm64-musl-14.2.3.tgz", + "integrity": "sha512-0D4/oMM2Y9Ta3nGuCcQN8jjJjmDPYpHX9OJzqk42NZGJocU2MqhBq5tWkJrUQOQY9N+In9xOdymzapM09GeiZw==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@next/swc-linux-x64-gnu": { + "version": "14.2.3", + "resolved": "https://registry.npmjs.org/@next/swc-linux-x64-gnu/-/swc-linux-x64-gnu-14.2.3.tgz", + "integrity": "sha512-ENPiNnBNDInBLyUU5ii8PMQh+4XLr4pG51tOp6aJ9xqFQ2iRI6IH0Ds2yJkAzNV1CfyagcyzPfROMViS2wOZ9w==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@next/swc-linux-x64-musl": { + "version": "14.2.3", + "resolved": "https://registry.npmjs.org/@next/swc-linux-x64-musl/-/swc-linux-x64-musl-14.2.3.tgz", + "integrity": "sha512-BTAbq0LnCbF5MtoM7I/9UeUu/8ZBY0i8SFjUMCbPDOLv+un67e2JgyN4pmgfXBwy/I+RHu8q+k+MCkDN6P9ViQ==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@next/swc-win32-arm64-msvc": { + "version": "14.2.3", + "resolved": "https://registry.npmjs.org/@next/swc-win32-arm64-msvc/-/swc-win32-arm64-msvc-14.2.3.tgz", + "integrity": "sha512-AEHIw/dhAMLNFJFJIJIyOFDzrzI5bAjI9J26gbO5xhAKHYTZ9Or04BesFPXiAYXDNdrwTP2dQceYA4dL1geu8A==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@next/swc-win32-ia32-msvc": { + "version": "14.2.3", + "resolved": "https://registry.npmjs.org/@next/swc-win32-ia32-msvc/-/swc-win32-ia32-msvc-14.2.3.tgz", + "integrity": "sha512-vga40n1q6aYb0CLrM+eEmisfKCR45ixQYXuBXxOOmmoV8sYST9k7E3US32FsY+CkkF7NtzdcebiFT4CHuMSyZw==", + "cpu": [ + "ia32" + ], + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 10" + } } } } diff --git a/src/__tests__/CreateProdudash.test.tsx b/src/__tests__/CreateProdudash.test.tsx index 92b0b1f..0127c3f 100644 --- a/src/__tests__/CreateProdudash.test.tsx +++ b/src/__tests__/CreateProdudash.test.tsx @@ -2,7 +2,7 @@ import React from 'react'; import { render, screen, waitFor } from '@testing-library/react'; import '@testing-library/jest-dom'; import { QueryClient, QueryClientProvider } from '@tanstack/react-query'; -import Page from '@/app/dashboard/addproduct/page'; +import Page from '@/app/dashboard/product/create/page'; import request from '@/utils/axios'; import { useRouter } from 'next/navigation'; diff --git a/src/__tests__/ProfileeditDashboard.test.tsx b/src/__tests__/ProfileeditDashboard.test.tsx index 1753d47..5e1790c 100644 --- a/src/__tests__/ProfileeditDashboard.test.tsx +++ b/src/__tests__/ProfileeditDashboard.test.tsx @@ -2,7 +2,7 @@ import React from 'react'; import { render, screen, waitFor } from '@testing-library/react'; import '@testing-library/jest-dom'; import { QueryClient, QueryClientProvider } from '@tanstack/react-query'; -import Page from '@/app/dashboard/profile_/[id]/page'; +import Page from '@/app/dashboard/profile/[id]/page'; import request from '@/utils/axios'; import { useRouter } from 'next/navigation'; diff --git a/src/__tests__/UpdateReduce.test.tsx b/src/__tests__/UpdateReduce.test.tsx index 17188e6..f02ab51 100644 --- a/src/__tests__/UpdateReduce.test.tsx +++ b/src/__tests__/UpdateReduce.test.tsx @@ -72,7 +72,7 @@ describe('updatePassword slice', () => { const action = { type: updatePassword.rejected.type, - error: 'Failed to update password', + erro: 'Failed to update password', }; const state = reducer(initialState, action); diff --git a/src/__tests__/ZcartManagement.test.tsx b/src/__tests__/ZcartManagement.test.tsx index 41a42c4..ed007f2 100644 --- a/src/__tests__/ZcartManagement.test.tsx +++ b/src/__tests__/ZcartManagement.test.tsx @@ -284,10 +284,6 @@ describe('userCartSlice', () => { // Assertions expect(mockedRequest.put).toHaveBeenCalledWith('/carts', expectedItems); const actions = dispatch.mock.calls.map((call) => call[0]); - console.log( - '1111111111111111111111111111111111111111111111111111111111111111111111111111111', - result, - ); expect(result.payload).toEqual({ data: 'success' }); expect(actions[0].type).toBe(handleRemoveItemInCart.pending.type); expect(actions[1].type).toBe(handleRemoveItemInCart.rejected.type); diff --git a/src/__tests__/app.test.tsx b/src/__tests__/app.test.tsx index 48fe53a..f7b3008 100644 --- a/src/__tests__/app.test.tsx +++ b/src/__tests__/app.test.tsx @@ -55,7 +55,6 @@ describe('Signup Components', () => { expect(screen.getByPlaceholderText('Confirm Password')).toBeInTheDocument(); }); it('displays error message on Signup failure', async () => { - console.log('this is env cccccccccccccccccccccc', process.env.URL); mockaxios.onPost(`${process.env.URL}/users/signup`).reply(409, { message: 'User with this email already exists', }); diff --git a/src/__tests__/sellerOrders.test.tsx b/src/__tests__/sellerOrders.test.tsx deleted file mode 100644 index ada629a..0000000 --- a/src/__tests__/sellerOrders.test.tsx +++ /dev/null @@ -1,51 +0,0 @@ - -import React from "react"; -import { render, screen } from "@testing-library/react"; -import '@testing-library/jest-dom'; -import Page from '@/app/sellers/orders/page'; -import { useQuery } from "@tanstack/react-query"; -import Providers from "@/app/providers"; -// Mock the SellerOrderList component -jest.mock("@/components/sellerOrder", () => () =>
SellerOrderList Component
); - - - -// Mock the SellerOrderList component -jest.mock("@/components/sellerOrder", () => () =>
SellerOrderList Component
); -jest.mock('next/navigation', () => ({ - useRouter() { - return { - prefetch: () => null, - }; - }, - useSearchParams: () => ({ - get: () => { } - }) - })); -// Create a QueryClient instance for testing - -const Test = () => { - const { data } = useQuery({ - queryKey: ['test'], - queryFn: () => 'test', - }); - return
{data}
; - }; - - it('renders children', async () => { - const { findByText } = render( - - - - ); - expect(await findByText('test')).toBeInTheDocument(); - }); - - - -it("renders SellerOrderList component", () => { - render(); - const element = screen.getByText("SellerOrderList Component"); - expect(element).toBeInTheDocument(); -}); - diff --git a/src/__tests__/sellerProduct.test.tsx b/src/__tests__/sellerProduct.test.tsx deleted file mode 100644 index 567fee8..0000000 --- a/src/__tests__/sellerProduct.test.tsx +++ /dev/null @@ -1,60 +0,0 @@ -import React from 'react'; -import { render, screen } from '@testing-library/react'; -import SellerProductView from '@/app/sellers/products_/page'; -import Page from '@/app/sellers/products_/[id]/page'; -import SellerDash from '@/app/sellers/page'; -import { QueryClient, QueryClientProvider } from '@tanstack/react-query'; - -const queryClient = new QueryClient(); - -jest.mock('next/navigation', () => ({ - useRouter: jest.fn(() => ({ - push: jest.fn(), - })), - useParams: jest.fn(() => ({ - id: '1', // Mocking a product ID - })), - - useSearchParams: jest.fn(() => ({ - get: jest.fn(), - })), -})); - -describe('sellerProductView', () => { - console.log( - 'should render test with t xxxxxxxxxxxxxxxxxxxxxxx in Seller product view ts', - ); - it('renders the loading state', () => { - console.log( - 'should render test with t xxxxxxxxxxxxxxxxxxxxxxx in Seller product it one ts', - ); - render( - - - , - ); - // expect(screen.getByText('Welcome to the seller dashboard')).toBeInTheDocument(); - }); - it('renders the "Seller products view" text', () => { - console.log( - 'should render test with t xxxxxxxxxxxxxxxxxxxxxxx in Seller product it two ts', - ); - render( - - - , - ); - // expect(screen.getByText('Seller products view')).toBeInTheDocument(); - }); - it('renders the loading state', () => { - console.log( - 'should render test with t xxxxxxxxxxxxxxxxxxxxxxx in Seller product it three ts', - ); - render( - - - , - ); - // expect(screen.getByText('Description:')).toBeInTheDocument(); - }); -}); diff --git a/src/__tests__/singleProduct.test.tsx b/src/__tests__/singleProduct.test.tsx index 3b3dbc5..7cf093f 100644 --- a/src/__tests__/singleProduct.test.tsx +++ b/src/__tests__/singleProduct.test.tsx @@ -2,7 +2,7 @@ import React from 'react'; import { render, screen, waitFor } from '@testing-library/react'; import '@testing-library/jest-dom'; import { QueryClient, QueryClientProvider } from '@tanstack/react-query'; -import Page from '@/app/dashboard/products_/[id]/page'; +import Page from '@/app/dashboard/product/[id]/page'; import request from '@/utils/axios'; import { useRouter } from 'next/navigation'; diff --git a/src/__tests__/updatesDash.test.tsx b/src/__tests__/updatesDash.test.tsx index b5b18e4..2f48759 100644 --- a/src/__tests__/updatesDash.test.tsx +++ b/src/__tests__/updatesDash.test.tsx @@ -2,7 +2,7 @@ import React from 'react'; import { render, screen, waitFor } from '@testing-library/react'; import '@testing-library/jest-dom'; import { QueryClient, QueryClientProvider } from '@tanstack/react-query'; -import Page from '@/app/dashboard/product_/[id]/page'; +import Page from '@/app/dashboard/product/[id]/edit/page'; import request from '@/utils/axios'; import { useRouter } from 'next/navigation'; import { Provider } from 'react-redux'; diff --git a/src/app/dashboard/product_/[id]/page.tsx b/src/app/dashboard/product/[id]/edit/page.tsx similarity index 95% rename from src/app/dashboard/product_/[id]/page.tsx rename to src/app/dashboard/product/[id]/edit/page.tsx index 8324154..750c184 100644 --- a/src/app/dashboard/product_/[id]/page.tsx +++ b/src/app/dashboard/product/[id]/edit/page.tsx @@ -34,11 +34,11 @@ function page() { console.log('nothing')} + onClose={() => router.back()} /> - ; + - ); + ) } export default page; diff --git a/src/app/dashboard/products_/[id]/page.tsx b/src/app/dashboard/product/[id]/page.tsx similarity index 100% rename from src/app/dashboard/products_/[id]/page.tsx rename to src/app/dashboard/product/[id]/page.tsx diff --git a/src/app/dashboard/addproduct/page.tsx b/src/app/dashboard/product/create/page.tsx similarity index 99% rename from src/app/dashboard/addproduct/page.tsx rename to src/app/dashboard/product/create/page.tsx index ed03e61..29f8835 100644 --- a/src/app/dashboard/addproduct/page.tsx +++ b/src/app/dashboard/product/create/page.tsx @@ -26,7 +26,7 @@ function page() { console.log('nothing')} />; - ); + ) } export default page; diff --git a/src/app/dashboard/profile_/[id]/page.tsx b/src/app/dashboard/profile/[id]/page.tsx similarity index 100% rename from src/app/dashboard/profile_/[id]/page.tsx rename to src/app/dashboard/profile/[id]/page.tsx diff --git a/src/app/dashboard/users/page.tsx b/src/app/dashboard/users/page.tsx index 1409f06..c918688 100644 --- a/src/app/dashboard/users/page.tsx +++ b/src/app/dashboard/users/page.tsx @@ -1,17 +1,19 @@ 'use client'; import React, { use, useEffect, useState } from 'react'; -import DashNavbar from '@/components/DashNavbar'; -import HeaderDash from '@/components/headerDash'; import UsersPageAdmin from '@/components/UsersAdmin'; import LayoutDashboard from '@/components/LayoutDashboard'; +import { useRouter } from 'next/navigation'; function page() { - const [user, setUser] = useState(); + const [user, setUser] = useState(); + const router = useRouter() useEffect(() => { const categ = async () => { const user = localStorage.getItem('profile') || ''; const finalUser = JSON.parse(user); - + if (finalUser.User.Role.name !== 'admin') { + router.back(); + } setUser(finalUser?.User); console.log(finalUser); }; diff --git a/src/app/globals.css b/src/app/globals.css index eb1001e..c2457cd 100644 --- a/src/app/globals.css +++ b/src/app/globals.css @@ -106,74 +106,10 @@ body {} } } -/* swipe */ -.swiper { - width: 100%; - height: 50%; -} - -.swiper-slide { - text-align: center; - font-size: 18px; - background: #fff; - - /* Center slide text vertically */ - display: flex; - justify-content: center; - align-items: center; -} - -.swiper-slide img { - display: block; - width: 100%; - height: 50%; - object-fit: cover; -} - -.swiper { - /* Down */ - width: 50%; - height: 300px; - margin-left: auto; - margin-right: auto; -} - -.swiper-slide { - width: 100%; - background-size: fit; - background-position: center; -} - -.mySwiper { - /* low division */ - width: 100%; - height:100%; - box-sizing: border-box; -} - -.mySwiper .swiper-slide { - /* low single img card */ - width: 25%; - height: 50%; - opacity: 0.4; -} -.mySwiper2 { - /* high division */ - width: 100%; - display: block; - object-fit: cover; -} - -.mySwiper .swiper-slide-thumb-active { - opacity: 1; -} .mySwiper4 .swiper-slide-thumb-active { opacity: 1; } -.mySwiper4 .swiper-slide-thumb-active { - opacity: 1; -} .swiper-slide img { display: block; width: 100%; diff --git a/src/app/products/[id]/page.tsx b/src/app/products/[id]/page.tsx index 09bcad4..da12101 100644 --- a/src/app/products/[id]/page.tsx +++ b/src/app/products/[id]/page.tsx @@ -47,9 +47,9 @@ function Page() { }); if (error) return Error: {error.message}; const { + productPrice, productPictures, productName, - productPrice, productDescription, reviews, } = data?.product || {}; @@ -158,7 +158,7 @@ function Page() { - {productPrice}{' '} + {productPrice.toLocaleString()}{' '} RWF diff --git a/src/app/sellers/orders/page.tsx b/src/app/sellers/orders/page.tsx deleted file mode 100644 index 1459cd9..0000000 --- a/src/app/sellers/orders/page.tsx +++ /dev/null @@ -1,12 +0,0 @@ -import Header from "@/components/Header"; -import SellerOrderList from "@/components/sellerOrder"; -import React, { Suspense, useEffect } from "react"; - -function Page() { - return ( - - ) - } - - export default Page; - \ No newline at end of file diff --git a/src/app/sellers/page.tsx b/src/app/sellers/page.tsx deleted file mode 100644 index 5596eae..0000000 --- a/src/app/sellers/page.tsx +++ /dev/null @@ -1,103 +0,0 @@ -"use client" - -import React, { Suspense, useEffect } from "react"; -import DashboardHeader from "@/components/DashboardHeader"; -import UsersPageAdmin from "@/components/UsersAdmin"; -import AdminDashboard from "@/hooks/useAdminDashboard"; -import SellerProductView from "@/app/sellers/products_/page"; - -function Dashboard() { - const { - handleItemClick, - header, - setDisplay, - display, - menu, - open, - setOpen } = AdminDashboard() - - useEffect(() => { - switch (header) { - case "Users": - setDisplay(); - break; - case "Products": - setDisplay(); - break; - default: - setDisplay(

Welcome to the seller dashboard

); - break; - } - }, [header]); - - return ( -
- - -
-
- -
{display}
-
-
-
- ); -} - -function Page() { - return ( - - - - ) -} - -export default Page; - - - - - - diff --git a/src/app/sellers/products_/page.tsx b/src/app/sellers/products_/page.tsx deleted file mode 100644 index 352b7b5..0000000 --- a/src/app/sellers/products_/page.tsx +++ /dev/null @@ -1,34 +0,0 @@ -"use client" -import React, { useState } from 'react'; -import Table from '@/components/Table'; -import { GreenButton } from '@/components/Button'; -import DashboardHeader from '@/components/DashboardHeader'; -import ProductPopup from '@/components/Product/AddProducts'; -function SellerProductView() { - const [isPopupOpen, setIsPopupOpen] = useState(false); - const handleOpenPopup = () => { - setIsPopupOpen(true); - }; - const handleClosePopup = () => { - setIsPopupOpen(false); - }; - return ( - <> -
-
-
-

Seller products view

-
- -
-
-
- - - - - {isPopupOpen && } - - ); -} -export default SellerProductView; diff --git a/src/components/Card.tsx b/src/components/Card.tsx index e48a4ef..1882078 100644 --- a/src/components/Card.tsx +++ b/src/components/Card.tsx @@ -49,7 +49,7 @@ function Card({
- {productPrice} RWF + {productPrice.toLocaleString()} RWF = ({ role }) => {
= ({ role }) => {
handleClick('/')} />

@@ -93,7 +95,7 @@ const DashNavbar: React.FC = ({ role }) => {
  • {React.createElement(FaHome)} = ({ role }) => {
  • {React.createElement(FaUsersGear)} = ({ role }) => {
  • {React.createElement(FaUserShield)} = ({ role }) => {
  • {React.createElement(AiFillProduct)} = ({ role }) => {
  • {React.createElement(BsBorderStyle)} = ({ role }) => {
  • - +
  • {React.createElement(MdCreateNewFolder)} = ({ role }) => {
  • mutate()} - className={`flex bg-primary/80 ${activelink === 'product' ? 'text-yellow-400' : 'text-white'} text-2xl hover:text-yellow-400 duration-200 bg-transparent rounded-md hover:bg-primary p-2 cursor-pointer hover:bg-light-white items-center gap-x-4 bg-light-white`} + className={`flex bg-primary/80 ${activelink === '' ? 'text-yellow-400' : 'text-white'} text-2xl hover:text-yellow-400 duration-200 bg-transparent rounded-md hover:bg-primary p-2 cursor-pointer hover:bg-light-white items-center gap-x-4 bg-light-white`} > {React.createElement(MdOutlineLogout)} = ({ role }) => { onClick={handlemenu} className={`${activelink === 'addproduct' ? 'bg-yellow-600 text-white font-bold' : 'text-black'} hover:bg-yellow-400 px-2 hover:text-white font-semibold`} > - Create Product + + Create Product +
  • )}
  • mutate()} className={` hover:bg-yellow-400 px-2 hover:text-white font-semibold`} > diff --git a/src/components/DashboardHeader.tsx b/src/components/DashboardHeader.tsx deleted file mode 100644 index 66ea892..0000000 --- a/src/components/DashboardHeader.tsx +++ /dev/null @@ -1,82 +0,0 @@ -'use client'; -import React, { useState } from 'react'; -import { CiBellOn } from 'react-icons/ci'; -import { GiHamburgerMenu } from 'react-icons/gi'; -import { useQuery } from '@tanstack/react-query'; -import request from '@/utils/axios'; -import NotificationIcon from './ui-components/NotificationIcon'; -import Notification from './ui-components/Notification'; -import SideBarOverlay from './UsableSideOvelay'; - -interface HeaderInterface { - pageName: string; -} - -interface userData { - firstName: string; - profileImage: string; - Role: { - name: string; - }; -} - -const DashboardHeader: React.FC = ({ pageName }) => { - const { isLoading, error, data } = useQuery({ - queryKey: ['userProfile'], - queryFn: () => request.get('/users/profile'), - }); - const [overlayComponent, setOverlayComponent] = useState< - 'cart' | 'notification' | null - >(null); - const handleShowNotification = () => { - setOverlayComponent('notification'); - }; - const user = data?.User as userData; - - const handleCloseOverlay = () => { - setOverlayComponent(null); - }; - return ( - <> -
    -

    - {pageName} -

    - Logo -
    -
    - -
    -
    - - Logo { - e.currentTarget.src = '/unknown.jpg'; - }} - className="cursor-pointer rounded-[10px] w-[40px] sm:w-[60px] h-[40px] sm:h-[60px]" - /> -
    -

    - {user?.firstName || 'username'} -

    -

    - {user?.Role?.name || 'Role'} -

    -
    - -
    -
    -
    - {overlayComponent && ( - - {overlayComponent === 'notification' && ( - - )} - - )} - - ); -}; -export default DashboardHeader; diff --git a/src/components/EditProfile.tsx b/src/components/EditProfile.tsx index 161b47d..a97e450 100644 --- a/src/components/EditProfile.tsx +++ b/src/components/EditProfile.tsx @@ -3,26 +3,31 @@ import React, { useEffect, useState, useRef } from 'react'; import { useDispatch, useSelector } from 'react-redux'; import { AppDispatch, RootState } from '@/redux/store'; import { getUserProfile, updateUserProfile } from '@/redux/slices/profileSlice'; -import Header from '@/components/Header'; -import Footer from '@/components/Footer'; -import InputBox from '@/components/InputBox'; + import { toast } from 'react-toastify'; import { showToast } from '@/helpers/toast'; import { useForm, SubmitHandler, useWatch } from 'react-hook-form'; -import { zodResolver } from '@hookform/resolvers/zod'; + import updateSchema from '@/validations/userProfileSchema'; import { useRouter } from 'next/navigation'; import type { z } from 'zod'; +import { zodResolver } from '@hookform/resolvers/zod'; + +import InputBox from '@/components/InputBox'; +import UpdatePasswords from './updatepassword'; type FormSchemaType = z.infer; const UserProfileForm: React.FC = () => { const route = useRouter(); + const [showlModal, setShowmodal] = useState(false); const dispatch = useDispatch(); const { user, loading, error } = useSelector( (state: RootState) => state.userProfile, ); - + const handleshow = () => { + setShowmodal(!showlModal); + }; const { register, handleSubmit, @@ -113,7 +118,6 @@ const UserProfileForm: React.FC = () => { ); if (response.payload && response.payload.User) { currentProfile.User = response.payload.User; - console.log('currentProfile', currentProfile); localStorage.setItem('profile', JSON.stringify(currentProfile)); } @@ -267,6 +271,14 @@ const UserProfileForm: React.FC = () => { {watchedValues.phone || 'Contact Number'}
  • +
  • + +
  • @@ -350,10 +362,11 @@ const UserProfileForm: React.FC = () => {

    +
    ); }; diff --git a/src/components/LatestCard.tsx b/src/components/LatestCard.tsx index 95f41e8..a0404f1 100644 --- a/src/components/LatestCard.tsx +++ b/src/components/LatestCard.tsx @@ -27,7 +27,7 @@ const LatestCard: React.FC = ({

    {name}

    -

    Price:{price} RWF

    +

    Price: {price.toLocaleString()} RWF

    diff --git a/src/components/Product/editProduct.tsx b/src/components/Product/editProduct.tsx index 8514b9b..3e63864 100644 --- a/src/components/Product/editProduct.tsx +++ b/src/components/Product/editProduct.tsx @@ -47,6 +47,7 @@ const ProductPopup: React.FC = ({ }) => { const { id } = useParams(); const productId: any = id; + const router = useRouter() const [reuploadStatus, setReuploadStatus] = useState( 'Wait for loading product image........', ); @@ -161,8 +162,6 @@ const ProductPopup: React.FC = ({ }, []); const onSubmit: SubmitHandler = async (data) => { - console.log('data received', data); - console.log('CURRENCY', data.currency); if (files.length < 4) { setUploadError('You must upload at least 4 pictures.'); return; @@ -179,12 +178,9 @@ const ProductPopup: React.FC = ({ try { const result = await handleUpdateProduct(data, productId); showToast('Product has been updated', 'success'); - console.log(result); onClose(); } catch (error: any) { - console.log('ERROR', error); - console.error('Failed to update product:', error); let errorMessage = 'An unknown error occurred'; if (error.response) { if (error.response.data && error.response.data.error) { @@ -211,10 +207,6 @@ const ProductPopup: React.FC = ({ const file = e.target.files[0]; const totalFiles = files.length + 1; - console.log( - '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++filessss', - files, - ); // Check for maximum file limit if (totalFiles > 8) { setUploadError('You can upload a maximum of 8 pictures.'); @@ -469,7 +461,7 @@ const ProductPopup: React.FC = ({
    diff --git a/src/components/UsersAdmin.tsx b/src/components/UsersAdmin.tsx index 60642fa..f7b437f 100644 --- a/src/components/UsersAdmin.tsx +++ b/src/components/UsersAdmin.tsx @@ -114,9 +114,9 @@ const UsersPageAdmin = () => { <>
    {isLoading ? ( -
    -
    -
    +
    +
    +
    ) : (
    {!data ? ( diff --git a/src/components/headerDash.tsx b/src/components/headerDash.tsx index f6d51db..98b42a9 100644 --- a/src/components/headerDash.tsx +++ b/src/components/headerDash.tsx @@ -46,7 +46,7 @@ const HeaderDash: React.FC = ({ pageName }) => {
    diff --git a/src/components/profile/ProfileHeader.tsx b/src/components/profile/ProfileHeader.tsx index 1a07226..5025bf9 100644 --- a/src/components/profile/ProfileHeader.tsx +++ b/src/components/profile/ProfileHeader.tsx @@ -70,7 +70,7 @@ function ProfileHeader() { const router = useRouter(); const handleEditProfile = () => { if (user?.User.Role.name !== 'buyer') { - router.push(`/dashboard/profile_/${user?.User?.id}`); + router.push(`/dashboard/profile/${user?.User?.id}`); } else { router.push('/profile-edit'); } @@ -100,12 +100,6 @@ function ProfileHeader() {
    - = ({ role }) => { const [thumbsSwiper, setThumbsSwiper] = useState(null); const [Confirm, setConfirm] = useState(false); @@ -153,7 +156,10 @@ const Singleproduct: React.FC = ({ role }) => {
    )} - {productPrice} RWF + + {productPrice?.toLocaleString()} + {' '} + RWF
    @@ -172,7 +178,7 @@ const Singleproduct: React.FC = ({ role }) => {
    {role === 'seller' && (
    - + = ({ role }) => {
    +
    +
    +

    Reviews:

    +
    +
    + {reviews && reviews.length > 0 ? ( + reviews.map((review: ReviewType) => ( + + )) + ) : ( +

    No ratings yet.

    + )} +
    +
    {Confirm ? ( void; + showlModal: boolean; +} + +const UpdatePasswords: React.FC = ({ handleshow, showlModal }) => { + let { submit, erro, loadings, success, handlemoduleButton } = + UpdatePassword(); + const { + register, + handleSubmit, + formState: { errors }, + reset, + } = useForm({ + resolver: zodResolver(Updatepassword), + }); + const onSubmit = (data: FormDataType) => { + const result = submit(data); + // if (result) { + // reset(); + // } + }; + + return ( +
    + {showlModal && ( + +
    +
    + + + +

    {erro}

    +
    +
    + +
    +
    + )} + {success && ( + + )} +
    + ); +}; + +export default UpdatePasswords; diff --git a/src/hooks/useAdminDashboard.ts b/src/hooks/useAdminDashboard.ts deleted file mode 100644 index 5b38ea2..0000000 --- a/src/hooks/useAdminDashboard.ts +++ /dev/null @@ -1,59 +0,0 @@ -import React, { useEffect, useState } from "react"; -import { MdDashboard } from "react-icons/md"; -import { IoCartOutline, IoPersonOutline } from "react-icons/io5"; -import { FaChartLine } from "react-icons/fa6"; -import { IconType } from "react-icons"; -import { useSearchParams } from "next/navigation"; -import product from '../../public/product.svg' -import { useRouter } from "next/navigation"; - -interface MenuInterface { - title: string; - src: IconType; - gap?: boolean; - clicked: boolean; -} - -const Menus: MenuInterface[] = [ - { title: "Dashboard", src: MdDashboard, clicked: true }, - { title: "Users", src: IoPersonOutline, clicked: false }, - { title:"Products", src: IoCartOutline, clicked: false }, - { title:"Chart", src: FaChartLine, clicked: false} -]; - -function AdminDashboard() { - const router = useRouter() - const searchParams:any = useSearchParams() - const [open, setOpen] = useState(false) - const [display, setDisplay] = useState(null); - const [menu, setMenus] = useState(Menus); - const [header, setHeader] = useState(""); - - useEffect(() => { - setHeader(searchParams.get("page"?.toString()) || "Dashboard") - }, []) - - const handleItemClick = (index: number) => { - const clickedItem = Menus[index]; - const updatedMenus = Menus.map((menu, i) => { - return { - ...menu, - clicked: i === index, - }; - }); - setHeader(clickedItem.title); - setMenus(updatedMenus); - router.push(`?page=${clickedItem.title}`) - }; - - return { - handleItemClick, - open, - setOpen, - display, - setDisplay, - header, - menu, - } -} -export default AdminDashboard
    {product.productName} {product.stockLevel} - {product.productPrice} {product.productCurrency} + {product.productPrice.toLocaleString()}{' '} + {product.productCurrency} {product.productDiscount} - + @@ -150,7 +151,7 @@ const ProductsTable: React.FC = ({ Role }) => { - + @@ -163,7 +164,7 @@ const ProductsTable: React.FC = ({ Role }) => { handleStatus(product.id, product.isAvailable) } > - {product.isAvailable ? 'available' : 'unvailble'} + {product.isAvailable ? 'Available' : 'Unvailable'}