로그인한 사용자의 uuid 찾기

This commit is contained in:
leedj312
2025-10-29 11:06:40 +09:00
parent 231c8a213e
commit 631ffa1727
+28 -1
View File
@@ -1,5 +1,6 @@
import { fetchType, getFetchWithCount } from "@/components/lib/api";
import { getUserInfo } from "@common/components/api";
import { getCookie } from "@common/components/lib";
import toast from "react-hot-toast";
export type authState = {
@@ -10,6 +11,7 @@ export type authState = {
mdfcnAuthrtYn: string;
delAuthrtYn: string;
laeSeCd: string;
myUUID?: string;
};
};
@@ -23,14 +25,15 @@ export const authStateExport: authState = {
mdfcnAuthrtYn: "Y",
delAuthrtYn: "Y",
laeSeCd: "",
myUUID:''
},
};
export type authActions = {
getMenuAuthrts: (menuCd: number) => void;
getLaeSeCdCheck: () => Promise<void>;
getMyUUID: () => Promise<string |undefined>;
};
export const authActionsExport: (set: any, get: any) => authActions = (
set: any,
get: any
@@ -83,5 +86,29 @@ export const authActionsExport: (set: any, get: any) => authActions = (
console.error("laeSeCd check error", e);
}
},
getMyUUID: async () => {
try{
const cached = get().auth.myUUID;
if (cached && cached !== "") {
return cached;
}
const tokenId = getCookie("token-id");
set((state: authState) => ({
...state,
auth: {
...state.auth,
myUUID: tokenId,
},
}));
return tokenId;
}catch(e){
console.error("getMyUUID error", e);
return undefined;
}
},
};
};