From 027041cc60d70a904ce35860175009f54df6ad0a Mon Sep 17 00:00:00 2001 From: Francisco Tobar Date: Wed, 27 Nov 2024 10:00:13 -0600 Subject: [PATCH 1/2] refactor: disabled if builder not operational --- .../builder/BuilderRewardsSettingsForm.tsx | 41 ++++++++++++++----- .../context/BuilderSettingsContext.tsx | 4 ++ .../settings/builder/hooks/index.ts | 1 + .../hooks/useGetIsBuilderOperational.ts | 17 ++++++++ .../settings/builder/index.ts | 2 + 5 files changed, 55 insertions(+), 10 deletions(-) create mode 100644 src/app/collective-rewards/settings/builder/hooks/useGetIsBuilderOperational.ts diff --git a/src/app/collective-rewards/settings/builder/BuilderRewardsSettingsForm.tsx b/src/app/collective-rewards/settings/builder/BuilderRewardsSettingsForm.tsx index c102e38b..5a9298e2 100644 --- a/src/app/collective-rewards/settings/builder/BuilderRewardsSettingsForm.tsx +++ b/src/app/collective-rewards/settings/builder/BuilderRewardsSettingsForm.tsx @@ -7,8 +7,9 @@ import { FC, useEffect, useState } from 'react' import { useForm } from 'react-hook-form' import { GoRocket } from 'react-icons/go' import { z } from 'zod' -import { percentageToWei } from '../utils' +import { percentageToWei } from '@/app/collective-rewards/settings/utils' import { useBuilderSettingsContext } from './context' +import { Popover } from '@/components/Popover' const formSchema = z.object({ reward: z @@ -39,9 +40,10 @@ const formSchema = z.object({ export const BuilderRewardsSettingsForm: FC = () => { const router = useRouter() const [backButtonName, setBackButtonName] = useState('Cancel') - const { + let { current: { refetch, isLoading: isCurrentRewardsLoading }, update: { isSuccess, setNewReward, isPending }, + isBuilderOperational, } = useBuilderSettingsContext() const form = useForm>({ @@ -84,7 +86,12 @@ export const BuilderRewardsSettingsForm: FC = () => { {isCurrentRewardsLoading ? ( ) : ( - + )} @@ -92,14 +99,28 @@ export const BuilderRewardsSettingsForm: FC = () => { )} >
-
+ } + size="small" + position="top" + trigger="hover" + disabled={isBuilderOperational} > - Save changes - + +