Skip to content

Commit 474a097

Browse files
committed
Update get notes component
1 parent fad195f commit 474a097

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

components/get-notes.tsx

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,19 @@ const GetNotes = async ({
2828
<span> Error while fetching todos {message}</span>;
2929
}
3030

31+
// Get all collaborators for the todos
32+
const todosWithCollaborators = await Promise.all(
33+
todo.map(async item => {
34+
const { data: collabs } = await getCollaborators(item.id);
35+
return { ...item, collaborators: collabs };
36+
})
37+
);
38+
3139
return (
3240
<section className="columns-1 sm:columns-2 md:columns-3 lg:columns-4 gap-4 p-4 mt-10">
33-
{todo &&
34-
todo.map(async item => {
35-
const { data: collabs, success } = await getCollaborators(item.id);
41+
{todosWithCollaborators &&
42+
todosWithCollaborators.map(item => {
43+
// const { data: collabs, success } = await getCollaborators(item.id);
3644

3745
return (
3846
<ListingCard
@@ -42,7 +50,7 @@ const GetNotes = async ({
4250
className={`relative mb-4 border dark:border-slate-700 rounded-lg shadow-md hover:shadow-lg transition-shadow duration-200 break-inside-avoid-column group ${getLightModeColor(
4351
item.todoColor
4452
)} ${getDarkModeColor(item.todoColor)}`}
45-
collabs={collabs}
53+
collabs={item.collaborators}
4654
>
4755
<CardHeader className="py-2 px-4">
4856
{item.images?.map((item: any) => (
@@ -64,7 +72,7 @@ const GetNotes = async ({
6472
{parseFormattedText(item.description)}
6573
</CardContent>
6674
<CardFooter className="mb-4">
67-
{collabs
75+
{item.collaborators
6876
?.filter(item => item.user.id !== userId)
6977
.map(item => (
7078
<Avatar

0 commit comments

Comments
 (0)