1
0
mirror of https://github.com/upscayl/upscayl.git synced 2024-12-18 18:35:58 +01:00
upscayl/renderer/components/sidebar/settings-tab/save-output-folder-toggle.tsx

45 lines
1.2 KiB
TypeScript
Raw Normal View History

import { translationAtom } from "@/atoms/translations-atom";
2024-02-14 07:32:52 +01:00
import {
2024-04-09 20:11:24 +02:00
savedOutputPathAtom,
2024-02-14 07:32:52 +01:00
rememberOutputFolderAtom,
} from "@/atoms/user-settings-atom";
import { useAtom, useAtomValue } from "jotai";
2023-07-22 13:07:53 +02:00
2024-02-14 07:32:52 +01:00
export function SaveOutputFolderToggle() {
2024-04-09 20:11:24 +02:00
const [outputPath, setOutputPath] = useAtom(savedOutputPathAtom);
2024-02-14 07:32:52 +01:00
const [rememberOutputFolder, setRememberOutputFolder] = useAtom(
rememberOutputFolderAtom,
);
const t = useAtomValue(translationAtom);
2023-07-22 13:07:53 +02:00
return (
<div className="flex flex-col gap-2">
<p className="text-sm font-medium">
{t("SETTINGS.SAVE_OUTPUT_FOLDER.TITLE")}
</p>
2023-09-09 15:58:21 +02:00
<p className="text-xs text-base-content/80">
{t("SETTINGS.SAVE_OUTPUT_FOLDER.DESCRIPTION")}
2023-09-09 15:58:21 +02:00
</p>
2024-02-14 07:32:52 +01:00
2024-04-18 23:58:47 +02:00
<p className="font-mono text-sm">{outputPath}</p>
2023-07-22 13:07:53 +02:00
<input
type="checkbox"
2023-11-10 12:41:35 +01:00
className="toggle"
2023-07-22 13:07:53 +02:00
checked={rememberOutputFolder}
onClick={() => {
setRememberOutputFolder((oldValue) => {
if (oldValue === true) {
2024-02-14 07:32:52 +01:00
setOutputPath("");
2023-07-22 13:07:53 +02:00
}
return !oldValue;
});
localStorage.setItem(
"rememberOutputFolder",
2024-02-14 07:32:52 +01:00
JSON.stringify(!rememberOutputFolder),
2023-07-22 13:07:53 +02:00
);
}}
/>
</div>
);
}