-
-
- */}
+ {/*
+ /> */}
-
diff --git a/src/components/auth/profile-validation-schema.tsx b/src/components/auth/profile-validation-schema.tsx
index 8d4c001..6f596d1 100644
--- a/src/components/auth/profile-validation-schema.tsx
+++ b/src/components/auth/profile-validation-schema.tsx
@@ -1,8 +1,6 @@
import * as yup from 'yup';
export const profileValidationSchema = yup.object().shape({
- name: yup.string().required('form:error-name-required'),
- profile: yup.object().shape({
- contact: yup.string().max(19, 'maximum 19 digit').optional(),
- }),
+ fullname: yup.string(),
+
});
diff --git a/src/components/chat/chat-input.tsx b/src/components/chat/chat-input.tsx
index a766dae..68b64ef 100644
--- a/src/components/chat/chat-input.tsx
+++ b/src/components/chat/chat-input.tsx
@@ -1,28 +1,28 @@
-import { PiTrash } from "react-icons/pi";
-import Image from "next/image";
-import SendIcon from "public/image/send-01.svg";
-import MicIcon from "public/image/microphone-01.svg";
-import LinkIcon from "public/image/link-simple.svg";
-import SmileIcon from "public/image/face-smile.svg";
-import { MdClose } from "react-icons/md";
-import { useEffect, useState, useRef } from "react";
-import { useWebSocket } from "@/contexts/WebSocket.context";
-import FileInput from "./file-input";
-import dynamic from "next/dynamic";
-import EmojiPicker from "emoji-picker-react";
-import { BsFillReplyFill } from "react-icons/bs";
+import { PiTrash } from 'react-icons/pi';
+import Image from 'next/image';
+import SendIcon from 'public/image/send-01.svg';
+import MicIcon from 'public/image/microphone-01.svg';
+import LinkIcon from 'public/image/link-simple.svg';
+import SmileIcon from 'public/image/face-smile.svg';
+import { MdClose } from 'react-icons/md';
+import { useEffect, useState, useRef } from 'react';
+import { useWebSocket } from '@/contexts/WebSocket.context';
+import FileInput from './file-input';
+import dynamic from 'next/dynamic';
+import EmojiPicker from 'emoji-picker-react';
+import { BsFillReplyFill } from 'react-icons/bs';
// Dynamically import ReactMediaRecorder to prevent SSR issues
const ReactMediaRecorder = dynamic(
- () => import("react-media-recorder").then((mod) => mod.ReactMediaRecorder),
- { ssr: false }
+ () => import('react-media-recorder').then((mod) => mod.ReactMediaRecorder),
+ { ssr: false },
);
// Helper function to format recording time
const formatTime = (seconds) => {
const mins = Math.floor(seconds / 60)
.toString()
- .padStart(2, "0");
- const secs = (seconds % 60).toString().padStart(2, "0");
+ .padStart(2, '0');
+ const secs = (seconds % 60).toString().padStart(2, '0');
return `${mins}:${secs}`;
};
@@ -39,7 +39,7 @@ const Input = ({ product = {} }) => {
const [showProduct, setShowProduct] = useState(!!product.id);
const [isRecording, setIsRecording] = useState(false);
const [recordingTime, setRecordingTime] = useState(0);
- const [message, setMessage] = useState("");
+ const [message, setMessage] = useState('');
const [showEmojiPicker, setShowEmojiPicker] = useState(false); // Emoji picker state
// Ref for the timer interval
@@ -60,11 +60,11 @@ const Input = ({ product = {} }) => {
id: editingMessage.id,
};
editMessage(msg);
- setEditingMessage({})
- setMessage("");
+ setEditingMessage({});
+ setMessage('');
} else {
sendMessage(message, product?.id);
- setMessage("");
+ setMessage('');
setShowProduct(false);
}
}
@@ -108,9 +108,9 @@ const Input = ({ product = {} }) => {
}
};
- document.addEventListener("mousedown", handleClickOutside);
+ document.addEventListener('mousedown', handleClickOutside);
return () => {
- document.removeEventListener("mousedown", handleClickOutside);
+ document.removeEventListener('mousedown', handleClickOutside);
};
}, []);
useEffect(() => {
@@ -119,7 +119,7 @@ const Input = ({ product = {} }) => {
messageInputRef.current?.focus(); // Set focus on the input
}
}, [editingMessage]);
-
+
return (
{
stopTimer();
if (sendRecordingRef.current) {
let selectedFile = blob;
- selectedFile.status = "loading";
+ selectedFile.status = 'loading';
selectedFile.name = `audio ${new Date()}.wav`;
setLoadingMessage((prev) => [...prev, selectedFile]);
} else {
- console.log("Recording discarded:", blobUrl);
+ console.log('Recording discarded:', blobUrl);
}
sendRecordingRef.current = false; // Reset the flag after handling
}}
render={({ startRecording, stopRecording }) => (
- {/* Product Preview */}
- {product.id && showProduct && (
-
-
-
-
- {product?.images && product.images.length > 0 && (
-
- )}
-
-
- {product.name || "Unnamed Product"}
-
-
{product.price}$
-
-
-
{setShowProduct(false)}}
- size={20}
- aria-label="Close product preview"
- className="cursor-pointer"
- />
-
-
- )}
-
- {!!Object.keys(editingMessage).length && (
-
-
-
-
-
-
-
- {editingMessage.mime_type === "text"
- ? editingMessage.content
- : editingMessage.mime_type}
-
-
-
-
{setEditingMessage({}); setMessage("")}}
- size={20}
- aria-label="Close product preview"
- className="cursor-pointer"
- />
-
-
- )}
{/* Message Input Area */}
- {/* Emoji Button */}
-
{
- setShowEmojiPicker((prev) => !prev); // Toggle emoji picker state
- }}
- className="text-white px-3 py-2 rounded-md transition flex items-center hover:bg-slate-100"
- aria-label="Insert emoji"
- >
-
-
-
- {/* Emoji Picker */}
- {showEmojiPicker && (
-
- {
- setMessage(
- (prevMessage) => prevMessage + emojiObject.emoji
- );
- messageInputRef.current?.focus();
- }}
- emojiStyle="native"
- skinTonesDisabled
- previewConfig={{
- showPreview: false,
- }}
- />
-
- )}
+ {isRecording ? (
+
+ {/* Trash Button */}
+
+
{
+ sendRecordingRef.current = false; // Discard recording
+ stopRecording();
+ }}
+ aria-label="Discard recording"
+ className="text-red-600 flex items-center gap-2 hover:text-red-800"
+ >
+
+
- {/* Textarea Input */}
-
+
{
sendRecordingRef.current = true; // Indicate sending
stopRecording();
- } else {
- handleSendMessage();
- }
- }}
- className="text-white px-3 py-2 rounded-md transition flex items-center hover:bg-slate-100"
- aria-label={isRecording ? "Send recording" : "Send message"}
- >
-
-
+ }}
+ className="text-red-600 flex items-center gap-2 hover:text-red-800"
+ aria-label="Stop recording"
+ >
+
+
+
) : (
<>
- {!isRecording && (
- <>
-
-
{
- startRecording();
+ {/* Emoji Button */}
+ {
+ setShowEmojiPicker((prev) => !prev);
+ }}
+ className="text-white px-3 py-2 rounded-md transition flex items-center hover:bg-slate-100"
+ aria-label="Insert emoji"
+ >
+
+
+
+ {/* Emoji Picker */}
+ {showEmojiPicker && (
+
+ {
+ setMessage(
+ (prevMessage) => prevMessage + emojiObject.emoji,
+ );
+ messageInputRef.current?.focus();
}}
- className="text-white px-3 py-2 rounded-md transition flex items-center hover:bg-slate-100"
- aria-label="Start recording"
- >
-
-
- >
+ emojiStyle="native"
+ skinTonesDisabled
+ previewConfig={{
+ showPreview: false,
+ }}
+ />
+
)}
+
+ {/* Textarea Input */}
+
diff --git a/src/components/chat/message.tsx b/src/components/chat/message.tsx
index ed58bec..b381682 100644
--- a/src/components/chat/message.tsx
+++ b/src/components/chat/message.tsx
@@ -228,17 +228,17 @@ const Message = ({ msg }) => {
locale: router.locale,
});
}}
- className="w-[calc(50%-12px)] bg-[#C5C5C5]"
+ className="w-[calc(100%-12px)] bg-[#C5C5C5]"
>
Product details
-
Add to cart
-
+ */}
)}
diff --git a/src/components/chat/messages-list.tsx b/src/components/chat/messages-list.tsx
index 358e424..1be179b 100644
--- a/src/components/chat/messages-list.tsx
+++ b/src/components/chat/messages-list.tsx
@@ -23,7 +23,9 @@ const MessageList = ({ messages }) => {
}, [messages, loadingMessage]);
useEffect(() => {
- if (chatBoxRef.current && !(messages.length > 16)) {
+ if (chatBoxRef.current ) {
+ console.log("scrolling to bottom" , messages , messages.length , (messages.length > 16));
+
// Scroll to the bottom whenever allMessages change
chatBoxRef.current.scrollTop = chatBoxRef.current.scrollHeight;
}
@@ -31,7 +33,7 @@ const MessageList = ({ messages }) => {
useEffect(() => {
const handleScroll = () => {
- if (chatBoxRef.current && chatBoxRef.current.scrollTop === 0) {
+ if (chatBoxRef.current && (chatBoxRef.current.scrollTop === 0) && (messages.length >= 16)) {
getNextPage();
}
};
diff --git a/src/components/dashboard/admin.tsx b/src/components/dashboard/admin.tsx
index add17e9..add300e 100644
--- a/src/components/dashboard/admin.tsx
+++ b/src/components/dashboard/admin.tsx
@@ -66,7 +66,7 @@ export default function Dashboard() {
const [orderDataRange, setOrderDataRange] = useState(
data?.todayTotalOrderByStatus,
);
- const token = getAuthCredentials();
+ // const token = getAuthCredentials();
const { price: total_revenue } = usePrice(
diff --git a/src/components/layouts/topbar/message-bar.tsx b/src/components/layouts/topbar/message-bar.tsx
index b8a5152..e6e9a93 100644
--- a/src/components/layouts/topbar/message-bar.tsx
+++ b/src/components/layouts/topbar/message-bar.tsx
@@ -75,7 +75,7 @@ const MessageBar = ({ user }: IProps) => {
// here messages will be passed as a props in eventData. to keep the useEffect track of having a new message
return (
<>
-