This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
import React, { ReactNode, useContext, useState } from "react"
|
||||
import { useEffect } from "react"
|
||||
import React, { ReactNode, useContext, useEffect, useState } from "react"
|
||||
import { useJwt } from "react-jwt";
|
||||
import { deleteToken, getToken, storeToken } from "../Utils";
|
||||
|
||||
@@ -16,7 +15,7 @@ type ContextProps = {
|
||||
|
||||
const authContext = React.createContext<AuthContextProps | null>(null);
|
||||
|
||||
export function ProvideAuth(props: ContextProps) {
|
||||
export function ProvideAuth(props: Readonly<ContextProps>) {
|
||||
const auth = useProvideAuth();
|
||||
return <authContext.Provider value={auth}>{props.children}</authContext.Provider>
|
||||
}
|
||||
@@ -29,7 +28,7 @@ function useProvideAuth(): AuthContextProps {
|
||||
const [loginName, setLoginName] = useState<string | undefined>();
|
||||
const [trusted, setTrusted] = useState<boolean | undefined>();
|
||||
const [token, setToken] = useState<string | undefined>(getToken());
|
||||
const { decodedToken } = useJwt(token || '');
|
||||
const { decodedToken } = useJwt(token ?? '');
|
||||
|
||||
useEffect(() => {
|
||||
if (token && token.length > 0) {
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import React, { ReactNode, useContext, useState } from "react"
|
||||
import { useEffect } from "react"
|
||||
import React, { ReactNode, useContext, useEffect, useState } from "react"
|
||||
|
||||
const BANK_ACCOUNT_NUMBER_KEY = 'bank_account_number';
|
||||
const BANK_ACCOUNT_HOLDER_KEY = 'bank_account_holder_name';
|
||||
@@ -20,7 +19,7 @@ type ContextProps = {
|
||||
|
||||
const settingsContext = React.createContext<SettingsContextProps | null>(null);
|
||||
|
||||
export function ProvideSettings(props: ContextProps) {
|
||||
export function ProvideSettings(props: Readonly<ContextProps>) {
|
||||
const settings = useProvideSettings();
|
||||
return <settingsContext.Provider value={settings}>{props.children}</settingsContext.Provider>
|
||||
}
|
||||
@@ -45,7 +44,7 @@ function useProvideSettings(): SettingsContextProps {
|
||||
}
|
||||
const hideSoups = localStorage.getItem(HIDE_SOUPS_KEY);
|
||||
if (hideSoups !== null) {
|
||||
setHideSoups(hideSoups === 'true' ? true : false);
|
||||
setHideSoups(hideSoups === 'true');
|
||||
}
|
||||
}, [])
|
||||
|
||||
|
||||
@@ -18,8 +18,3 @@ export const SocketContext = React.createContext();
|
||||
export const EVENT_CONNECT = 'connect';
|
||||
export const EVENT_DISCONNECT = 'disconnect';
|
||||
export const EVENT_MESSAGE = 'message';
|
||||
// export const EVENT_CONFIG = 'config';
|
||||
// export const EVENT_TOASTER = 'toaster';
|
||||
// export const EVENT_VOTING = 'voting';
|
||||
// export const EVENT_VOTE_CONFIG = 'voteSettings';
|
||||
// export const EVENT_ADMIN = 'admin';
|
||||
|
||||
Reference in New Issue
Block a user