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 | import { useEffect, useState } from "react"; |
| #2 | import { useMemoriesApi } from "@/hooks/useMemoriesApi"; |
| #3 | import { useSelector } from "react-redux"; |
| #4 | import { RootState } from "@/store/store"; |
| #5 | import { Memory } from "@/components/types"; |
| #6 | import Categories from "@/components/shared/categories"; |
| #7 | import Link from "next/link"; |
| #8 | import { formatDate } from "@/lib/helpers"; |
| #9 | interface RelatedMemoriesProps { |
| #10 | memoryId: string; |
| #11 | } |
| #12 | |
| #13 | export function RelatedMemories({ memoryId }: RelatedMemoriesProps) { |
| #14 | const { fetchRelatedMemories } = useMemoriesApi(); |
| #15 | const relatedMemories = useSelector( |
| #16 | (state: RootState) => state.memories.relatedMemories |
| #17 | ); |
| #18 | const [isLoading, setIsLoading] = useState(true); |
| #19 | |
| #20 | useEffect(() => { |
| #21 | const loadRelatedMemories = async () => { |
| #22 | try { |
| #23 | await fetchRelatedMemories(memoryId); |
| #24 | } catch (error) { |
| #25 | console.error("Failed to fetch related memories:", error); |
| #26 | } finally { |
| #27 | setIsLoading(false); |
| #28 | } |
| #29 | }; |
| #30 | |
| #31 | loadRelatedMemories(); |
| #32 | }, []); |
| #33 | |
| #34 | if (isLoading) { |
| #35 | return ( |
| #36 | <div className="w-full max-w-2xl mx-auto rounded-lg overflow-hidden bg-zinc-900 text-white p-6"> |
| #37 | <p className="text-center text-zinc-500">Loading related memories...</p> |
| #38 | </div> |
| #39 | ); |
| #40 | } |
| #41 | |
| #42 | if (!relatedMemories.length) { |
| #43 | return ( |
| #44 | <div className="w-full max-w-2xl mx-auto rounded-lg overflow-hidden bg-zinc-900 text-white p-6"> |
| #45 | <p className="text-center text-zinc-500">No related memories found</p> |
| #46 | </div> |
| #47 | ); |
| #48 | } |
| #49 | |
| #50 | return ( |
| #51 | <div className="w-full max-w-2xl mx-auto rounded-lg overflow-hidden bg-zinc-900 border border-zinc-800 text-white"> |
| #52 | <div className="px-6 py-4 flex justify-between items-center bg-zinc-800 border-b border-zinc-800"> |
| #53 | <h2 className="font-semibold">Related Memories</h2> |
| #54 | </div> |
| #55 | <div className="space-y-6 p-6"> |
| #56 | {relatedMemories.map((memory: Memory) => ( |
| #57 | <div |
| #58 | key={memory.id} |
| #59 | className="border-l-2 border-zinc-800 pl-6 py-1 hover:bg-zinc-700/10 transition-colors cursor-pointer" |
| #60 | > |
| #61 | <Link href={`/memory/${memory.id}`}> |
| #62 | <h3 className="font-medium mb-3">{memory.memory}</h3> |
| #63 | <div className="flex items-center justify-between"> |
| #64 | <div className="flex items-center gap-3"> |
| #65 | <Categories |
| #66 | categories={memory.categories} |
| #67 | isPaused={ |
| #68 | memory.state === "paused" || memory.state === "archived" |
| #69 | } |
| #70 | concat={true} |
| #71 | /> |
| #72 | {memory.state !== "active" && ( |
| #73 | <span className="inline-block px-3 border border-yellow-600 text-yellow-600 font-semibold text-xs rounded-full bg-yellow-400/10 backdrop-blur-sm"> |
| #74 | {memory.state === "paused" ? "Paused" : "Archived"} |
| #75 | </span> |
| #76 | )} |
| #77 | </div> |
| #78 | <div className="flex items-center gap-4"> |
| #79 | <div className="text-zinc-400 text-sm"> |
| #80 | {formatDate(memory.created_at)} |
| #81 | </div> |
| #82 | </div> |
| #83 | </div> |
| #84 | </Link> |
| #85 | </div> |
| #86 | ))} |
| #87 | </div> |
| #88 | </div> |
| #89 | ); |
| #90 | } |
| #91 |