// useLibs

import { UserClass } from 'esoftplay/cache/user/class/import';
import useGlobalState, { useGlobalReturn } from 'esoftplay/global';



export interface EventTransactionArgs {

}
export interface EventTransactionProps {

}
export interface EventTransactionReturn {
  getTrxId: () => string
}

const stateTrxId = useGlobalState<number>(undefined, { persistKey: 'event/transaction' })

export function state(): useGlobalReturn<any> {
  return stateTrxId
}

export function createTrxId() {
  let user = UserClass.state().get()
  let time = (new Date().getTime() / 1000).toFixed()
  return time + "" + user?.id + "" + (Math.random() * 101).toFixed(0)
}

export default function m(): EventTransactionReturn {
  return {
    getTrxId: createTrxId
  }
}