/*
* Copyright (c) 2021 - 2023, Ludvig Lundgren and the autobrr contributors.
* SPDX-License-Identifier: GPL-2.0-or-later
*/
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
import { toast } from "react-hot-toast";
import Select, { components, ControlProps, InputProps, MenuProps, OptionProps } from "react-select";
import { APIClient } from "@api/APIClient";
import { GithubRelease } from "@app/types/Update";
import Toast from "@components/notifications/Toast";
import { LogLevelOptions, SelectOption } from "@domain/constants";
import { LogFiles } from "@screens/Logs";
interface RowItemProps {
label: string;
value?: string;
title?: string;
emptyText?: string;
newUpdate?: GithubRelease;
}
const RowItem = ({ label, value, title, emptyText }: RowItemProps) => {
return (
{label}
{value ? value : emptyText}
);
};
interface RowItemNumberProps {
label: string;
value?: string | number;
title?: string;
unit?: string;
}
const RowItemNumber = ({ label, value, title, unit }: RowItemNumberProps) => {
return (
{label}
{value}
{unit &&
{unit}
}
);
};
const Input = (props: InputProps) => {
return (
);
};
const Control = (props: ControlProps) => {
return (
);
};
const Menu = (props: MenuProps) => {
return (
);
};
const Option = (props: OptionProps) => {
return (
);
};
const RowItemSelect = ({ id, title, label, value, options, onChange }: any) => {
return (
{label}:
);
};
function LogSettings() {
const { isLoading, data } = useQuery({
queryKey: ["config"],
queryFn: APIClient.config.get,
retry: false,
refetchOnWindowFocus: false,
onError: err => console.log(err)
});
const queryClient = useQueryClient();
const setLogLevelUpdateMutation = useMutation({
mutationFn: (value: string) => APIClient.config.update({ log_level: value }),
onSuccess: () => {
toast.custom((t) => );
queryClient.invalidateQueries({ queryKey: ["config"] });
}
});
return (
Logs
Set level, size etc.
{/*
*/}
{/* */}
{/* */}
{/*
*/}
);
}
export default LogSettings;