첫 커밋
This commit is contained in:
31
src/shared/lib/hooks/use-device-uid.ts
Normal file
31
src/shared/lib/hooks/use-device-uid.ts
Normal file
@@ -0,0 +1,31 @@
|
||||
/* eslint-disable react-hooks/exhaustive-deps */
|
||||
/* eslint-disable @cspell/spellchecker */
|
||||
import { useEffect } from 'react';
|
||||
|
||||
import useLocalStorageState from 'use-local-storage-state';
|
||||
// import { useUpdateUserInfo } from '@/entities/user/lib/use-update-user-info';
|
||||
import { StorageKeys } from '@/shared/constants/local-storage';
|
||||
import { useStore } from '@/shared/model/store';
|
||||
|
||||
export const useDeviceUid = () => {
|
||||
let defaultUid = '';
|
||||
if (!window.ReactNativeWebView) {
|
||||
defaultUid = '1234567890';
|
||||
}
|
||||
const userInfo = useStore((state: any) => state.userSlice.userInfo);
|
||||
const [deviceUid] = useLocalStorageState(StorageKeys.DeviceUniqueId, { defaultValue: defaultUid });
|
||||
//const { updateUserInfo } = useUpdateUserInfo();
|
||||
|
||||
useEffect(() => {
|
||||
if (deviceUid.length < 1) {
|
||||
return;
|
||||
}
|
||||
if (userInfo?.appEsntlNo && userInfo?.appEsntlNo?.length > 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
// updateUserInfo((prev: any) => ({ ...prev, appEsntlNo: deviceUid }));
|
||||
}, [deviceUid]);
|
||||
|
||||
return deviceUid;
|
||||
};
|
||||
Reference in New Issue
Block a user