Skip to content

Commit

Permalink
Merge pull request #54 from DFanso/pages/clientChat
Browse files Browse the repository at this point in the history
client side chat, input box text update
  • Loading branch information
DFanso authored Jan 5, 2024
2 parents 5a2c7a2 + 984cf18 commit acb36b9
Show file tree
Hide file tree
Showing 15 changed files with 281 additions and 64 deletions.
Binary file added client/public/images/chat-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added client/public/images/chat-3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added client/public/images/chat-4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added client/public/images/chat.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
67 changes: 31 additions & 36 deletions client/public/index.html
Original file line number Diff line number Diff line change
@@ -1,49 +1,43 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="icon" href="%PUBLIC_URL%/favicon.png" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<meta
name="description"
content="Web site created using create-react-app"
/>
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
<!--

<head>
<meta charset="utf-8" />
<link rel="icon" href="%PUBLIC_URL%/favicon.png" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<meta name="description" content="Web site created using create-react-app" />
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
<!--
manifest.json provides metadata used when your web app is installed on a
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
-->
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
<!--
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
<!--
Notice the use of %PUBLIC_URL% in the tags above.
It will be replaced with the URL of the `public` folder during the build.
Only files inside the `public` folder can be referenced from the HTML.
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link
href="https://fonts.googleapis.com/css2?family=Cinzel:wght@500&family=Inter:wght@300&family=Roboto&family=Roboto+Condensed&display=swap"
rel="stylesheet"
/>
<title>CINEMAGIC</title>
</head>
<body>
<script
type="module"
src="https://unpkg.com/ionicons@5.5.2/dist/ionicons/ionicons.esm.js"
></script>
<script
nomodule
src="https://unpkg.com/ionicons@5.5.2/dist/ionicons/ionicons.js"
></script>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
<!--
-->
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link
href="https://fonts.googleapis.com/css2?family=Cinzel:wght@500&family=Inter:wght@300&family=Roboto&family=Roboto+Condensed&display=swap"
rel="stylesheet" />
<link href="https://fonts.googleapis.com/css?family=Roboto:400,400i,700&display=swap" rel="stylesheet">

<title>CINEMAGIC</title>
</head>

<body>
<script type="module" src="https://unpkg.com/ionicons@5.5.2/dist/ionicons/ionicons.esm.js"></script>
<script nomodule src="https://unpkg.com/ionicons@5.5.2/dist/ionicons/ionicons.js"></script>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
<!--
This HTML file is a template.
If you open it directly in the browser, you will see an empty page.
Expand All @@ -53,5 +47,6 @@
To begin the development, run `npm start` or `yarn start`.
To create a production bundle, use `npm run build` or `yarn build`.
-->
</body>
</html>
</body>

</html>
15 changes: 14 additions & 1 deletion client/src/App.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
padding: 0;
font-family: 'Cinzel', serif;
}

.home,
.about,
.contact-page {
Expand All @@ -15,8 +16,20 @@
font-size: 100px;
}

.about-cover, .contact-cover {
.about-cover,
.contact-cover {
background-position: center;
background-size: cover;
background-repeat: no-repeat;
}



input,
textarea {
font-family: 'Roboto', sans-serif !important;
}

input:focus {
outline: none;
}
1 change: 1 addition & 0 deletions client/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import UserProfile from "./components/pages/UserProfile";
import NotFound from "./components/pages/NotFound";
import PaymentSuccess from "./components/pages/PaymentSuccess";
import PaymentCancel from "./components/pages/PaymentCancel";

import { useSelector } from "react-redux";

import { useDispatch } from "react-redux";
Expand Down
72 changes: 72 additions & 0 deletions client/src/components/Chat.js
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;
120 changes: 120 additions & 0 deletions client/src/components/css/Chat.css
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;
}
2 changes: 2 additions & 0 deletions client/src/components/pages/About.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from "react";
import "../css/About.css";
import Chat from "../Chat";

const About = () => {
return (
Expand Down Expand Up @@ -41,6 +42,7 @@ const About = () => {
</div>
</div>
</div>
<Chat />
</div>
);
};
Expand Down
2 changes: 2 additions & 0 deletions client/src/components/pages/Booking.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { Link, useParams } from "react-router-dom";
import axios from "axios";
import { useLoading } from "../LoadingContext.js";
import { TailSpin } from "react-loader-spinner";
import Chat from "../Chat";

const Booking = () => {
const { id } = useParams();
Expand Down Expand Up @@ -127,6 +128,7 @@ const Booking = () => {
</div>
</>
)}
<Chat />
</div>
);
};
Expand Down
3 changes: 3 additions & 0 deletions client/src/components/pages/Contact.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import axios from "axios";
import Swal from "sweetalert2";
import { TailSpin } from "react-loader-spinner";
import { useLoading } from "../LoadingContext.js";
import Chat from "../Chat";

const ContactPage = () => {
const { loading, setLoading } = useLoading();
const [formData, setFormData] = useState({
Expand Down Expand Up @@ -132,6 +134,7 @@ const ContactPage = () => {
</div>
</div>
</div>{" "}
<Chat />
</div>
);
};
Expand Down
2 changes: 2 additions & 0 deletions client/src/components/pages/Home.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@ import "../../App.css";
import Section from "../Section";
import Cards from "../Cards";
import SliderSection from "../SliderSection";
import Chat from "../Chat";

function Home() {
return (
<>
<Section />
<Cards />
<SliderSection />
<Chat />
</>
);
}
Expand Down
Loading

0 comments on commit acb36b9

Please sign in to comment.