From 63326512fc08c93c292d3936a76a814fc8030d60 Mon Sep 17 00:00:00 2001 From: Nikita Yutanov Date: Tue, 30 Jan 2024 17:20:31 +0300 Subject: [PATCH] Refactor hooks compatability --- .../shared/ui/labeled-checkbox/labeled-checkbox.tsx | 5 ++--- utils/gear-hooks/src/hooks/api/useSendMessage.ts | 3 ++- .../src/hooks/api/voucher/use-voucher-status.ts | 11 +++-------- 3 files changed, 7 insertions(+), 12 deletions(-) diff --git a/idea/frontend/src/shared/ui/labeled-checkbox/labeled-checkbox.tsx b/idea/frontend/src/shared/ui/labeled-checkbox/labeled-checkbox.tsx index 017bb05c13..71510e6c3d 100644 --- a/idea/frontend/src/shared/ui/labeled-checkbox/labeled-checkbox.tsx +++ b/idea/frontend/src/shared/ui/labeled-checkbox/labeled-checkbox.tsx @@ -8,19 +8,18 @@ type Props = { name: string; label: string; inputLabel: string; - value?: string; direction?: InputProps['direction']; gap?: InputProps['gap']; children?: ReactNode; }; -const LabeledCheckbox = ({ name, label, inputLabel, value, direction = 'x', gap, children }: Props) => { +const LabeledCheckbox = ({ name, label, inputLabel, direction = 'x', gap, children }: Props) => { const { register } = useFormContext(); return (
- + {children}
diff --git a/utils/gear-hooks/src/hooks/api/useSendMessage.ts b/utils/gear-hooks/src/hooks/api/useSendMessage.ts index c1a9ceba87..b462974d91 100644 --- a/utils/gear-hooks/src/hooks/api/useSendMessage.ts +++ b/utils/gear-hooks/src/hooks/api/useSendMessage.ts @@ -3,11 +3,12 @@ import { web3FromSource } from '@polkadot/extension-dapp'; import { EventRecord } from '@polkadot/types/interfaces'; import { AnyJson, IKeyringPair, ISubmittableResult } from '@polkadot/types/types'; import { HexString } from '@polkadot/util/types'; +import { SubmittableExtrinsic } from '@polkadot/api/types'; import { useContext } from 'react'; + import { AccountContext, AlertContext, ApiContext } from 'context'; import { DEFAULT_ERROR_OPTIONS, DEFAULT_SUCCESS_OPTIONS } from 'consts'; import { getExtrinsicFailedMessage } from 'utils'; -import { SubmittableExtrinsic } from '@polkadot/api/types'; type UseSendMessageOptions = { disableAlerts?: boolean; diff --git a/utils/gear-hooks/src/hooks/api/voucher/use-voucher-status.ts b/utils/gear-hooks/src/hooks/api/voucher/use-voucher-status.ts index 3ebccdbe03..429e3adebf 100644 --- a/utils/gear-hooks/src/hooks/api/voucher/use-voucher-status.ts +++ b/utils/gear-hooks/src/hooks/api/voucher/use-voucher-status.ts @@ -1,16 +1,11 @@ -import { useContext } from 'react'; - -import { ApiContext } from 'context'; - import { useApproxBlockTimestamp } from '../block'; function useVoucherStatus(expirationBlock: number | undefined) { - const { isV110Runtime } = useContext(ApiContext); const { blockTimestamp, isBlockTimestampReady } = useApproxBlockTimestamp(expirationBlock); - const expirationTimestamp = isV110Runtime ? blockTimestamp : undefined; - const isVoucherStatusReady = isV110Runtime ? isBlockTimestampReady : true; - const isVoucherActive = isV110Runtime ? !!expirationTimestamp && expirationTimestamp > Date.now() : true; + const expirationTimestamp = blockTimestamp; + const isVoucherStatusReady = isBlockTimestampReady; + const isVoucherActive = !!expirationTimestamp && expirationTimestamp > Date.now(); return { expirationTimestamp, isVoucherStatusReady, isVoucherActive }; }