1
0
mirror of https://github.com/upscayl/upscayl.git synced 2024-12-19 10:55:53 +01:00
upscayl/renderer/components/settings-tab/SaveOutputFolderToggle.tsx

40 lines
1.1 KiB
TypeScript
Raw Normal View History

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/userSettingsAtom";
import { useAtom } 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,
);
2023-07-22 13:07:53 +02:00
return (
<div className="flex flex-col gap-2">
2023-09-09 15:58:21 +02:00
<p className="text-sm font-medium">SAVE OUTPUT FOLDER</p>
<p className="text-xs text-base-content/80">
If enabled, the output folder will be remembered between sessions.
</p>
2024-02-14 07:32:52 +01:00
<p>{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>
);
}