added collaboration mode for collections

This commit is contained in:
Daniel
2023-04-27 00:10:48 +03:30
parent e715756cbe
commit cc8e8dbe9a
16 changed files with 279 additions and 37 deletions
+9 -9
View File
@@ -5,13 +5,13 @@
import { create } from "zustand";
import { Collection } from "@prisma/client";
import { NewCollection } from "@/types/global";
import { ExtendedCollection, NewCollection } from "@/types/global";
type CollectionStore = {
collections: Collection[];
collections: ExtendedCollection[];
setCollections: () => void;
addCollection: (body: NewCollection) => Promise<boolean>;
updateCollection: (collection: Collection) => void;
// updateCollection: (collection: Collection) => void;
removeCollection: (collectionId: number) => void;
};
@@ -44,12 +44,12 @@ const useCollectionStore = create<CollectionStore>()((set) => ({
return response.ok;
},
updateCollection: (collection) =>
set((state) => ({
collections: state.collections.map((c) =>
c.id === collection.id ? collection : c
),
})),
// updateCollection: (collection) =>
// set((state) => ({
// collections: state.collections.map((c) =>
// c.id === collection.id ? collection : c
// ),
// })),
removeCollection: (collectionId) => {
set((state) => ({
collections: state.collections.filter((c) => c.id !== collectionId),
+2
View File
@@ -79,6 +79,8 @@ const useLinkStore = create<LinkStore>()((set) => ({
const data = await response.json();
console.log(data);
if (response.ok) {
set((state) => ({
links: state.links.filter((e) => e.id !== link.id),