Skip to content

Commit

Permalink
fix: use form state to update entity
Browse files Browse the repository at this point in the history
  • Loading branch information
collinlokken committed Jan 8, 2024
1 parent df07a39 commit fbb56b3
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
DeleteSoftButton,
TAttribute,
} from '@development-framework/dm-core'
import { useFormContext } from 'react-hook-form'

interface PrimitiveArrayProps {
uiAttribute: TUiAttributeObject | undefined
Expand Down Expand Up @@ -35,9 +36,10 @@ const PrimitiveArray = ({
onChange,
}: PrimitiveArrayProps) => {
const [hovering, setHovering] = useState<number>(-1)
const methods = useFormContext()

const updateValues = (index: number, newValue: TPrimitive): void => {
const newValues = [...data]
const newValues = [...methods.getValues(namePath)]
switch (attribute.attributeType) {
case 'boolean':
newValues[index] = newValue
Expand All @@ -53,7 +55,7 @@ const PrimitiveArray = ({
}
}
const removeItem = (index: number) => {
const newValues = [...data]
const newValues = [...methods.getValues(namePath)]
newValues.splice(index, 1)
onChange(newValues)
}
Expand Down

0 comments on commit fbb56b3

Please sign in to comment.