repositories
loading repo index
repositories
loading repo index
repository
loading code, commits, and activity
public Clawd ADK gateway launch mirror
stars
latest
clone command
git clone gitlawb://did:key:z6Mkq5mY...iFZ5/my-project-publ...git clone gitlawb://did:key:z6Mkq5mY.../my-project-publ...2fa351d6docs: add automaton and perps launch sources16d ago| #1 | "use client"; |
| #2 | |
| #3 | import { Button } from "@/components/ui/button"; |
| #4 | import { |
| #5 | Dialog, |
| #6 | DialogContent, |
| #7 | DialogDescription, |
| #8 | DialogFooter, |
| #9 | DialogHeader, |
| #10 | DialogTitle, |
| #11 | DialogTrigger, |
| #12 | } from "@/components/ui/dialog"; |
| #13 | import { Label } from "@/components/ui/label"; |
| #14 | import { useState, useRef } from "react"; |
| #15 | import { GoPlus } from "react-icons/go"; |
| #16 | import { Loader2 } from "lucide-react"; |
| #17 | import { useMemoriesApi } from "@/hooks/useMemoriesApi"; |
| #18 | import { toast } from "sonner"; |
| #19 | import { Textarea } from "@/components/ui/textarea"; |
| #20 | |
| #21 | export function CreateMemoryDialog() { |
| #22 | const { createMemory, isLoading, fetchMemories } = useMemoriesApi(); |
| #23 | const [open, setOpen] = useState(false); |
| #24 | const textRef = useRef<HTMLTextAreaElement>(null); |
| #25 | |
| #26 | const handleCreateMemory = async (text: string) => { |
| #27 | try { |
| #28 | await createMemory(text); |
| #29 | toast.success("Memory created successfully"); |
| #30 | // close the dialog |
| #31 | setOpen(false); |
| #32 | // refetch memories |
| #33 | await fetchMemories(); |
| #34 | } catch (error) { |
| #35 | console.error(error); |
| #36 | toast.error("Failed to create memory"); |
| #37 | } |
| #38 | }; |
| #39 | |
| #40 | return ( |
| #41 | <Dialog open={open} onOpenChange={setOpen}> |
| #42 | <DialogTrigger asChild> |
| #43 | <Button |
| #44 | variant="outline" |
| #45 | size="sm" |
| #46 | className="bg-primary hover:bg-primary/90 text-white" |
| #47 | > |
| #48 | <GoPlus /> |
| #49 | Create Memory |
| #50 | </Button> |
| #51 | </DialogTrigger> |
| #52 | <DialogContent className="sm:max-w-[525px] bg-zinc-900 border-zinc-800"> |
| #53 | <DialogHeader> |
| #54 | <DialogTitle>Create New Memory</DialogTitle> |
| #55 | <DialogDescription> |
| #56 | Add a new memory to your OpenMemory instance |
| #57 | </DialogDescription> |
| #58 | </DialogHeader> |
| #59 | <div className="grid gap-4 py-4"> |
| #60 | <div className="grid gap-2"> |
| #61 | <Label htmlFor="memory">Memory</Label> |
| #62 | <Textarea |
| #63 | ref={textRef} |
| #64 | id="memory" |
| #65 | placeholder="e.g., Lives in San Francisco" |
| #66 | className="bg-zinc-950 border-zinc-800 min-h-[150px]" |
| #67 | /> |
| #68 | </div> |
| #69 | </div> |
| #70 | <DialogFooter> |
| #71 | <Button variant="outline" onClick={() => setOpen(false)}> |
| #72 | Cancel |
| #73 | </Button> |
| #74 | <Button |
| #75 | disabled={isLoading} |
| #76 | onClick={() => handleCreateMemory(textRef?.current?.value || "")} |
| #77 | > |
| #78 | {isLoading ? ( |
| #79 | <Loader2 className="w-4 h-4 mr-2 animate-spin" /> |
| #80 | ) : ( |
| #81 | "Save Memory" |
| #82 | )} |
| #83 | </Button> |
| #84 | </DialogFooter> |
| #85 | </DialogContent> |
| #86 | </Dialog> |
| #87 | ); |
| #88 | } |
| #89 |