attributeId to FieldId
This commit is contained in:
@@ -22,11 +22,11 @@ const ManageAttribute: FC<Props> = (props) => {
|
||||
|
||||
const handleChange = (attributeId: string, value: string) => {
|
||||
const attribute = formik.values.attributes
|
||||
const index: number = attribute.findIndex(o => o.attributeId === attributeId)
|
||||
const index: number = attribute.findIndex(o => o.fieldId === attributeId)
|
||||
if (index > -1) {
|
||||
attribute[index].value = value
|
||||
} else {
|
||||
attribute.push({ attributeId: attributeId, value: value })
|
||||
attribute.push({ fieldId: attributeId, value: value })
|
||||
}
|
||||
formik.setFieldValue('attributes', attribute)
|
||||
}
|
||||
@@ -61,7 +61,7 @@ const ManageAttribute: FC<Props> = (props) => {
|
||||
<div className='flex gap-5 flex-wrap'>
|
||||
{
|
||||
item.options?.map((value) => {
|
||||
const object = formik.values.attributes.find(o => o.attributeId === item.id)
|
||||
const object = formik.values.attributes.find(o => o.fieldId === item.id)
|
||||
return (
|
||||
<div key={value.id} className='flex gap-2 items-center'>
|
||||
<div>{value.value}</div>
|
||||
@@ -78,7 +78,7 @@ const ManageAttribute: FC<Props> = (props) => {
|
||||
</div>
|
||||
)
|
||||
else if (item.type === FieldTypeEnum.radio) {
|
||||
const object = formik.values.attributes.find(o => o.attributeId === item.id)
|
||||
const object = formik.values.attributes.find(o => o.fieldId === item.id)
|
||||
return (
|
||||
<div key={item.id} className='mt-6'>
|
||||
<div className='text-sm mb-3'>{item.name}</div>
|
||||
|
||||
@@ -21,7 +21,7 @@ export type RequestType = {
|
||||
productId?: string;
|
||||
quantity?: number;
|
||||
attributes: {
|
||||
attributeId: string;
|
||||
fieldId: string;
|
||||
value: string | number;
|
||||
}[];
|
||||
attachments: AttachmentsType[];
|
||||
|
||||
Reference in New Issue
Block a user