Skip to content

Commit

Permalink
Merge pull request #41 from Batsave/dev
Browse files Browse the repository at this point in the history
Refactor Chatbot component and add prop type validation
  • Loading branch information
Batsave authored Jan 19, 2024
2 parents 4179a5e + e03dff8 commit 1b214c7
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions frontend/src/pages/Chatbot.jsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import React, { useState, useEffect, useRef } from "react";
import io from "socket.io-client";
import "../scss/chatbot.scss";

/* eslint-disable */
import PropTypes from "prop-types";

const socket = io(import.meta.env.VITE_BACKEND_URL);
export default function Chatbot({ isVisible }) {
const [messages, setMessages] = useState([]);
const [currentMessage, setCurrentMessage] = useState("");
const [isTyping, setIsTyping] = useState(false);
const [isTyping] = useState(false);
const [hasInitiated, setHasInitiated] = useState(false);
const messagesEndRef = useRef(null);

Expand Down Expand Up @@ -56,7 +55,7 @@ export default function Chatbot({ isVisible }) {
<div className="message-area">
{messages.map((message, index) => (
<div
key={index}
key={index.id}
className={`message ${
message.author === "user" ? "user-message" : "bot-message"
}`}
Expand Down Expand Up @@ -96,3 +95,7 @@ export default function Chatbot({ isVisible }) {
</div>
);
}

Chatbot.propTypes = {
isVisible: PropTypes.bool.isRequired,
};

0 comments on commit 1b214c7

Please sign in to comment.