Added the Ability to Update Board Background Images After Creation

This commit is contained in:
Ahmad 2024-04-30 20:01:22 -04:00
parent 4ddb7f99fd
commit ae6a8d69b8
No known key found for this signature in database
GPG key ID: 8FD8A93530D182BF
6 changed files with 123 additions and 6 deletions

View file

@ -16,10 +16,36 @@ const handler = async (data: InputType): Promise<ReturnType> => {
if (!userId || !orgId) return { error: 'Unauthorized' };
const { title, id } = data;
const { title, id, image } = data;
let board;
try {
const currentBoard = await db.board.findUnique({
where: {
id,
orgId,
},
select: {
imageId: true,
imageThumbUrl: true,
imageFullUrl: true,
imageUserName: true,
imageLinkHTML: true,
imageDownloadUrl: true,
},
});
const currentImageString = `${currentBoard?.imageId}|${currentBoard?.imageThumbUrl}|${currentBoard?.imageFullUrl}|${currentBoard?.imageUserName}|${currentBoard?.imageLinkHTML}|${currentBoard?.imageDownloadUrl}`;
const [
imageId,
imageThumbUrl,
imageFullUrl,
imageLinkHTML,
imageUserName,
imageDownloadUrl,
] = image?.split('|') || currentImageString.split('|');
board = await db.board.update({
where: {
id,
@ -27,6 +53,12 @@ const handler = async (data: InputType): Promise<ReturnType> => {
},
data: {
title,
imageId,
imageThumbUrl,
imageFullUrl,
imageLinkHTML,
imageUserName,
imageDownloadUrl,
},
});