@uniai-fe/next-providers 0.1.2 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uniai-fe/next-providers",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
4
4
  "description": "Next.js State Providers for UNIAI FE Projects",
5
5
  "type": "module",
6
6
  "private": false,
@@ -10,9 +10,9 @@
10
10
  "publishConfig": {
11
11
  "access": "public"
12
12
  },
13
- "packageManager": "pnpm@10.22.0",
13
+ "packageManager": "pnpm@10.23.0",
14
14
  "engines": {
15
- "node": ">=22",
15
+ "node": ">=24",
16
16
  "pnpm": ">=10"
17
17
  },
18
18
  "author": {
@@ -63,9 +63,9 @@
63
63
  "@uniai-fe/util-jotai": "workspace:*",
64
64
  "@uniai-fe/ui-legacy": "workspace:*",
65
65
  "@uniai-fe/i18n": "workspace:*",
66
- "@tanstack/react-query": "^5.90.8",
66
+ "@tanstack/react-query": "^5.90.10",
67
67
  "@types/node": "^24.10.1",
68
- "@types/react": "^19.2.4",
68
+ "@types/react": "^19.2.7",
69
69
  "@types/react-dom": "^19.2.3",
70
70
  "airtable": "^0.12.2",
71
71
  "eslint": "^9.39.1",
@@ -1,7 +1,12 @@
1
1
  "use client";
2
2
 
3
3
  import { useCallback, useEffect } from "react";
4
- import { setServerState } from "@uniai-fe/util-jotai";
4
+
5
+ import { string } from "@uniai-fe/util-functions";
6
+ import { postFetchServerState } from "@uniai-fe/util-jotai";
7
+
8
+ const SYSTEM_LOCALE_KEY = "systemLocale";
9
+ const DEFAULT_LOCALE = "ko";
5
10
 
6
11
  /**
7
12
  * 쿠키 요청값 업데이트
@@ -13,16 +18,32 @@ export default function SetQueryCookie() {
13
18
  /**
14
19
  * 언어설정 쿠키 요청값 업데이트
15
20
  */
16
- const setLocaleCookie = useCallback(async () => {
21
+ const syncLocaleCookie = useCallback(async () => {
17
22
  if (typeof window === "undefined") return;
18
- const locale = localStorage.getItem("systemLocale");
19
- await setServerState("systemLocale", locale, "ko");
23
+
24
+ try {
25
+ const locale = localStorage.getItem(SYSTEM_LOCALE_KEY) ?? DEFAULT_LOCALE;
26
+ await postFetchServerState({
27
+ key: SYSTEM_LOCALE_KEY,
28
+ value: string(locale),
29
+ });
30
+ } catch (error) {
31
+ console.error("[SetQueryCookie] Failed to sync locale cookie", error);
32
+ }
20
33
  }, []);
21
34
 
22
35
  // 클라이언트에서 실행
23
36
  useEffect(() => {
24
- setLocaleCookie();
25
- }, [setLocaleCookie]);
37
+ const handleStorage = (event: StorageEvent) => {
38
+ if (typeof event.key === "string" && event.key === SYSTEM_LOCALE_KEY) {
39
+ syncLocaleCookie();
40
+ }
41
+ };
42
+
43
+ syncLocaleCookie();
44
+ window.addEventListener("storage", handleStorage);
45
+ return () => window.removeEventListener("storage", handleStorage);
46
+ }, [syncLocaleCookie]);
26
47
 
27
48
  return null;
28
49
  }