import { FormControl } from 'components/FormControl'
import { AddressInput, NumberInput } from 'components/forms/FormInput'
import { useEffect, useId, useMemo } from 'react'
import { FaMinus, FaPlus } from 'react-icons/fa'
import { useInputState, useNumberInputState } from './FormInput.hooks'
export interface Attribute {
address: string
weight: number
}
export interface MemberAttributesProps {
title: string
subtitle?: string
isRequired?: boolean
attributes: [string, Attribute][]
onAdd: () => void
onChange: (key: string, attribute: Attribute) => void
onRemove: (key: string) => void
}
export function MemberAttributes(props: MemberAttributesProps) {
const { title, subtitle, isRequired, attributes, onAdd, onChange, onRemove } = props
const calculateMemberPercent = (id: string) => {
const total = attributes.reduce((acc, [, { weight }]) => acc + (weight ? weight : 0), 0)
// return attributes.map(([id, { weight }]) => [id, weight / total])
const memberWeight = attributes.find(([memberId]) => memberId === id)?.[1].weight
return memberWeight ? memberWeight / total : 0
}
return (