-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #54 from DFanso/pages/clientChat
client side chat, input box text update
- Loading branch information
Showing
15 changed files
with
281 additions
and
64 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
import React, { useState } from 'react'; | ||
import './css/Chat.css'; // Path to CSS file | ||
|
||
const Chat = () => { | ||
const [isOpen, setIsOpen] = useState(false); | ||
const [messages, setMessages] = useState([]); | ||
const [input, setInput] = useState(''); | ||
|
||
const sendMessage = (event) => { | ||
event.preventDefault(); | ||
if (input.trim()) { | ||
setMessages([...messages, { text: input, sender: 'client' }]); | ||
setInput(''); | ||
} | ||
}; | ||
|
||
const toggleChat = () => { | ||
setIsOpen(!isOpen); | ||
}; | ||
|
||
const faqs = [ | ||
"What are the opening hours?", | ||
"How to book a ticket?", | ||
"Are there any discounts available?", | ||
// ... more FAQs | ||
]; | ||
|
||
const sendFaqMessage = (faq) => { | ||
setMessages([...messages, { text: faq, sender: 'client' }]); | ||
}; | ||
|
||
return ( | ||
<div className="chat-container"> | ||
{isOpen && ( | ||
<div className="chat-interface"> | ||
<div className="chat-header"> | ||
CINEMAGIC | ||
</div> | ||
<div className="faq-container"> | ||
{faqs.map((faq, index) => ( | ||
<div key={index} className="faq" onClick={() => sendFaqMessage(faq)}> | ||
{faq} | ||
</div> | ||
))} | ||
</div> | ||
<div className="chat-messages"> | ||
{messages.map((message, index) => ( | ||
<div key={index} className={`message ${message.sender}`}> | ||
<span className="message-text">{message.text}</span> | ||
</div> | ||
))} | ||
</div> | ||
<form onSubmit={sendMessage} className="message-input-container"> | ||
<input | ||
type="text" | ||
className="message-input" | ||
value={input} | ||
onChange={(e) => setInput(e.target.value)} | ||
placeholder="Type a message..." | ||
/> | ||
<button type="submit" className="send-button">Send</button> | ||
</form> | ||
</div> | ||
)} | ||
<button className="chat-toggle" onClick={toggleChat}> | ||
<img src="/images/chat-3.png" alt="Chat" className='chat-icon' /> | ||
</button> | ||
</div> | ||
); | ||
}; | ||
|
||
export default Chat; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
.chat-container { | ||
position: fixed; | ||
bottom: 0; | ||
right: 0; | ||
z-index: 1001; | ||
margin: 0; | ||
padding: 0; | ||
} | ||
|
||
.chat-interface { | ||
position: fixed; | ||
bottom: 100px; | ||
right: 20px; | ||
width: 300px; | ||
height: 400px; | ||
background-color: #525252; | ||
border-radius: 15px; | ||
box-shadow: 0px 4px 6px rgba(0, 0, 0, 0.1); | ||
display: flex; | ||
flex-direction: column; | ||
justify-content: space-between; | ||
padding: 15px 10px; | ||
z-index: 2; | ||
overflow: hidden; | ||
} | ||
|
||
.chat-header { | ||
background-color: #ffd700; | ||
color: #333; | ||
text-align: center; | ||
padding: 10px; | ||
border-radius: 15px 15px 0 0; | ||
} | ||
|
||
.faq-container { | ||
overflow-y: auto; | ||
flex-grow: 1; | ||
margin-top: 10px; | ||
} | ||
|
||
.faq { | ||
padding: 8px; | ||
margin: 10px 0; | ||
background-color: none; | ||
border: 1px solid #ffd700; | ||
border-radius: 5px; | ||
cursor: pointer; | ||
font-size: 14px; | ||
color: #ffd700; | ||
} | ||
|
||
.faq:hover { | ||
background-color: #ffd700; | ||
color: #525252; | ||
transition: 0.5s; | ||
} | ||
|
||
.chat-messages { | ||
overflow-y: auto; | ||
flex-grow: 1; | ||
} | ||
|
||
.message { | ||
margin: 5px 0; | ||
padding: 8px 12px; | ||
background-color: #007bff; | ||
color: white; | ||
border-radius: 15px; | ||
max-width: 80%; | ||
align-self: flex-end; | ||
} | ||
|
||
.message.admin { | ||
background-color: #f1f0f0; | ||
color: black; | ||
align-self: flex-start; | ||
} | ||
|
||
.message-input-container { | ||
display: flex; | ||
} | ||
|
||
.message-input { | ||
flex-grow: 1; | ||
border-radius: 15px; | ||
padding: 10px; | ||
border: 1px solid #ddd; | ||
} | ||
|
||
.send-button { | ||
background-color: #ffd700; | ||
color: #333; | ||
border: none; | ||
padding: 10px 15px; | ||
margin-left: 5px; | ||
border-radius: 15px; | ||
|
||
} | ||
|
||
.chat-toggle { | ||
position: fixed; | ||
bottom: 20px; | ||
right: 20px; | ||
background-color: #ffd700; | ||
width: 50px; | ||
height: 50px; | ||
border: none; | ||
border-radius: 50%; | ||
box-shadow: 0px 4px 6px rgba(0, 0, 0, 0.1); | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
cursor: pointer; | ||
z-index: 3; | ||
} | ||
|
||
.chat-icon { | ||
width: 40px; | ||
height: 40px; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.