-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added new page and static insight component
- Loading branch information
1 parent
9ae16b4
commit cfa9adf
Showing
4 changed files
with
111 additions
and
1 deletion.
There are no files selected for viewing
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 |
---|---|---|
|
@@ -27,6 +27,7 @@ yarn-error.log* | |
|
||
# local env files | ||
.env*.local | ||
.env | ||
|
||
# vercel | ||
.vercel | ||
|
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,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<Boolean>(false); | ||
const { messages, input, handleInputChange, handleSubmit } = useChat(); | ||
|
||
return ( | ||
<div> | ||
<NavBar /> | ||
<div | ||
style={{height: '70vh', flexDirection: "column-reverse", display: "flex" }} | ||
> | ||
<> | ||
{waitingForAI && | ||
( | ||
<div className="loading"> | ||
<img src='/1484.gif' alt="Loading"></img> | ||
</div> | ||
)} | ||
</> | ||
<> | ||
{messages.length == 0 && | ||
( | ||
<div style={{ display: 'flex', flexDirection: 'row', alignItems: 'center', justifyContent: 'center' }}> | ||
<img style={{ width: "25%", marginBottom: "2%" }} src='/singlestore_white.svg' alt="SingleStore Logo" /> | ||
<span style={{ marginBottom: '2%', fontSize: '40px', justifySelf: 'center' }}>+</span> | ||
<img style={{ width: "8%", marginBottom: "2%" }} src='/openAI.svg' alt="OpenAI Logo" /> | ||
</div> | ||
) | ||
} | ||
</> | ||
<div className="pr-4 messages"> | ||
{messages.map(m => ( | ||
<div key={m.id}> | ||
<div className="flex gap-3 my-4 text-gray-600 text-sm flex-1"> | ||
<span className="relative flex shrink-0 overflow-hidden rounded-full w-8 h-8" | ||
style={{ margin: '30px', marginTop: '0px' }}> | ||
<div className="rounded-full bg-gray-100 border p-1"> | ||
{m.role === 'user' ? ( | ||
<img src="/user.png" alt="User" /> | ||
) : ( | ||
<img src="/bot.png" alt="Bot" /> | ||
)} | ||
</div> | ||
</span> | ||
<p className="leading-relaxed" style={{ color: 'aliceblue' }}> | ||
<span className="block font-bold">{m.role}</span> | ||
{m.content} | ||
</p> | ||
</div> | ||
{m.role === 'assistant' && <InsightCard />} | ||
</div> | ||
))} | ||
</div> | ||
|
||
<div className="flex items-center pt-0 chat-window"> | ||
<form className="flex items-center justify-center w-full space-x-2" onSubmit={handleSubmit}> | ||
<input | ||
value={input} | ||
onChange={handleInputChange} | ||
className="flex h-10 w-full rounded-md border border-[#e5e7eb] px-3 py-2 text-sm placeholder-[#6b7280] focus:outline-none focus:ring-2 focus:ring-[#9ca3af] disabled:cursor-not-allowed disabled:opacity-50 text-[#030712] focus-visible:ring-offset-2" | ||
placeholder="Ask what you have in mind" | ||
/> | ||
<button | ||
type="submit" | ||
className="inline-flex items-center justify-center rounded-md text-sm font-medium text-[#f9fafb] disabled:pointer-events-none disabled:opacity-50 bg-black hover:bg-[#111827E6] h-10 px-4 py-2" | ||
> | ||
Send | ||
</button> | ||
</form> | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
} |
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,29 @@ | ||
import React from 'react'; | ||
|
||
const InsightCard: React.FC = () => ( | ||
<div className="bg-purple-600 p-4 rounded-lg mt-2 text-sm max-w-[500px]"> | ||
<h3 className="font-bold mb-2 text-left">Insight Summary</h3> | ||
<p>Number of tickets opened for the issue: 12</p> | ||
<p>Average time to respond to the tickets: 4 min</p> | ||
<div className="flex items-center"> | ||
<p className="mr-2">Total number of customers affected:</p> | ||
<svg width="50" height="50" viewBox="0 0 50 50"> | ||
<circle cx="25" cy="25" r="25" fill="#3B82F6" /> {/* Blue background */} | ||
<path | ||
d="M25 25 L25 0 A25 25 0 0 1 48.3 32.7 Z" | ||
fill="#10B981" // Green slice | ||
/> | ||
<text x="25" y="28" textAnchor="middle" fill="white" fontSize="10"> | ||
12/521 | ||
</text> | ||
</svg> | ||
</div> | ||
<p>Rev across affected customers 📊: $3.2 Million</p> | ||
<div className="flex items-center"> | ||
<p className="mr-2">Sentiment of affected customers:</p> | ||
<div className="w-4 h-4 rounded-full bg-yellow-400"></div> | ||
</div> | ||
</div> | ||
); | ||
|
||
export default InsightCard; |
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