32 lines
1018 B
TypeScript
32 lines
1018 B
TypeScript
/* 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;
|
|
};
|