mirror of
https://github.com/luxfi/explore.git
synced 2026-09-24 00:28:18 +00:00
* refactor token instance page title * add menu item and modal with recaptcha * initialize refresh and show loading state * handle error state * fix metadata atributes parser * refactoring * tests
41 lines
947 B
TypeScript
41 lines
947 B
TypeScript
import React from 'react';
|
|
|
|
interface MetadataUpdateProviderProps {
|
|
children: React.ReactNode;
|
|
}
|
|
|
|
interface TMetadataUpdateContext {
|
|
status: Status;
|
|
setStatus: (status: Status) => void;
|
|
}
|
|
|
|
export const MetadataUpdateContext = React.createContext<TMetadataUpdateContext | null>(null);
|
|
|
|
type Status = 'INITIAL' | 'MODAL_OPENED' | 'WAITING_FOR_RESPONSE' | 'SUCCESS' | 'ERROR';
|
|
|
|
export function MetadataUpdateProvider({ children }: MetadataUpdateProviderProps) {
|
|
|
|
const [ status, setStatus ] = React.useState<Status>('INITIAL');
|
|
|
|
const value = React.useMemo(() => {
|
|
return {
|
|
status,
|
|
setStatus,
|
|
};
|
|
}, [ status ]);
|
|
|
|
return (
|
|
<MetadataUpdateContext.Provider value={ value }>
|
|
{ children }
|
|
</MetadataUpdateContext.Provider>
|
|
);
|
|
}
|
|
|
|
export function useMetadataUpdateContext() {
|
|
const context = React.useContext(MetadataUpdateContext);
|
|
if (context === undefined) {
|
|
return null;
|
|
}
|
|
return context;
|
|
}
|