2024-09-01 17:31:45 +05:30
|
|
|
import { translationAtom } from "@/atoms/translations-atom";
|
2024-10-04 14:45:54 +05:30
|
|
|
import { overwriteAtom } from "@/atoms/user-settings-atom";
|
2024-09-01 17:31:45 +05:30
|
|
|
import { useAtom, useAtomValue } from "jotai";
|
2023-08-11 15:15:27 +05:30
|
|
|
import React, { useEffect } from "react";
|
2023-08-10 15:47:35 +05:30
|
|
|
|
2024-01-15 14:37:22 +05:30
|
|
|
const OverwriteToggle = () => {
|
|
|
|
const [overwrite, setOverwrite] = useAtom(overwriteAtom);
|
2024-09-01 17:31:45 +05:30
|
|
|
const t = useAtomValue(translationAtom);
|
2023-08-30 10:24:16 +05:30
|
|
|
|
2023-08-10 15:47:35 +05:30
|
|
|
return (
|
|
|
|
<div className="flex flex-col gap-2">
|
2024-09-01 17:31:45 +05:30
|
|
|
<p className="text-sm font-medium">
|
2024-09-03 13:04:58 +05:30
|
|
|
{t("SETTINGS.OVERWRITE_TOGGLE.TITLE")}
|
2024-09-01 17:31:45 +05:30
|
|
|
</p>
|
2023-09-09 19:28:21 +05:30
|
|
|
<p className="text-xs text-base-content/80">
|
2024-09-03 13:04:58 +05:30
|
|
|
{t("SETTINGS.OVERWRITE_TOGGLE.DESCRIPTION")}
|
2023-09-09 19:28:21 +05:30
|
|
|
</p>
|
2023-08-10 15:47:35 +05:30
|
|
|
<input
|
|
|
|
type="checkbox"
|
2023-08-26 12:57:15 +05:30
|
|
|
className="toggle"
|
2023-08-10 15:47:35 +05:30
|
|
|
checked={overwrite}
|
|
|
|
onClick={() => {
|
2023-08-30 10:24:16 +05:30
|
|
|
setOverwrite((oldValue: boolean) => {
|
|
|
|
if (oldValue) {
|
2023-08-10 15:47:35 +05:30
|
|
|
localStorage.removeItem("overwrite");
|
2023-08-30 10:24:16 +05:30
|
|
|
return false;
|
|
|
|
} else {
|
|
|
|
return true;
|
2023-08-10 15:47:35 +05:30
|
|
|
}
|
|
|
|
});
|
|
|
|
localStorage.setItem("overwrite", JSON.stringify(!overwrite));
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
2023-09-19 00:00:43 +05:30
|
|
|
export default OverwriteToggle;
|