Skip to content

Commit 49b17a5

Browse files
committed
Add chat message some design and make a pop up on chat page
1 parent 45cfef6 commit 49b17a5

File tree

3 files changed

+43
-16
lines changed

3 files changed

+43
-16
lines changed
Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,24 @@
11
import React from "react";
2+
import Image from "next/image";
3+
import CategoriesDropdown from "@/app/components/my_account_components/CategoriesDropdown";
24

35
const CategoriesAndGenderDetailsPopup = () => {
4-
return <div></div>;
6+
return (
7+
<div className="absolute flex flex-col bg-white rounded p-4">
8+
<div className="flex justify-around">
9+
<Image src="/female.png" height={20} width={20} alt="profile-picture" />
10+
<Image src="/male.png" height={20} width={20} alt="profile-picture" />
11+
<Image
12+
src="/both_gender.png"
13+
height={20}
14+
width={20}
15+
alt="profile-picture"
16+
/>
17+
</div>
18+
<CategoriesDropdown category="Interest" />
19+
<CategoriesDropdown category="Location" />
20+
</div>
21+
);
522
};
623

724
export default CategoriesAndGenderDetailsPopup;

app/voyager/random_chat/page.tsx

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
"use client"
1+
"use client";
22

33
import { useState, useEffect } from "react";
44
import Sidebar from "@/app/components/random_chat_components/Sidebar";
5+
import CategoriesAndGenderDetailsPopup from "@/app/components/random_chat_components/CategoriesAndGenderDetailsPopup";
56

67
const RandomChat = () => {
78
const [inputMessage, setInputMessage] = useState<string>("");
@@ -25,13 +26,15 @@ const RandomChat = () => {
2526
return () => {
2627
newSocket.close();
2728
};
29+
// eslint-disable-next-line
2830
}, []); // Only runs once when the component mounts
2931

3032
function sendMessage(event: React.KeyboardEvent<HTMLInputElement>) {
3133
if (
3234
event.key === "Enter" &&
3335
socket &&
34-
socket.readyState === WebSocket.OPEN
36+
socket.readyState === WebSocket.OPEN &&
37+
inputMessage.length >=1
3538
) {
3639
// Send the message
3740
socket.send(JSON.stringify({ content: inputMessage }));
@@ -48,23 +51,30 @@ const RandomChat = () => {
4851
return (
4952
<div className="flex w-full h-full">
5053
<Sidebar />
51-
<div className="flex h-[100vh] w-full ml-[25%] bg-[#393E46]">
54+
<div className="flex flex-col justify-between h-[100vh] w-full ml-[25%] bg-[#393E46]">
55+
{chatMessages.length <= 0 && <CategoriesAndGenderDetailsPopup />}
5256
<div className="bg-blue text-white p-2">
5357
{chatMessages.map((message, index) => (
54-
<div key={index}>{message}</div>
58+
<div
59+
key={index}
60+
className="bg-white rounded-l-full rounded-r-full px-3 py-1 text-black max-w-fit mb-3"
61+
>
62+
{message}
63+
</div>
5564
))}
5665
</div>
57-
58-
<div className="w-[90%] self-end mx-auto mb-5">
59-
<input
60-
type="text"
61-
id="default-input"
62-
className="text-gray-50 text-sm rounded-lg block p-2.5 w-full bg-gray-500 outline-none"
63-
placeholder="Enter text here..."
64-
value={inputMessage}
65-
onChange={handleMessageChange}
66-
onKeyDown={sendMessage}
67-
/>
66+
<div className="w-full">
67+
<div className="w-[95%] mx-auto mb-4">
68+
<input
69+
type="text"
70+
id="default-input"
71+
className="text-gray-50 text-sm rounded-lg block p-2.5 w-full bg-gray-500 outline-none"
72+
placeholder="Enter text here..."
73+
value={inputMessage}
74+
onChange={handleMessageChange}
75+
onKeyDown={sendMessage}
76+
/>
77+
</div>
6878
</div>
6979
</div>
7080
</div>

public/both_gender.png

6.24 KB
Loading

0 commit comments

Comments
 (0)