Skip to content

Commit a86a2b8

Browse files
committed
Replace && operator with optional chaining operator in get notes
1 parent a4c0d6a commit a86a2b8

File tree

1 file changed

+55
-56
lines changed

1 file changed

+55
-56
lines changed

components/get-notes.tsx

Lines changed: 55 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -38,64 +38,63 @@ const GetNotes = async ({
3838

3939
return (
4040
<section className="columns-1 sm:columns-2 md:columns-3 lg:columns-4 gap-4 p-4 mt-10">
41-
{todosWithCollaborators &&
42-
todosWithCollaborators.map(item => {
43-
// const { data: collabs, success } = await getCollaborators(item.id);
41+
{todosWithCollaborators?.map(item => {
42+
// const { data: collabs, success } = await getCollaborators(item.id);
4443

45-
return (
46-
<ListingCard
47-
key={item.id}
48-
item={item}
49-
userId={userId}
50-
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(
51-
item.todoColor
52-
)} ${getDarkModeColor(item.todoColor)}`}
53-
collabs={item.collaborators}
54-
>
55-
<CardHeader className="py-2 px-4">
56-
{item.images?.map((item: any) => (
57-
<Image
58-
src={item.url}
59-
key={item.id}
60-
alt="Image"
61-
width={200}
62-
height={200}
63-
className="h-full w-full rounded"
64-
priority={true}
65-
/>
44+
return (
45+
<ListingCard
46+
key={item.id}
47+
item={item}
48+
userId={userId}
49+
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(
50+
item.todoColor
51+
)} ${getDarkModeColor(item.todoColor)}`}
52+
collabs={item.collaborators}
53+
>
54+
<CardHeader className="py-2 px-4">
55+
{item.images?.map((item: any) => (
56+
<Image
57+
src={item.url}
58+
key={item.id}
59+
alt="Image"
60+
width={200}
61+
height={200}
62+
className="h-full w-full rounded"
63+
priority={true}
64+
/>
65+
))}
66+
<CardTitle className="font-bold text-lg break-words">
67+
{item.title}
68+
</CardTitle>
69+
</CardHeader>
70+
<CardContent className="py-2 px-4 break-words">
71+
{parseFormattedText(item.description)}
72+
</CardContent>
73+
<CardFooter className="mb-4">
74+
{item.collaborators
75+
?.filter(item => item.user.id !== userId)
76+
.map(item => (
77+
<Avatar
78+
key={item.user.id}
79+
className="flex items-center justify-center"
80+
>
81+
<AvatarImage
82+
src={item.user.profilePic as string}
83+
alt="AS"
84+
className="cursor-pointer w-7 h-7 rounded-full"
85+
width={50}
86+
height={50}
87+
/>
88+
<AvatarFallback className="cursor-pointer w-7 h-7 p-2 shadow rounded-full dark:border border-gray-600 text-xs">
89+
{item.user?.firstName.charAt(0)}
90+
{item.user?.lastName.charAt(0)}
91+
</AvatarFallback>
92+
</Avatar>
6693
))}
67-
<CardTitle className="font-bold text-lg break-words">
68-
{item.title}
69-
</CardTitle>
70-
</CardHeader>
71-
<CardContent className="py-2 px-4 break-words">
72-
{parseFormattedText(item.description)}
73-
</CardContent>
74-
<CardFooter className="mb-4">
75-
{item.collaborators
76-
?.filter(item => item.user.id !== userId)
77-
.map(item => (
78-
<Avatar
79-
key={item.user.id}
80-
className="flex items-center justify-center"
81-
>
82-
<AvatarImage
83-
src={item.user.profilePic as string}
84-
alt="AS"
85-
className="cursor-pointer w-7 h-7 rounded-full"
86-
width={50}
87-
height={50}
88-
/>
89-
<AvatarFallback className="cursor-pointer w-7 h-7 p-2 shadow rounded-full dark:border border-gray-600 text-xs">
90-
{item.user?.firstName.charAt(0)}
91-
{item.user?.lastName.charAt(0)}
92-
</AvatarFallback>
93-
</Avatar>
94-
))}
95-
</CardFooter>
96-
</ListingCard>
97-
);
98-
})}
94+
</CardFooter>
95+
</ListingCard>
96+
);
97+
})}
9998
</section>
10099
);
101100
};

0 commit comments

Comments
 (0)