2024-09-01 14:01:45 +02:00
|
|
|
import { translationAtom } from "@/atoms/translations-atom";
|
2024-10-04 11:15:54 +02:00
|
|
|
import { overwriteAtom } from "@/atoms/user-settings-atom";
|
2024-09-01 14:01:45 +02:00
|
|
|
import { useAtom, useAtomValue } from "jotai";
|
2023-08-11 11:45:27 +02:00
|
|
|
import React, { useEffect } from "react";
|
2023-08-10 12:17:35 +02:00
|
|
|
|
2024-01-15 10:07:22 +01:00
|
|
|
const OverwriteToggle = () => {
|
|
|
|
const [overwrite, setOverwrite] = useAtom(overwriteAtom);
|
2024-09-01 14:01:45 +02:00
|
|
|
const t = useAtomValue(translationAtom);
|
2023-08-30 06:54:16 +02:00
|
|
|
|
2023-08-10 12:17:35 +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.OVERWRITE_TOGGLE.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.OVERWRITE_TOGGLE.DESCRIPTION")}
|
2023-09-09 15:58:21 +02:00
|
|
|
</p>
|
2023-08-10 12:17:35 +02:00
|
|
|
<input
|
|
|
|
type="checkbox"
|
2023-08-26 09:27:15 +02:00
|
|
|
className="toggle"
|
2023-08-10 12:17:35 +02:00
|
|
|
checked={overwrite}
|
|
|
|
onClick={() => {
|
2023-08-30 06:54:16 +02:00
|
|
|
setOverwrite((oldValue: boolean) => {
|
|
|
|
if (oldValue) {
|
2023-08-10 12:17:35 +02:00
|
|
|
localStorage.removeItem("overwrite");
|
2023-08-30 06:54:16 +02:00
|
|
|
return false;
|
|
|
|
} else {
|
|
|
|
return true;
|
2023-08-10 12:17:35 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
localStorage.setItem("overwrite", JSON.stringify(!overwrite));
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
2023-09-18 20:30:43 +02:00
|
|
|
export default OverwriteToggle;
|