From cfa9adfbe7d1a9e568f4069753d93d18960905a1 Mon Sep 17 00:00:00 2001 From: Madhukar Kumar Date: Thu, 15 Aug 2024 14:32:57 -0700 Subject: [PATCH] New Insight pages Added new page and static insight component --- .gitignore | 1 + src/app/askinsights/page.tsx | 80 +++++++++++++++++++++++++++++++ src/app/component/InsightCard.tsx | 29 +++++++++++ src/app/component/navbar.tsx | 2 +- 4 files changed, 111 insertions(+), 1 deletion(-) create mode 100644 src/app/askinsights/page.tsx create mode 100644 src/app/component/InsightCard.tsx diff --git a/.gitignore b/.gitignore index fd3dbb5..00bba9b 100644 --- a/.gitignore +++ b/.gitignore @@ -27,6 +27,7 @@ yarn-error.log* # local env files .env*.local +.env # vercel .vercel diff --git a/src/app/askinsights/page.tsx b/src/app/askinsights/page.tsx new file mode 100644 index 0000000..700db98 --- /dev/null +++ b/src/app/askinsights/page.tsx @@ -0,0 +1,80 @@ +'use client'; + +import { useChat } from 'ai/react'; +import { useState } from 'react'; +import NavBar from '../component/navbar'; +import InsightCard from '../component/InsightCard'; + +export default function Home() { + const [waitingForAI, setWaitingForAI] = useState(false); + const { messages, input, handleInputChange, handleSubmit } = useChat(); + + return ( +
+ +
+ <> + {waitingForAI && + ( +
+ Loading +
+ )} + + <> + {messages.length == 0 && + ( +
+ SingleStore Logo + + + OpenAI Logo +
+ ) + } + +
+ {messages.map(m => ( +
+
+ +
+ {m.role === 'user' ? ( + User + ) : ( + Bot + )} +
+
+

+ {m.role} + {m.content} +

+
+ {m.role === 'assistant' && } +
+ ))} +
+ +
+
+ + +
+
+
+
+ ); +} diff --git a/src/app/component/InsightCard.tsx b/src/app/component/InsightCard.tsx new file mode 100644 index 0000000..52d223f --- /dev/null +++ b/src/app/component/InsightCard.tsx @@ -0,0 +1,29 @@ +import React from 'react'; + +const InsightCard: React.FC = () => ( +
+

Insight Summary

+

Number of tickets opened for the issue: 12

+

Average time to respond to the tickets: 4 min

+
+

Total number of customers affected:

+ + {/* Blue background */} + + + 12/521 + + +
+

Rev across affected customers 📊: $3.2 Million

+
+

Sentiment of affected customers:

+
+
+
+); + +export default InsightCard; \ No newline at end of file diff --git a/src/app/component/navbar.tsx b/src/app/component/navbar.tsx index ce88966..f483d7b 100644 --- a/src/app/component/navbar.tsx +++ b/src/app/component/navbar.tsx @@ -4,7 +4,7 @@ import Link from 'next/link'; const NavBar: React.FC = () => { return ( -