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