Added tag support + Post link and many more changes and optimizations.
This commit is contained in:
@@ -41,21 +41,6 @@ const useCollectionSlice = create<CollectionSlice>()((set) => ({
|
||||
),
|
||||
})),
|
||||
removeCollection: (collectionId) => {
|
||||
// await fetch("/api/routes/collections/postCollection", {
|
||||
// body: JSON.stringify({ collectionName }),
|
||||
// headers: {
|
||||
// "Content-Type": "application/json",
|
||||
// },
|
||||
// method: "POST",
|
||||
// })
|
||||
// .then((res) => res.json())
|
||||
// .then((data) => {
|
||||
// console.log(data);
|
||||
// set((state) => ({
|
||||
// collections: [...state.collections, data.response],
|
||||
// }));
|
||||
// });
|
||||
|
||||
set((state) => ({
|
||||
collections: state.collections.filter((c) => c.id !== collectionId),
|
||||
}));
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
import { create } from "zustand";
|
||||
import { Tag } from "@prisma/client";
|
||||
|
||||
type TagSlice = {
|
||||
tags: Tag[];
|
||||
setTags: () => void;
|
||||
};
|
||||
|
||||
const useTagSlice = create<TagSlice>()((set) => ({
|
||||
tags: [],
|
||||
setTags: async () => {
|
||||
const response = await fetch("/api/routes/tags");
|
||||
|
||||
const data = await response.json();
|
||||
|
||||
if (response.ok) set({ tags: data.response });
|
||||
},
|
||||
}));
|
||||
|
||||
export default useTagSlice;
|
||||
Reference in New Issue
Block a user