();
- useHotkeys([['ctrl+K', () => textInput.current && textInput.current.focus()]]);
+ // Find a service with the type of 'Overseerr'
+ const service = config.services.find((s) => s.type === 'Overseerr');
+ const form = useForm({
+ initialValues: {
+ query: '',
+ },
+ });
+
+ const [debounced, cancel] = useDebouncedValue(form.values.query, 250);
+ const [data, setData] = useState([]);
+ useEffect(() => {
+ if (form.values.query !== debounced || form.values.query === '') return;
+ setOpened(false);
+ setOpenedResults(true);
+ if (service) {
+ const serviceUrl = new URL(service.url);
+ axios
+ .post(`/api/modules/overseerr?query=${form.values.query}`, {
+ service,
+ })
+ .then((res) => setData(res.data.results ?? []));
+ }
+ }, [debounced]);
+ useHotkeys([['ctrl+K', () => textInput.current && textInput.current.focus()]]);
const { classes, cx } = useStyles();
const rightSection = (
@@ -43,12 +74,6 @@ export default function SearchBar(props: any) {
);
- const form = useForm({
- initialValues: {
- query: '',
- },
- });
-
// If enabled modules doesn't contain the module, return null
// If module in enabled
@@ -57,6 +82,7 @@ export default function SearchBar(props: any) {
return null;
}
+ // Data with label as item.name
return (