mirror of
https://github.com/pezkuwichain/pwap.git
synced 2026-08-03 17:25:50 +00:00
60a800b33e
- Clone Polkadot.js Apps repository - Update package.json with Pezkuwi branding - Add Pezkuwi endpoint to production chains (wss://pezkuwichain.app:9944) - Create comprehensive README for SDK UI - Set up project structure with all packages Next steps: - Apply Kurdistan colors (Kesk, Sor, Zer, Spi + Black) to UI theme - Replace logos with Pezkuwi branding - Test build and deployment
44 lines
1.1 KiB
TypeScript
44 lines
1.1 KiB
TypeScript
// Copyright 2017-2025 @polkadot/react-hooks authors & contributors
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
import type { CodeStored } from './types.js';
|
|
|
|
import { useEffect, useState } from 'react';
|
|
|
|
import { createNamedHook, useIsMountedRef } from '@polkadot/react-hooks';
|
|
|
|
import store from './store.js';
|
|
|
|
interface UseCodes {
|
|
allCodes: CodeStored[];
|
|
codeTrigger: number;
|
|
}
|
|
|
|
const DEFAULT_STATE: UseCodes = { allCodes: [], codeTrigger: Date.now() };
|
|
|
|
function useCodesImpl (): UseCodes {
|
|
const mountedRef = useIsMountedRef();
|
|
const [state, setState] = useState<UseCodes>(DEFAULT_STATE);
|
|
|
|
useEffect(
|
|
(): void => {
|
|
const triggerUpdate = (): void => {
|
|
mountedRef.current && setState({
|
|
allCodes: store.getAllCode(),
|
|
codeTrigger: Date.now()
|
|
});
|
|
};
|
|
|
|
store.on('new-code', triggerUpdate);
|
|
store.on('removed-code', triggerUpdate);
|
|
store.loadAll(triggerUpdate);
|
|
},
|
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
[]
|
|
);
|
|
|
|
return state;
|
|
}
|
|
|
|
export const useCodes = createNamedHook('useCodes', useCodesImpl);
|