2
0
visuddhinanda 5 сар өмнө
parent
commit
98f8b50cb0

+ 19 - 0
dashboard-v4/dashboard/src/hooks/useSetting.ts

@@ -0,0 +1,19 @@
+import { useEffect, useState } from "react";
+import { GetUserSetting } from "../components/auth/setting/default";
+import { useAppSelector } from "../hooks";
+import { settingInfo } from "../reducers/setting";
+
+export function useSetting(key: string) {
+  const [commentaryLayout, setCommentaryLayout] = useState("column");
+  const settings = useAppSelector(settingInfo);
+
+  useEffect(() => {
+    const layoutCommentary = GetUserSetting(key, settings);
+
+    layoutCommentary &&
+      typeof layoutCommentary === "string" &&
+      setCommentaryLayout(layoutCommentary);
+  }, [key, settings]);
+
+  return commentaryLayout;
+}