mirror of
https://github.com/ahmadk953/tasko.git
synced 2025-05-04 12:43:24 +00:00
Added the Ability to Update Board Background Images After Creation
This commit is contained in:
parent
4ddb7f99fd
commit
ae6a8d69b8
6 changed files with 123 additions and 6 deletions
|
@ -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,
|
||||
},
|
||||
});
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue