diff --git a/raggr-frontend/src/.App.tsx.swp b/raggr-frontend/src/.App.tsx.swp
index 5462516..421db95 100644
Binary files a/raggr-frontend/src/.App.tsx.swp and b/raggr-frontend/src/.App.tsx.swp differ
diff --git a/raggr-frontend/src/App.tsx b/raggr-frontend/src/App.tsx
index f335937..1bbb1dc 100644
--- a/raggr-frontend/src/App.tsx
+++ b/raggr-frontend/src/App.tsx
@@ -4,83 +4,147 @@ import ReactMarkdown from "react-markdown";
import "./App.css";
+type QuestionAnswer = {
+ question: string;
+ answer: string;
+};
+
+type QuestionBubbleProps = {
+ text: string;
+};
+
+type AnswerBubbleProps = {
+ text: string;
+ loading: string;
+};
+
+type QuestionAnswerPairProps = {
+ question: string;
+ answer: string;
+ loading: boolean;
+};
+
+const QuestionBubble = ({ text }: QuestionBubbleProps) => {
+ return
🤦: {text}
;
+};
+
+const AnswerBubble = ({ text, loading }: AnswerBubbleProps) => {
+ return (
+
+ {loading ? (
+
+ ) : (
+
+ {"🐈: " + text}
+
+ )}
+
+ );
+};
+
+const QuestionAnswerPair = ({
+ question,
+ answer,
+ loading,
+}: QuestionAnswerPairProps) => {
+ return (
+
+ );
+};
+
const App = () => {
const [query, setQuery] = useState("");
const [answer, setAnswer] = useState("");
- const [loading, setLoading] = useState(false);
const [simbaMode, setSimbaMode] = useState(false);
+ const [questionsAnswers, setQuestionsAnswers] = useState(
+ []
+ );
const simbaAnswers = ["meow.", "hiss...", "purrrrrr", "yowOWROWWowowr"];
const handleQuestionSubmit = () => {
if (simbaMode) {
console.log("simba mode activated");
- setLoading(true);
const randomIndex = Math.floor(Math.random() * simbaAnswers.length);
const randomElement = simbaAnswers[randomIndex];
setAnswer(randomElement);
- setTimeout(() => setLoading(false), 3500);
+ setQuestionsAnswers(
+ questionsAnswers.concat([
+ {
+ question: query,
+ answer: randomElement,
+ },
+ ])
+ );
return;
}
const payload = { query: query };
- setLoading(true);
axios
.post("/api/query", payload)
- .then((result) => setAnswer(result.data.response))
- .finally(() => setLoading(false));
+ .then((result) =>
+ setQuestionsAnswers(
+ questionsAnswers.concat([
+ { question: query, answer: result.data.response },
+ ])
+ )
+ );
};
const handleQueryChange = (event) => {
setQuery(event.target.value);
};
return (
-
+
ask simba!
-
-
-
-
-
-
-
- setSimbaMode(event.target.checked)
- }
- />
-
simba mode?
-
- {loading ? (
-