improved ux + coloring fix + improved dashboard ui
This commit is contained in:
@@ -32,16 +32,15 @@ export default async function updateLink(
|
||||
|
||||
const isCollectionOwner =
|
||||
targetLink?.collection.ownerId === link.collection.ownerId &&
|
||||
link.collection.ownerId === userId &&
|
||||
targetLink?.collection.ownerId === userId;
|
||||
link.collection.ownerId === userId;
|
||||
|
||||
const authorizedSwitchCollection =
|
||||
!isCollectionOwner && targetLink?.collection.id === link.collection.id;
|
||||
const unauthorizedSwitchCollection =
|
||||
!isCollectionOwner && targetLink?.collection.id !== link.collection.id;
|
||||
|
||||
console.log(authorizedSwitchCollection);
|
||||
console.log(isCollectionOwner);
|
||||
|
||||
// Makes sure collection members (non-owners) cannot move a link to/from a collection.
|
||||
if (!authorizedSwitchCollection)
|
||||
if (unauthorizedSwitchCollection)
|
||||
return {
|
||||
response: "You can't move a link to/from a collection you don't own.",
|
||||
status: 401,
|
||||
@@ -59,15 +58,11 @@ export default async function updateLink(
|
||||
data: {
|
||||
name: link.name,
|
||||
description: link.description,
|
||||
collection:
|
||||
targetLink?.collection.ownerId === link.collection.ownerId &&
|
||||
link.collection.ownerId === userId
|
||||
? {
|
||||
connect: {
|
||||
id: link.collection.id,
|
||||
},
|
||||
}
|
||||
: undefined,
|
||||
collection: {
|
||||
connect: {
|
||||
id: link.collection.id,
|
||||
},
|
||||
},
|
||||
tags: {
|
||||
set: [],
|
||||
connectOrCreate: link.tags.map((tag) => ({
|
||||
@@ -104,14 +99,14 @@ export default async function updateLink(
|
||||
},
|
||||
});
|
||||
|
||||
if (targetLink.collection.id !== link.collection.id) {
|
||||
if (targetLink?.collection.id !== link.collection.id) {
|
||||
await moveFile(
|
||||
`archives/${targetLink.collection.id}/${link.id}.pdf`,
|
||||
`archives/${targetLink?.collection.id}/${link.id}.pdf`,
|
||||
`archives/${link.collection.id}/${link.id}.pdf`
|
||||
);
|
||||
|
||||
await moveFile(
|
||||
`archives/${targetLink.collection.id}/${link.id}.png`,
|
||||
`archives/${targetLink?.collection.id}/${link.id}.png`,
|
||||
`archives/${link.collection.id}/${link.id}.png`
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user