Skip to content

Commit

Permalink
Fix searching backend and frontend
Browse files Browse the repository at this point in the history
  • Loading branch information
tanish35 committed Oct 10, 2024
1 parent 261d715 commit e6a75b6
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
6 changes: 6 additions & 0 deletions backend/src/controllers/postController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ const searchPosts = asyncHandler(async (req: Request, res: Response) => {
name: true,
},
},
User: {
select: {
username: true,
pic: true,
},
},
},
});

Expand Down
16 changes: 11 additions & 5 deletions frontend/src/components/SearchBar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,18 +49,24 @@ const SearchBar = () => {
<ListItem
p={2}
borderBottom="1px solid"
borderColor="gray.200"
borderColor="gray.600"
cursor="pointer"
_hover={{ backgroundColor: "gray.100" }}
_hover={{ backgroundColor: "gray.700" }}
bg="gray.800"
onClick={() => navigate(`/posts/${suggestion.post_id}`)}
>
<Flex align="center">
<Avatar size="sm" mr={3} />
<Avatar src={suggestion.User.pic} size="sm" mr={3} />
<Box>
<Text fontWeight="bold">{suggestion.title}</Text>
<Text fontSize="sm" color="gray.500">
<Text fontWeight="bold" color="white">
{suggestion.title}
</Text>
<Text fontSize="sm" color="gray.400">
{suggestion.content.slice(0, 50)}...
</Text>
<Text fontSize="xs" color="gray.500">
Posted by {suggestion.User.username}
</Text>
</Box>
</Flex>
</ListItem>
Expand Down

0 comments on commit e6a75b6

Please sign in to comment.