adbcc4b9af
feat: implement conversations API with message retrieval and posting feat: add avatar URL handling for users and update user role definitions feat: create chat system tables in the database with initial seed data fix: update user roles from "sales_user" to "sales" for consistency chore: add middleware for system API route access fixed fuckups on john's side, added a benchmark Made Graphs actualy load from database and realtime data, graphs will update and percentages will be mathematically made, and made realtime added chatcart edits, made graphs glow. added in some little small home feeling fuctions added in a slide show, in login with qoutes from creators because i want to leave a print on it saying we made this shit, we built it brick for brick login page added qoutes some random, and made them shuffle from left to right one dissapears other come in adding shape to the textbox for the qoutes Fixed my chat fuckups when it comes to chats
69 lines
2.0 KiB
TypeScript
69 lines
2.0 KiB
TypeScript
"use client"
|
|
|
|
import { useState } from "react"
|
|
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"
|
|
import { Button } from "@/components/ui/button"
|
|
import { Textarea } from "@/components/ui/textarea"
|
|
import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar"
|
|
import { Send } from "lucide-react"
|
|
|
|
interface NoteFormProps {
|
|
leadId: string
|
|
}
|
|
|
|
export function NoteForm({ leadId }: NoteFormProps) {
|
|
const [note, setNote] = useState("")
|
|
const [submitting, setSubmitting] = useState(false)
|
|
|
|
const handleSubmit = async () => {
|
|
if (!note.trim()) return
|
|
setSubmitting(true)
|
|
try {
|
|
await fetch(`/api/leads/${leadId}/notes`, {
|
|
method: "POST",
|
|
headers: { "Content-Type": "application/json" },
|
|
body: JSON.stringify({ content: note }),
|
|
})
|
|
setNote("")
|
|
window.location.reload()
|
|
} catch {
|
|
// ignore
|
|
}
|
|
setSubmitting(false)
|
|
}
|
|
|
|
return (
|
|
<Card>
|
|
<CardHeader>
|
|
<CardTitle>Add Note</CardTitle>
|
|
</CardHeader>
|
|
<CardContent>
|
|
<div className="flex gap-4">
|
|
<Avatar className="h-10 w-10 shrink-0">
|
|
<AvatarImage src="https://ui-avatars.com/api/?name=Sarah+Chen&background=1d4ed8&color=fff&size=64" />
|
|
<AvatarFallback>SC</AvatarFallback>
|
|
</Avatar>
|
|
<div className="flex-1 space-y-3">
|
|
<Textarea
|
|
placeholder="Write a note about this lead..."
|
|
value={note}
|
|
onChange={(e) => setNote(e.target.value)}
|
|
className="min-h-[100px] resize-none"
|
|
/>
|
|
<div className="flex justify-end">
|
|
<Button
|
|
onClick={handleSubmit}
|
|
disabled={!note.trim() || submitting}
|
|
className="gap-2"
|
|
>
|
|
<Send className="h-4 w-4" />
|
|
{submitting ? "Adding..." : "Add Note"}
|
|
</Button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</CardContent>
|
|
</Card>
|
|
)
|
|
}
|