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
@@ -4,10 +4,10 @@
// You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
import { prisma } from "@/lib/api/db";
import { Collection } from "@prisma/client";
import { NewCollection } from "@/types/global";
import { existsSync, mkdirSync } from "fs";
export default async function (collection: Collection, userId: number) {
export default async function (collection: NewCollection, userId: number) {
if (!collection || collection.name.trim() === "")
return {
response: "Please enter a valid collection.",
@@ -41,6 +41,14 @@ export default async function (collection: Collection, userId: number) {
},
name: collection.name,
description: collection.description,
members: {
create: collection.members.map((e) => ({
user: { connect: { email: e.email } },
canCreate: e.canCreate,
canUpdate: e.canUpdate,
canDelete: e.canDelete,
})),
},
},
});