|
|
@ -1,15 +1,32 @@ |
|
|
|
import React from "react"; |
|
|
|
import { createStore } from 'zustand/vanilla' |
|
|
|
import { persist, createJSONStorage } from 'zustand/middleware' |
|
|
|
import { getTranslation } from "../core/i18n/I18NHandler"; |
|
|
|
|
|
|
|
var randomId = 0; |
|
|
|
|
|
|
|
export const participantIdLogState = createStore( |
|
|
|
persist( |
|
|
|
() => ({ |
|
|
|
participant_id: "" |
|
|
|
}), |
|
|
|
{ |
|
|
|
name: 'participant-id-storage', // name of the item in the storage (must be unique) |
|
|
|
storage: createJSONStorage(() => sessionStorage), // (optional) by default, 'localStorage' is used |
|
|
|
}, |
|
|
|
), |
|
|
|
) |
|
|
|
|
|
|
|
const { getState, setState } = participantIdLogState; |
|
|
|
|
|
|
|
function RandomIDComponent() { |
|
|
|
randomId = Math.floor(Math.random() * 89999) + 10000; |
|
|
|
setState({ participant_id: "" + randomId }) |
|
|
|
return (<div><h3>Your ID:</h3><p>{randomId}</p></div>); |
|
|
|
} |
|
|
|
|
|
|
|
export function getUserID() { |
|
|
|
return randomId; |
|
|
|
return getState().participant_id; |
|
|
|
} |
|
|
|
|
|
|
|
export default RandomIDComponent; |