Browse Source
feat: update development server port, adjust chat component styles, and add new SVG icons
master
feat: update development server port, adjust chat component styles, and add new SVG icons
master
sina_sajjadi
2 weeks ago
20 changed files with 2247 additions and 88 deletions
-
2next.config.js
-
2package.json
-
2055public/image/Frame-48098164.svg
-
3public/image/face-smile.svg
-
3public/image/icon-park-outline_link.svg
-
4public/image/link-simple.svg
-
3public/image/microphone-01.svg
-
3public/image/send-01.svg
-
10src/components/chat/chat-input.tsx
-
80src/components/chat/file-input.tsx
-
6src/components/chat/file-message.tsx
-
99src/components/chat/message.tsx
-
2src/components/chat/messages-list.tsx
-
2src/components/product/form-utils.ts
-
18src/contexts/WebSocket.context.tsx
-
2src/data/client/user.ts
-
2src/data/shop.ts
-
6src/pages/chat/chat-box.tsx
-
2src/pages/chat/converstions.tsx
-
27src/pages/shop/index.tsx
2055
public/image/Frame-48098164.svg
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
@ -0,0 +1,3 @@ |
|||||
|
<svg width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg"> |
||||
|
<path d="M10.667 18.667C10.667 18.667 12.667 21.3337 16.0003 21.3337C19.3337 21.3337 21.3337 18.667 21.3337 18.667M20.0003 12.0003H20.0137M12.0003 12.0003H12.0137M29.3337 16.0003C29.3337 23.3641 23.3641 29.3337 16.0003 29.3337C8.63653 29.3337 2.66699 23.3641 2.66699 16.0003C2.66699 8.63653 8.63653 2.66699 16.0003 2.66699C23.3641 2.66699 29.3337 8.63653 29.3337 16.0003ZM20.667 12.0003C20.667 12.3685 20.3685 12.667 20.0003 12.667C19.6321 12.667 19.3337 12.3685 19.3337 12.0003C19.3337 11.6321 19.6321 11.3337 20.0003 11.3337C20.3685 11.3337 20.667 11.6321 20.667 12.0003ZM12.667 12.0003C12.667 12.3685 12.3685 12.667 12.0003 12.667C11.6321 12.667 11.3337 12.3685 11.3337 12.0003C11.3337 11.6321 11.6321 11.3337 12.0003 11.3337C12.3685 11.3337 12.667 11.6321 12.667 12.0003Z" stroke="#363636" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/> |
||||
|
</svg> |
@ -0,0 +1,3 @@ |
|||||
|
<svg width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg"> |
||||
|
<path d="M16.4718 6.37661L6.57248 16.2766C5.44745 17.4018 4.81543 18.9278 4.81543 20.5189C4.81543 22.1101 5.44745 23.6361 6.57248 24.7613C7.12963 25.3184 7.79107 25.7604 8.51903 26.0619C9.24699 26.3635 10.0272 26.5187 10.8151 26.5187C11.6031 26.5187 12.3833 26.3635 13.1113 26.0619C13.8392 25.7604 14.5007 25.3184 15.0578 24.7613L26.8431 12.9766C27.2147 12.6052 27.5094 12.1642 27.7104 11.6788C27.9115 11.1935 28.015 10.6733 28.015 10.1479C28.015 9.6226 27.9115 9.1024 27.7104 8.61705C27.5094 8.1317 27.2147 7.69072 26.8431 7.31927C26.4717 6.94777 26.0307 6.65307 25.5454 6.45201C25.06 6.25095 24.5398 6.14746 24.0145 6.14746C23.4891 6.14746 22.9689 6.25095 22.4836 6.45201C21.9982 6.65307 21.5573 6.94777 21.1858 7.31927L9.40115 19.1046C9.2154 19.2903 9.06805 19.5108 8.96752 19.7535C8.86699 19.9962 8.81524 20.2563 8.81524 20.5189C8.81524 20.7816 8.86699 21.0417 8.96752 21.2844C9.06805 21.5271 9.2154 21.7476 9.40115 21.9333C9.7762 22.3082 10.2848 22.5188 10.8151 22.5188C11.3455 22.5188 11.8541 22.3082 12.2291 21.9333L22.1291 12.0333" stroke="#212121" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/> |
||||
|
</svg> |
@ -0,0 +1,4 @@ |
|||||
|
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"> |
||||
|
<path d="M9.17177 14.8286L14.8286 9.17177M6.34334 10.586L4.57557 12.3537C2.62295 14.3064 2.62295 17.4722 4.57557 19.4248V19.4248C6.52819 21.3774 9.69402 21.3774 11.6466 19.4248L13.4144 17.657M10.586 6.34334L12.3537 4.57557C14.3064 2.62295 17.4722 2.62295 19.4248 4.57557V4.57557C21.3774 6.5282 21.3774 9.69402 19.4248 11.6466L17.657 13.4144" stroke="#222222" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/> |
||||
|
<path d="M9.17177 14.8286L14.8286 9.17177M6.34334 10.586L4.57557 12.3537C2.62295 14.3064 2.62295 17.4722 4.57557 19.4248V19.4248C6.52819 21.3774 9.69402 21.3774 11.6466 19.4248L13.4144 17.657M10.586 6.34334L12.3537 4.57557C14.3064 2.62295 17.4722 2.62295 19.4248 4.57557V4.57557C21.3774 6.5282 21.3774 9.69402 19.4248 11.6466L17.657 13.4144" stroke="#222222" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/> |
||||
|
</svg> |
@ -0,0 +1,3 @@ |
|||||
|
<svg width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg"> |
||||
|
<path d="M25.3337 13.3337V16.0003C25.3337 21.155 21.155 25.3337 16.0003 25.3337M6.66699 13.3337V16.0003C6.66699 21.155 10.8457 25.3337 16.0003 25.3337M16.0003 25.3337V29.3337M10.667 29.3337H21.3337M16.0003 20.0003C13.7912 20.0003 12.0003 18.2095 12.0003 16.0003V6.66699C12.0003 4.45785 13.7912 2.66699 16.0003 2.66699C18.2095 2.66699 20.0003 4.45785 20.0003 6.66699V16.0003C20.0003 18.2095 18.2095 20.0003 16.0003 20.0003Z" stroke="black" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/> |
||||
|
</svg> |
@ -0,0 +1,3 @@ |
|||||
|
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"> |
||||
|
<path d="M7 12L4.83771 17.7661C4.52632 18.5965 5.36976 19.3912 6.18018 19.031L19.9439 12.9138C20.7357 12.5619 20.7357 11.4381 19.9439 11.0862L6.18018 4.96897C5.36976 4.60878 4.52632 5.40351 4.83771 6.2339L7 12ZM7 12H13" stroke="black" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/> |
||||
|
</svg> |
@ -0,0 +1,80 @@ |
|||||
|
import { useWebSocket } from "@/contexts/WebSocket.context"; |
||||
|
import Image from "next/image"; |
||||
|
import FaPlus from "public/image/icon-park-outline_link.svg"; |
||||
|
import { useEffect, useState } from "react"; |
||||
|
import { toast } from "react-toastify"; // Import toast from react-toastify
|
||||
|
import "react-toastify/dist/ReactToastify.css"; // Import CSS for toast
|
||||
|
|
||||
|
// Define the allowed image, video, and audio extensions
|
||||
|
const IMAGE_EXTENSIONS = ["jpg", "jpeg", "png", "gif", "bmp", "tiff", "webp", "svg"]; |
||||
|
const VIDEO_EXTENSIONS = ["mp4", "mkv", "webm", "avi", "mov", "flv", "wmv"]; |
||||
|
const AUDIO_EXTENSIONS = ["mp3", "wav", "ogg", "flac", "aac", "m4a"]; |
||||
|
|
||||
|
const getFileType = (extension : string) => { |
||||
|
const ext = extension.toLowerCase(); |
||||
|
|
||||
|
// Check if it's an image
|
||||
|
if (IMAGE_EXTENSIONS.includes(ext)) { |
||||
|
return "image"; |
||||
|
} |
||||
|
|
||||
|
// Check if it's a video
|
||||
|
if (VIDEO_EXTENSIONS.includes(ext)) { |
||||
|
return "video"; |
||||
|
} |
||||
|
|
||||
|
// Check if it's an audio file
|
||||
|
if (AUDIO_EXTENSIONS.includes(ext)) { |
||||
|
return "audio"; |
||||
|
} |
||||
|
|
||||
|
// Everything else is a generic file
|
||||
|
return "file"; |
||||
|
}; |
||||
|
|
||||
|
const FileInput = () => { |
||||
|
const {setLoadingMessage} = useWebSocket() |
||||
|
const { sendFile } = useWebSocket(); |
||||
|
const [file, setFile] = useState(null); // To store the selected file
|
||||
|
|
||||
|
const MAX_FILE_SIZE = 300 * 1024 * 1024; // 300 MB in bytes
|
||||
|
|
||||
|
const handleFileChange = async (event : any) => { |
||||
|
const selectedFile = event.target.files[0]; |
||||
|
|
||||
|
if (selectedFile) { |
||||
|
// Check file size
|
||||
|
if (selectedFile.size > MAX_FILE_SIZE) { |
||||
|
toast.error("File is too large. Please select a file smaller than 300 MB."); |
||||
|
return; // Prevent further processing if the file is too large
|
||||
|
} |
||||
|
selectedFile.status = "loading" |
||||
|
setLoadingMessage((prev) => [...prev, selectedFile]); |
||||
|
|
||||
|
} |
||||
|
}; |
||||
|
|
||||
|
// Send the file when it's available
|
||||
|
|
||||
|
|
||||
|
return ( |
||||
|
<div> |
||||
|
{/* Hidden file input */} |
||||
|
<input |
||||
|
id="file-input" |
||||
|
type="file" |
||||
|
className="hidden" |
||||
|
onChange={handleFileChange} // Handle file change
|
||||
|
/> |
||||
|
{/* Label triggers the file input */} |
||||
|
<label |
||||
|
htmlFor="file-input" // This associates the label with the file input
|
||||
|
className="text-white px-3 py-2 rounded-md transition flex content-center hover:bg-slate-100" |
||||
|
> |
||||
|
<Image width={25} height={25} src={FaPlus} /> |
||||
|
</label> |
||||
|
</div> |
||||
|
); |
||||
|
}; |
||||
|
|
||||
|
export default FileInput; |
Write
Preview
Loading…
Cancel
Save
Reference in new issue