diff --git a/src/__tests__/formatTime.test.tsx b/src/__tests__/formatTime.test.tsx
deleted file mode 100644
index 5a695ae..0000000
--- a/src/__tests__/formatTime.test.tsx
+++ /dev/null
@@ -1,39 +0,0 @@
-// eslint-disable-next-line import/extensions
-import { formatTime } from '@/utils/formatTime';
-
-describe('formatTime', () => {
- it('should format the time correctly for a valid Date object', () => {
- const date = new Date('2024-07-08T14:34:56Z');
- const formattedTime = formatTime(date);
-
- // Adjust the expected time based on your local time zone or set the date to UTC.
- const expectedHours = date.getUTCHours().toString().padStart(2, '0');
- const expectedMinutes = date.getUTCMinutes().toString().padStart(2, '0');
- const expectedSeconds = date.getUTCSeconds().toString().padStart(2, '0');
- const expectedTime = `${expectedHours}:${expectedMinutes}:${expectedSeconds}`;
-
- expect(formattedTime).toBe(expectedTime);
- });
-
- it('should return "NaN:NaN:NaN" for an invalid date string', () => {
- const invalidDate = 'invalid-date-string';
- const formattedTime = formatTime(invalidDate as any);
- expect(formattedTime).toBe('NaN:NaN:NaN');
- });
-
- it('should return "NaN:NaN:NaN" for a number input', () => {
- const invalidNumber = 12345;
- const formattedTime = formatTime(invalidNumber as any);
- expect(formattedTime).toBe('NaN:NaN:NaN');
- });
-
- it('should return "NaN:NaN:NaN" for null input', () => {
- const formattedTime = formatTime(null as any);
- expect(formattedTime).toBe('NaN:NaN:NaN');
- });
-
- it('should return "NaN:NaN:NaN" for undefined input', () => {
- const formattedTime = formatTime(undefined as any);
- expect(formattedTime).toBe('NaN:NaN:NaN');
- });
-});
diff --git a/src/app/globals.css b/src/app/globals.css
index 34bf3a5..58148d9 100644
--- a/src/app/globals.css
+++ b/src/app/globals.css
@@ -241,9 +241,9 @@ body {}
}
/* Scroll */
-.o-hidden{overflow: hidden !important;}
+/* .o-hidden{overflow: hidden !important;}
.o-x-scroll{overflow-y: scroll !important;}
-.opacity-0{opacity: 0 !important;}
+.opacity-0{opacity: 0 !important;} */
/* doubleshricked*/
/* width */
.scroll-double-shrinked::-webkit-scrollbar {
@@ -264,4 +264,4 @@ body {}
margin-top: 4px !important ;
margin-bottom: 4px !important ;
height: 90% !important;
-}
\ No newline at end of file
+}
diff --git a/src/app/page.tsx b/src/app/page.tsx
index a4b18c8..91baf78 100644
--- a/src/app/page.tsx
+++ b/src/app/page.tsx
@@ -7,15 +7,15 @@ import Header from '@/components/Header';
import HeroSection from '@/components/HeroSection';
import { LatestSection } from '@/components/LatestSection';
import Footer from '@/components/Footer';
-import { MdOutlineChat } from 'react-icons/md';
-import { IoMdClose } from 'react-icons/io';
+
import { HomeAds } from '@/components/HomeAds';
+
import { ProductWithFilter } from '@/components/allProducts';
-import Link from 'next/link';
-import ChatRoomsList from '@/components/ChatRoomsList';
import ChatPopUp from '@/hooks/ChatPopUp';
import ChatWrapper from '@/components/chatWrapper';
-
+import Link from 'next/link';
+import { MdOutlineChat } from 'react-icons/md';
+import { checkUserLoggedIn } from '@/components/isLogged';
export interface FormDataType {
confirmPassword: string;
@@ -24,9 +24,8 @@ export interface FormDataType {
}
export default function Home() {
- // const [isOpen, setIsOpen] = useState(false);
- const [showlModal, setShowmodal] = useState(false);
const { isChatPopUpOpen, setIsChatPopUpOpen, toggleChatPopUp } = ChatPopUp();
+ const [showlModal, setShowmodal] = useState(false);
const {
register,
handleSubmit,
@@ -43,42 +42,12 @@ export default function Home() {
reset();
};
- // function handlePopUp(): void {
- // setIsOpen(!isOpen);
- // }
-
return (
-
- {/*
-
-
-
-
*/}
-
- {/* Startttttttt */}
-
-
-
-
-
- {isChatPopUpOpen && (
- //
-
- )}
-
-
- {/* Enddddddddd */}
+
+
{/* The Image adds */}
{/* LAtest Product */}
@@ -98,6 +67,26 @@ export default function Home() {
+ {/* Startttttttt */}
+
+ {checkUserLoggedIn() && (
+
+
+
+ )}
+
+ {isChatPopUpOpen && (
+ //
+
+ )}
+
+
+ {/* Enddddddddd */}
{/* Footer Sections */}
diff --git a/src/components/ChatConversation.tsx b/src/components/ChatConversation.tsx
index f86e6db..11ff278 100644
--- a/src/components/ChatConversation.tsx
+++ b/src/components/ChatConversation.tsx
@@ -70,7 +70,7 @@ const allMessagesList = messages.map((message:Message)=>{
toogleDislay={toogleDislay}
/>
-
+
{allMessagesList}
diff --git a/src/components/ChatRoomsList.tsx b/src/components/ChatRoomsList.tsx
index 6a7aa9f..01db01b 100644
--- a/src/components/ChatRoomsList.tsx
+++ b/src/components/ChatRoomsList.tsx
@@ -23,16 +23,10 @@ const ChatRoomsList:React.FC
=({chatrooms, currentUser, toogleDis
))
return (
<>
-
+
Messages
-
-
-
-
+
{ListOfChatRooms}
diff --git a/src/components/DashboardHeader.tsx b/src/components/DashboardHeader.tsx
index 1f258e9..66ea892 100644
--- a/src/components/DashboardHeader.tsx
+++ b/src/components/DashboardHeader.tsx
@@ -1,5 +1,5 @@
'use client';
-import React, { useEffect, useState } from 'react';
+import React, { useState } from 'react';
import { CiBellOn } from 'react-icons/ci';
import { GiHamburgerMenu } from 'react-icons/gi';
import { useQuery } from '@tanstack/react-query';
@@ -32,41 +32,6 @@ const DashboardHeader: React.FC = ({ pageName }) => {
setOverlayComponent('notification');
};
const user = data?.User as userData;
- // const { isChatPopUpOpen, setIsChatPopUpOpen, toggleChatPopUp } = ChatPopUp();
- // const [currentUser, setCurrentUser] = useState(getCurrentUser());
- // const [currentUserToken, setCurrentUserToken] = useState('');
- // const [chatrooms, setChatrooms] = useState([]);
-
-
- // useEffect(() => {
- // const token = localStorage.getItem('token');
- // if (token) {
- // const trimmedToken = token.split(' ')[1];
- // setCurrentUserToken(trimmedToken);
-
- // socket = io(`${process.env.URL__CHAT}`, {
- // auth: { token: trimmedToken },
- // });
-
- // socket.on('connect', () => {
- // socket.emit('fetch all chatrooms');
- // });
-
- // socket.on('connect_error', (err) => {
- // console.error('Socket connection error:', err);
-
- // });
-
- // socket.on('all chatrooms', (receivedChatrooms) => {
- // setChatrooms(receivedChatrooms);
- // });
-
- // return () => {
- // socket.off('all chatrooms');
- // socket.disconnect();
- // };
- // }
- // }, [currentUserToken]);
const handleCloseOverlay = () => {
setOverlayComponent(null);
diff --git a/src/components/LayoutDashboard.tsx b/src/components/LayoutDashboard.tsx
index bcfcf98..7b540cb 100644
--- a/src/components/LayoutDashboard.tsx
+++ b/src/components/LayoutDashboard.tsx
@@ -3,9 +3,9 @@ import React, { FC, useEffect, useState } from 'react';
import DashNavbar from '@/components/DashNavbar';
import HeaderDash from '@/components/headerDash';
import { useRouter } from 'next/navigation';
+import ChatWrapper from './chatWrapper';
import { MdOutlineChat } from 'react-icons/md';
import ChatPopUp from '@/hooks/ChatPopUp';
-import ChatWrapper from './chatWrapper';
interface Properties {
children: React.ReactNode;
pageName: string;
@@ -16,6 +16,7 @@ const LayoutDashboard: React.FC = ({
pageName,
isLoading,
}) => {
+ const { isChatPopUpOpen, setIsChatPopUpOpen, toggleChatPopUp } = ChatPopUp();
const [user, setUser] = useState();
const router = useRouter();
useEffect(() => {
@@ -33,38 +34,40 @@ const LayoutDashboard: React.FC = ({
};
categ();
}, []);
- const { isChatPopUpOpen, setIsChatPopUpOpen, toggleChatPopUp } = ChatPopUp();
+
return (
-
-
-
-
-
-
-
+ <>
+
+
+
-
- {/* Statistic section */}
-
- {!isLoading ? (
- children
- ) : (
-
- )}
+
+
+
+
+
+ {/* Statistic section */}
+
+ {!isLoading ? (
+ children
+ ) : (
+
+ )}
+
{/* Startttttttt */}
-
-
+
+
{isChatPopUpOpen && (
//
@@ -72,7 +75,7 @@ const LayoutDashboard: React.FC
= ({
{/* Enddddddddd */}
-
+ >
);
};
diff --git a/src/components/Product/AddProducts.tsx b/src/components/Product/AddProducts.tsx
index 5d8bb6c..205938d 100644
--- a/src/components/Product/AddProducts.tsx
+++ b/src/components/Product/AddProducts.tsx
@@ -91,6 +91,7 @@ const ProductPopup: React.FC
= ({
console.log(result.message);
onClose();
} catch (error: any) {
+ console.error('Failed to create product:', error);
let errorMessage = 'An unknown error occurred';
if (error.response) {
if (error.response.data && error.response.data.error) {
diff --git a/src/components/chatWrapper.tsx b/src/components/chatWrapper.tsx
index d591bc6..bec8109 100644
--- a/src/components/chatWrapper.tsx
+++ b/src/components/chatWrapper.tsx
@@ -1,3 +1,5 @@
+'use client'
+
import React,{useState, useEffect} from 'react'
import ChatConversation from './ChatConversation'
import ChatRoomsList from './ChatRoomsList'
@@ -16,9 +18,8 @@ export interface msgObject {
}
let socket: Socket;
-
const ChatWrapper= () => {
-
+ const chatUrl = process.env.NEXT_PUBLIC_URL_CHAT as string;
//socket connect
const [chatrooms, setChatrooms] = useState([]);
@@ -43,14 +44,14 @@ const ChatWrapper= () => {
}
},[]);
-
useEffect(() => {
const token = localStorage.getItem('token');
if (token) {
const trimmedToken = token.split(' ')[1];
setCurrentUserToken(trimmedToken);
-
- socket = io('http://localhost:9090/chats', {
+ // const chatUrl = process.env.URL_CHAT as string
+ console.log("Chatttttt urllllllll",chatUrl);
+ socket = io(chatUrl, {
auth: { token: trimmedToken },
});
diff --git a/src/components/isLogged.tsx b/src/components/isLogged.tsx
new file mode 100644
index 0000000..05f4897
--- /dev/null
+++ b/src/components/isLogged.tsx
@@ -0,0 +1,8 @@
+'use client'
+
+export const checkUserLoggedIn = (): boolean => {
+ const userLocalStorage = localStorage.getItem("profile");
+ const userParse =JSON.parse( userLocalStorage as string);
+ return (userParse?.User)? true : false;
+ };
+
\ No newline at end of file
diff --git a/src/utils/formatTime.tsx b/src/utils/formatTime.tsx
index c89bbad..8e087ef 100644
--- a/src/utils/formatTime.tsx
+++ b/src/utils/formatTime.tsx
@@ -1,30 +1,11 @@
-import { ReactNode } from "react";
-export const formatTime = (dateString: Date | ReactNode): string => {
- if (!(dateString instanceof Date)) {
- return 'NaN:NaN:NaN';
- }
+import { ReactNode } from "react";
- const date = new Date(dateString);
- // eslint-disable-next-line no-restricted-globals
- if (isNaN(date.getTime())) {
- return 'NaN:NaN:NaN';
+export const formatTime=(dateString : Date | ReactNode)=> {
+ const date = new Date(dateString as Date);
+ const hours = date.getHours().toString().padStart(2, '0');
+ const minutes = date.getMinutes().toString().padStart(2, '0');
+ const seconds = date.getSeconds().toString().padStart(2, '0');
+ return `${hours}:${minutes}:${seconds}`;
}
-
- const hours = date.getHours().toString().padStart(2, '0');
- const minutes = date.getMinutes().toString().padStart(2, '0');
- const seconds = date.getSeconds().toString().padStart(2, '0');
- return `${hours}:${minutes}:${seconds}`;
-};
-
-
-
-// import { ReactNode } from "react";
-
-// export const formatTime=(dateString : Date | ReactNode)=> {
-// const date = new Date(dateString as Date);
-// const hours = date.getHours().toString().padStart(2, '0');
-// const minutes = date.getMinutes().toString().padStart(2, '0');
-// const seconds = date.getSeconds().toString().padStart(2, '0');
-// return `${hours}:${minutes}:${seconds}`;
-// }
\ No newline at end of file
+
\ No newline at end of file
diff --git a/tailwind.config.ts b/tailwind.config.ts
index a7a6ba9..7fc7cc8 100644
--- a/tailwind.config.ts
+++ b/tailwind.config.ts
@@ -22,8 +22,6 @@ const config: Config = {
},
},
},
- plugins: [
- require('daisyui'),
- ],
+ plugins: [],
};
-export default config;
+export default config;
\ No newline at end of file