mirror of
https://github.com/Monadical-SAS/reflector.git
synced 2025-12-20 20:29:06 +00:00
* feat: limit the amount of transcripts to 10 by default * feat: separate page into different component, greatly improving the loading and reactivity * fix: current implementation immediately invokes the onDelete and onReprocess From pr-agent-monadical: Suggestion: The current implementation immediately invokes the onDelete and onReprocess functions when the component renders, rather than when the menu items are clicked. This can cause unexpected behavior and potential memory leaks. Use callback functions that only execute when the menu items are actually clicked. [possible issue, importance: 9]
35 lines
837 B
TypeScript
35 lines
837 B
TypeScript
import React, { useState } from "react";
|
|
import { Flex, Input, Button } from "@chakra-ui/react";
|
|
|
|
interface SearchBarProps {
|
|
onSearch: (searchTerm: string) => void;
|
|
}
|
|
|
|
export default function SearchBar({ onSearch }: SearchBarProps) {
|
|
const [searchInputValue, setSearchInputValue] = useState("");
|
|
|
|
const handleSearch = () => {
|
|
onSearch(searchInputValue);
|
|
};
|
|
|
|
const handleKeyDown = (event: React.KeyboardEvent) => {
|
|
if (event.key === "Enter") {
|
|
handleSearch();
|
|
}
|
|
};
|
|
|
|
return (
|
|
<Flex mb={4} alignItems="center">
|
|
<Input
|
|
placeholder="Search transcriptions..."
|
|
value={searchInputValue}
|
|
onChange={(e) => setSearchInputValue(e.target.value)}
|
|
onKeyDown={handleKeyDown}
|
|
/>
|
|
<Button ml={2} onClick={handleSearch}>
|
|
Search
|
|
</Button>
|
|
</Flex>
|
|
);
|
|
}
|