MCPcopy Create free account
hub / github.com/9d8dev/directory / BookmarkManager

Function BookmarkManager

components/admin/bookmark-manager.tsx:90–736  ·  view source on GitHub ↗
({
  bookmarks,
  categories,
}: BookmarkManagerProps)

Source from the content-addressed store, hash-verified

88}
89
90export function BookmarkManager({
91 bookmarks,
92 categories,
93}: BookmarkManagerProps) {
94 const [isGenerating, setIsGenerating] = useState(false);
95 const [isSaving, setIsSaving] = useState(false);
96 const [isSheetOpen, setIsSheetOpen] = useState(false);
97 const [isBulkSheetOpen, setIsBulkSheetOpen] = useState(false);
98
99 const [bulkUploadState, setBulkUploadState] = useState<ActionState | null>(
100 null,
101 );
102 const [isUploading, setIsUploading] = useState(false);
103
104 const [bookmarkToDelete, setBookmarkToDelete] =
105 useState<BookmarkWithCategory | null>(null);
106 const [isDeleting, setIsDeleting] = useState(false);
107
108 const [selectedBookmark, setSelectedBookmark] =
109 useState<BookmarkWithCategory | null>(null);
110 const [isNewBookmark, setIsNewBookmark] = useState(true);
111
112 useEffect(() => {
113 if (bulkUploadState?.success) {
114 if (
115 bulkUploadState.progress?.current === bulkUploadState.progress?.total
116 ) {
117 toast.success(
118 bulkUploadState.message || "Bookmarks uploaded successfully",
119 );
120 setIsUploading(false);
121 setIsSheetOpen(false);
122 setBulkUploadState(null);
123 } else if (bulkUploadState.progress?.lastAdded) {
124 toast.success(`Added: ${bulkUploadState.progress.lastAdded}`);
125 }
126 } else if (bulkUploadState?.error) {
127 toast.error(bulkUploadState.error);
128 if (
129 !bulkUploadState.progress ||
130 bulkUploadState.progress.current === bulkUploadState.progress.total
131 ) {
132 setIsUploading(false);
133 }
134 }
135 }, [bulkUploadState]);
136
137 // Form state management
138 const [formData, setFormData] = useState({
139 title: "",
140 slug: "",
141 url: "",
142 description: "",
143 overview: "",
144 search_results: "",
145 favicon: "",
146 ogImage: "",
147 categoryId: "none",

Callers

nothing calls this directly

Calls 4

resetFormFunction · 0.85
handleEditFunction · 0.85
handleGenerateContentFunction · 0.85
handleDeleteFunction · 0.70

Tested by

no test coverage detected