Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2ee332a

Browse files
committed
Only show quick action menu for the current user's updates
1 parent fff599e commit 2ee332a

File tree

1 file changed

+41
-30
lines changed

1 file changed

+41
-30
lines changed

src/components/HomePageFeed.tsx

Lines changed: 41 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,11 @@ export function HomePageFeedUpdate({
135135
queryClient.refetchQueries('/api/fauna/all-updates')
136136
queryClient.refetchQueries(['/api/fauna/recent-updates', goal.id])
137137
},
138+
onError: () => {
139+
toast.error('Something went wrong!!!', {
140+
id: toastId.current,
141+
})
142+
},
138143
}
139144
)
140145

@@ -192,38 +197,44 @@ export function HomePageFeedUpdate({
192197
</p>
193198
</div>
194199

195-
<div className="flex-shrink-0 self-center flex">
196-
<div className="relative inline-block text-left">
197-
<Menu
198-
trigger={
199-
<button className="-m-2 p-2 rounded-full flex items-center text-gray-400 hover:text-gray-600">
200-
<span className="sr-only">Open quick actions</span>
201-
<DotsThreeOutlineVertical
202-
className="h-5 w-5"
203-
aria-hidden={true}
204-
/>
205-
</button>
206-
}
207-
>
208-
<Menu.Item
209-
icon={Pencil}
210-
onClick={() => setIsInEditMode(true)}
200+
{session && (session.user as User).id === update.postedBy.id && (
201+
<div className="flex-shrink-0 self-center flex">
202+
<div className="relative inline-block text-left">
203+
<Menu
204+
trigger={
205+
<button className="-m-2 p-2 rounded-full flex items-center text-gray-400 hover:text-gray-600">
206+
<span className="sr-only">
207+
Open quick actions
208+
</span>
209+
<DotsThreeOutlineVertical
210+
className="h-5 w-5"
211+
aria-hidden={true}
212+
/>
213+
</button>
214+
}
211215
>
212-
Edit
213-
</Menu.Item>
214-
<Menu.Item
215-
icon={Trash}
216-
onClick={() => {
217-
deleteUpdate()
218-
const id = toast.loading('Deleting your update...')
219-
toastId.current = id
220-
}}
221-
>
222-
Delete
223-
</Menu.Item>
224-
</Menu>
216+
<Menu.Item
217+
icon={Pencil}
218+
onClick={() => setIsInEditMode(true)}
219+
>
220+
Edit
221+
</Menu.Item>
222+
<Menu.Item
223+
icon={Trash}
224+
onClick={() => {
225+
deleteUpdate()
226+
const id = toast.loading(
227+
'Deleting your update...'
228+
)
229+
toastId.current = id
230+
}}
231+
>
232+
Delete
233+
</Menu.Item>
234+
</Menu>
235+
</div>
225236
</div>
226-
</div>
237+
)}
227238
</div>
228239
<div className="mt-4 flex">
229240
<button

0 commit comments

Comments
 (0)