Skip to content

Commit

Permalink
fix bug with cards not rendering fully on preview
Browse files Browse the repository at this point in the history
  • Loading branch information
Alforoan committed Sep 10, 2024
1 parent 0a0898d commit d454f9a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
2 changes: 1 addition & 1 deletion client/src/components/UploadBoardComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ const UploadBoardComponent: React.FC<UploadProps> = ({ isEditingTitle }) => {
name: boardName,
uuid: uuidv4(),
};
handleUploadNewTemplate(boardToUpload);
await handleUploadNewTemplate(boardToUpload);
setSelectedBoard(null);
navigate("/templates");
};
Expand Down
12 changes: 9 additions & 3 deletions client/src/context/TemplateContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,19 @@ export const TemplateProvider = ({ children }: { children: ReactNode }) => {
try {
await postTemplate(template);

template.cards!.forEach(async (card) => {
const uploadCardPromises = template.cards!.map(async (card) => {
if (card.id !== "0") {
await postCard(card, template.uuid, true);
return await postCard(card, template.uuid, true);
}
});

setUploadedTemplateNames((prev) => [...prev, template.name]);
await Promise.all(uploadCardPromises);

setUploadedTemplateNames((prev) => {
console.log('LOGGING PREV WHEN UPLOADING A TEMPLTAE', prev);

return [...prev, template.name];
});
} catch (error) {
console.error("Error uploadinig template cards:", error);
}
Expand Down
3 changes: 2 additions & 1 deletion client/src/hooks/useAPI.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,8 @@ export const usePostTemplate = () => {
downloads: 0,
uploaded_at: new Date(),
};
await execute({ payload: payload });
const response = await execute({ payload: payload });
return response;
};

return { postTemplate, isLoading, error };
Expand Down

0 comments on commit d454f9a

Please sign in to comment.