2024-09-01 14:01:45 +02:00
|
|
|
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,
|
2024-10-04 11:15:54 +02:00
|
|
|
} from "@/atoms/user-settings-atom";
|
2024-09-01 14:01:45 +02:00
|
|
|
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,
|
|
|
|
);
|
2024-09-01 14:01:45 +02:00
|
|
|
const t = useAtomValue(translationAtom);
|
|
|
|
|
2023-07-22 13:07:53 +02:00
|
|
|
return (
|
|
|
|
<div className="flex flex-col gap-2">
|
2024-09-01 14:01:45 +02:00
|
|
|
<p className="text-sm font-medium">
|
2024-09-03 09:34:58 +02:00
|
|
|
{t("SETTINGS.SAVE_OUTPUT_FOLDER.TITLE")}
|
2024-09-01 14:01:45 +02:00
|
|
|
</p>
|
2023-09-09 15:58:21 +02:00
|
|
|
<p className="text-xs text-base-content/80">
|
2024-09-03 09:34:58 +02:00
|
|
|
{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>
|
|
|
|
);
|
|
|
|
}
|