MCPcopy Create free account
hub / github.com/code100x/daily-code / handleAddCategory

Function handleAddCategory

apps/web/components/admin/EditCategories.tsx:29–52  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

27 const router = useRouter();
28 const [newCategory, setNewCategory] = useState<string>("");
29 async function handleAddCategory() {
30 if (!newCategory) {
31 toast({
32 title: "Category cannot be empty",
33 description: "Please enter a category",
34 });
35 return;
36 }
37 toast({
38 title: "Adding category",
39 });
40 try {
41 await addCategory(newCategory);
42 router.refresh();
43 toast({
44 title: "Category added",
45 description: `Category ${newCategory} added`,
46 });
47 } catch (error) {
48 toast({
49 title: "Error adding category",
50 });
51 }
52 }
53 async function handleDeleteCategory(categoryId: string) {
54 toast({
55 title: "Deleting category",

Callers

nothing calls this directly

Calls 2

toastFunction · 0.90
addCategoryFunction · 0.90

Tested by

no test coverage detected