Skip to content

Commit

Permalink
patch: fix search (#195)
Browse files Browse the repository at this point in the history
  • Loading branch information
tinashechiraya authored Dec 12, 2024
1 parent c177f7c commit d259388
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion django_project/frontend/src/pages/Support/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export default function SupportPage() {
const [additionalDetails, setAdditionalDetails] = useState("");
const [screenshot, setScreenshot] = useState<File | null>(null);
const [currentPage, setCurrentPage] = useState(1);
const [filteredTickets, setFilteredTickets] = useState([]);

const dispatch = useDispatch<AppDispatch>();
const toast = useToast();
Expand Down Expand Up @@ -126,6 +127,15 @@ export default function SupportPage() {
}
};

useEffect(() => {
setFilteredTickets(
tickets.filter((ticket) =>
ticket.title.toLowerCase().includes(searchTerm.toLowerCase()) ||
ticket.description.toLowerCase().includes(searchTerm.toLowerCase())
)
);
}, [searchTerm, tickets]);

return (
<>
<Helmet>
Expand Down Expand Up @@ -222,7 +232,7 @@ export default function SupportPage() {
flexDirection="column"
gap={4}
>
{currentTickets.map((ticket, index) => (
{(searchTerm !== '' ? filteredTickets : currentTickets).map((ticket, index) => (
<Box key={index} boxShadow="md" borderRadius="md" p={4} border="1px" borderColor="gray.300">
<Flex direction="column" gap={2} position="relative">
{/* Badge (Status) */}
Expand Down

0 comments on commit d259388

Please sign in to comment.