Conversation
|
@yeo-yeo is attempting to deploy a commit to the Yuqing's projects Team on Vercel. A member of the Team first needs to authorize it. |
| .eq('id', userID) | ||
| const favouriteItems: number[] | null = | ||
| favourites && favourites[0].favourite_items | ||
| const favouriteItems = favourites && favourites[0].favourite_items |
There was a problem hiding this comment.
I haven't systematically been through but I think there a few places like this where you shouldn't need to declare the types so you can just get rid of them
| return ( | ||
| <Button | ||
| className={`bg-foundation text-white rounded-full ${className || ''}`} | ||
| <Link |
There was a problem hiding this comment.
Buttons like Message Seller only work if you click on the button text at the moment! I thought there was something wrong with their click handlers/links but then I realised the issue is only the text was being turned into a link
(I might not have got the class/css stuff right here)
| )) as Item[] | ||
| itemDetails = itemDetails.filter(item => item !== undefined) | ||
| if (!userID) { | ||
| return null |
There was a problem hiding this comment.
maybe this isn't the right thing to return, I was being lazy
I think it should be impossible for a logged out user to reach this component so this could actually be a legit time to use userID! on line 13!
| ) | ||
|
|
||
| const items = fetchedItems.filter( | ||
| (item: Item | undefined): item is Item => item !== undefined, |
There was a problem hiding this comment.
this here is some pure typescript magic called a 'type predicate'. the item is Item bit means 'what I'm going to return from this little fn is of type Item', and this does away with the annoying (Item | undefined)[] situation you were in before. Just using the filter without this type predicate magic annoyingly doesn't convince Typescript that you've got rid of the undefineds (even though you have)
| const seller_name = await fetchSellerName( | ||
| supabase, | ||
| itemDetails[0].seller_id || '', | ||
| itemDetails?.[0]?.seller_id || '', |
There was a problem hiding this comment.
With the changes here and in fetchItemDetails I think a bug should be fixed where at the moment if you try to view your favourite items but you don't have any, the whole page crashes
No description provided.