diff --git a/mobile-magic/apps/frontend/app/project/[projectId]/page.tsx b/mobile-magic/apps/frontend/app/project/[projectId]/page.tsx index b8d4ac2..bcaafe9 100644 --- a/mobile-magic/apps/frontend/app/project/[projectId]/page.tsx +++ b/mobile-magic/apps/frontend/app/project/[projectId]/page.tsx @@ -1,9 +1,9 @@ "use client"; import { Button } from "@/components/ui/button"; -import { Input } from "@/components/ui/input"; + import { WORKER_URL } from "@/config"; -import { Send } from "lucide-react"; +import { Check, ClipboardCopy, Paperclip, Send } from "lucide-react"; import { usePrompts } from "@/hooks/usePrompts"; import { useActions } from "@/hooks/useActions"; import axios from "axios"; @@ -12,75 +12,130 @@ import { useAuth, useUser } from "@clerk/nextjs"; import { WORKER_API_URL } from "@/config"; import { ProjectsDrawer } from "@/components/ProjectsDrawer"; import Image from "next/image"; +import { ScrollArea } from "@/components/ui/scroll-area"; +import { Textarea } from "@/components/ui/textarea"; +interface Action { + id: string; + content?: string; + code?: string; +} export default function ProjectPage({ params }: { params: { projectId: string } }) { const { prompts } = usePrompts(params.projectId); const { actions } = useActions(params.projectId); const [prompt, setPrompt] = useState(""); const { getToken } = useAuth(); - const {user} = useUser() + const { user } = useUser() + const [copied, setCopied] = useState(null); const submitPrompt = async () => { - const token = await getToken(); - axios.post( - `${WORKER_API_URL}/prompt`, - { - projectId: params.projectId, - prompt: prompt, - }, - { - headers: { - Authorization: `Bearer ${token}`, - }, - }, - ); - setPrompt(""); - }; + const token = await getToken(); + axios.post( + `${WORKER_API_URL}/prompt`, + { + projectId: params.projectId, + prompt: prompt, + }, + { + headers: { + Authorization: `Bearer ${token}`, + }, + }, + ); + setPrompt(""); + }; + + const copyToClipboard = (text: string, id: string) => { + navigator.clipboard.writeText(text); + setCopied(id); + setTimeout(() => setCopied(null), 2000); + }; + + return ( +
+
+
+ Chat History +
+
+ +
+ {prompts.filter((prompt) => prompt.type === "USER").map((prompt, index) => ( +
+
+ Profile picture + {prompt.content} +
+ + {actions[index] && ( +
+
+
{actions[index]?.content}
- return
-
-
-
- -
-
- {prompts.filter((prompt) => prompt.type === "USER").map((prompt) => ( - - Profile picture - {prompt.content} - + {('code' in actions[index] && actions[index]?.code) && ( +
+ +
+                                                                
+                                                                    {String(actions[index].code || "")}
+                                                                
+                                                            
+ + + +
+ )} +
+
+ )} +
))} -
- {actions.map((action) => ( -
- {action.content} -
- ))} +
+ +
+
+
+