[UI] Create manufacturer part (#11792)
- Create new manufacturer part from supplier part form - Closes https://github.com/inventree/InvenTree/issues/10924
This commit is contained in:
parent
389e49c218
commit
e43d619d69
|
|
@ -12,7 +12,7 @@ import {
|
|||
IconPackage,
|
||||
IconPhone
|
||||
} from '@tabler/icons-react';
|
||||
import { useMemo } from 'react';
|
||||
import { useMemo, useState } from 'react';
|
||||
|
||||
/**
|
||||
* Field set for SupplierPart instance
|
||||
|
|
@ -26,6 +26,8 @@ export function useSupplierPartFields({
|
|||
manufacturerPartId?: number;
|
||||
partId?: number;
|
||||
}) {
|
||||
const [part, setPart] = useState<any>({});
|
||||
|
||||
return useMemo(() => {
|
||||
const fields: ApiFormFieldSet = {
|
||||
part: {
|
||||
|
|
@ -35,6 +37,9 @@ export function useSupplierPartFields({
|
|||
part: partId,
|
||||
purchaseable: true,
|
||||
active: true
|
||||
},
|
||||
onValueChange: (value: any, record: any) => {
|
||||
setPart(record);
|
||||
}
|
||||
},
|
||||
manufacturer_part: {
|
||||
|
|
@ -50,6 +55,16 @@ export function useSupplierPartFields({
|
|||
...adjust.filters,
|
||||
part: adjust.data.part
|
||||
};
|
||||
},
|
||||
addCreateFields: {
|
||||
part: {
|
||||
value: part?.pk,
|
||||
disabled: !!part?.pk
|
||||
},
|
||||
manufacturer: {},
|
||||
MPN: {},
|
||||
description: {},
|
||||
link: {}
|
||||
}
|
||||
},
|
||||
supplier: {
|
||||
|
|
@ -82,7 +97,7 @@ export function useSupplierPartFields({
|
|||
};
|
||||
|
||||
return fields;
|
||||
}, [manufacturerId, manufacturerPartId, partId]);
|
||||
}, [manufacturerId, manufacturerPartId, partId, part]);
|
||||
}
|
||||
|
||||
export function useManufacturerPartFields() {
|
||||
|
|
|
|||
Loading…
Reference in New Issue