Skip to content

Commit

Permalink
refactor: pr comments
Browse files Browse the repository at this point in the history
  • Loading branch information
franciscotobar committed Nov 27, 2024
1 parent c0f0b85 commit 05282b1
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ import {
import { createContext, FC, ReactNode, useContext } from 'react'
import { Address } from 'viem'
import { useAccount } from 'wagmi'
import { useGetIsBuilderOperational } from '@/app/collective-rewards/settings'
import { useBuilderContext } from '@/app/collective-rewards/user'
import { isBuilderActive } from '@/app/collective-rewards/utils'

type BackerRewardsPercentageContext = {
update: SetBackerRewardsForBuilder
Expand All @@ -24,11 +25,13 @@ const BuilderSettingsContext = createContext<BackerRewardsPercentageContext>(
export const useBuilderSettingsContext = () => useContext(BuilderSettingsContext)

export const BuilderSettingsProvider: FC<{ children: ReactNode }> = ({ children }) => {
const { getBuilderByAddress } = useBuilderContext()
const { address } = useAccount()
const current = useGetBackerRewardsForBuilder(address as Address)
const update = useSetBackerRewardsForBuilder()
const rewardPercentageToApply = useGetRewardPercentageToApply(address as Address)
const { data: isBuilderOperational } = useGetIsBuilderOperational(address as Address)
const builder = getBuilderByAddress(address as Address)
const isBuilderOperational = builder ? isBuilderActive(builder) : false

const contextValue: BackerRewardsPercentageContext = {
update,
Expand Down
1 change: 0 additions & 1 deletion src/app/collective-rewards/settings/builder/hooks/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
export * from './useBuilderConfig'
export * from './useGetIsBuilderOperational'

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { ProgressBar } from '@/components/ProgressBar'
import { Button } from '@/components/Button'
import { BuilderStateFlags } from '@/app/collective-rewards/types'
import { AllocationsContext } from '@/app/collective-rewards/allocations/context'
import { isBuilderActive } from '@/app/collective-rewards/utils'

export function getFormattedCurrency(value: number, symbol: string) {
const formattedCurrency = formatCurrency(value, symbol)
Expand Down Expand Up @@ -207,12 +208,7 @@ export const ActionCell: FC<ActionCellProps> = ({ tableHeader: { className }, bu
console.log('Builder not found in selection') // TODO: handle this case better
return
}
return (
builder.stateFlags &&
builder.stateFlags.kycApproved &&
builder.stateFlags.communityApproved &&
!builder.stateFlags.paused
)
return isBuilderActive(builder)
}, [builder])

const selectBuilder = () => {
Expand Down
1 change: 1 addition & 0 deletions src/app/collective-rewards/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ export * from './getCoinbaseAddress'
export * from './getMostAdvancedProposal'
export * from './handleErrors'
export * from './removeBrackets'
export * from './isBuilderActive'

0 comments on commit 05282b1

Please sign in to comment.