MCPcopy Create free account
hub / github.com/WardAnalytics/WardGraph / GraphCard

Function GraphCard

src/templates/SavedGraphsTemplate.tsx:33–107  ·  view source on GitHub ↗
({ userID, graph })

Source from the content-addressed store, hash-verified

31}
32
33const GraphCard: FC<GraphCardProps> = ({ userID, graph }) => {
34 const navigate = useNavigate();
35 const [isDeleteDialogOpen, setIsDeleteDialogOpen] = useState(false);
36 const [graphName, setGraphName] = useState<string>(graph.name);
37 const [editMode, setEditMode] = useState<boolean>(false);
38
39 const onChangeGraphName = async () => {
40 graph.name = graphName;
41 await updatePersonalGraph(userID, graph);
42 setEditMode(false);
43 };
44
45 // Hotkeys for the graph name input
46 // Enter: Save the graph name
47 const hotKeysMap: HotKeysType = {
48 ENTER: {
49 key: "enter",
50 asyncHandler: async (event: KeyboardEvent<HTMLElement>) => {
51 event.preventDefault();
52
53 await onChangeGraphName();
54 },
55 },
56 };
57
58 return (
59 <div className="group flex h-full min-h-[7rem] w-full flex-col gap-2 rounded-md px-4 py-3 text-lg text-gray-800 shadow-sm ring-1 ring-inset ring-gray-300">
60 <p className=" flex h-fit flex-row flex-wrap items-center gap-1.5 text-base font-semibold text-gray-800 transition-all duration-150 ">
61 {editMode ? (
62 <div className="flex w-full flex-row items-center gap-1.5 group-hover:flex">
63 <input
64 type="text"
65 value={graphName}
66 onChange={(e) => setGraphName(e.target.value)}
67 autoFocus
68 className="block w-full rounded-md border-0 py-1.5 text-sm leading-6 text-gray-900 ring-1 ring-inset ring-gray-300 transition-all placeholder:text-gray-400 focus:outline focus:outline-[3px] focus:outline-blue-200 focus:ring-2 focus:ring-blue-400"
69 onKeyDown={async (event) => {
70 const hotKey = event.key.toLocaleLowerCase();
71 switch (hotKey) {
72 case hotKeysMap.ENTER.key:
73 await hotKeysMap.ENTER.asyncHandler!(event);
74 break;
75 }
76 }}
77 onBlur={onChangeGraphName}
78 />
79 </div>
80 ) : (
81 <span onClick={() => setEditMode(true)}>{graph.name}</span>
82 )}
83 <Badge text="Ethereum" color={Colors.BLUE} Icon={LinkIcon} />
84 </p>
85
86 <div className="h-[1.5px] w-full bg-gray-100" />
87 <p className="text-sm text-gray-600">
88 {graph.data.addresses.length} addresses
89 </p>
90 <div className="ml-auto mt-auto flex flex-row">

Callers

nothing calls this directly

Calls 2

getGraphHrefFunction · 0.90
onChangeGraphNameFunction · 0.85

Tested by

no test coverage detected