// to be used only when the defaults need to be hard reset
import {
	setSlippage,
	toggleAutoSlippage,
	updateLocalStorage,
} from "@store/settingsSlice";
import { useEffect } from "react";
import { useDispatch } from "react-redux";

const bungeeLocalStore =
	typeof window !== "undefined"
		? JSON.parse(localStorage.getItem("bungee") || "{}")
		: {};

export const resetUserDefaults = () => {
	const dispatch = useDispatch();
	const defaultSlippageReset = bungeeLocalStore?.settings?.slippageReset2611;

	useEffect(() => {
		if (!defaultSlippageReset && dispatch) {
			dispatch(setSlippage("auto"));
			dispatch(toggleAutoSlippage(true));
			updateLocalStorage("settings", "slippageReset2611", true);
		}
	}, [defaultSlippageReset, dispatch]);
};
