Skip to content

Open-source manufacturing ERP, MES and QMS. Quoting, MRP, inventory, shop floor, quality and lot/serial traceability on one Postgres schema, with a REST API and MCP server. Self-host or use Carbon Cloud.

fix(purchasing): resolve React #310 hooks error when linking supplier to draft RFQ

Sidwebworksa772ffcfd03a
diff --git a/apps/erp/app/modules/purchasing/ui/PurchasingRfq/PurchasingRFQProperties.tsx b/apps/erp/app/modules/purchasing/ui/PurchasingRfq/PurchasingRFQProperties.tsx
index 93e95296e0..022a280dc3 100644
--- a/apps/erp/app/modules/purchasing/ui/PurchasingRfq/PurchasingRFQProperties.tsx
+++ b/apps/erp/app/modules/purchasing/ui/PurchasingRfq/PurchasingRFQProperties.tsx
@@ -55,6 +55,25 @@ const PurchasingRFQProperties = () => {
);
}, [allSuppliers]);
+ const renderSuppliersInlinePreview = useCallback(
+ (value: string[], _options: unknown, maxPreview = 5) => (
+ <AvatarGroup limit={maxPreview} className="relative z-10">
+ <AvatarGroupList>
+ {value.map((supplier, index: number) => (
+ <Avatar
+ key={index}
+ name={
+ allSuppliers.find((s) => s.id === supplier)?.name ?? supplier
+ }
+ />
+ ))}
+ </AvatarGroupList>
+ <AvatarOverflowIndicator />
+ </AvatarGroup>
+ ),
+ [allSuppliers]
+ );
+
// Get current supplier IDs from the RFQ
const currentSupplierIds = useMemo(() => {
return (
@@ -221,7 +240,7 @@ const PurchasingRFQProperties = () => {
label={t`Suppliers`}
options={supplierOptions}
value={currentSupplierIds}
- inline={SuppliersInlinePreview}
+ inline={renderSuppliersInlinePreview}
isReadOnly={isDisabled}
disabled={isDisabled}
onChange={(selected) => {
@@ -340,25 +359,4 @@ const PurchasingRFQProperties = () => {
);
};
-const SuppliersInlinePreview = (
- value: string[],
- options: { value: string; label: string; helper?: string }[],
- maxPreview = 5
-) => {
- const [suppliers] = useSuppliers();
- return (
- <AvatarGroup limit={maxPreview} className="relative z-10">
- <AvatarGroupList>
- {value.map((supplier, index: number) => (
- <Avatar
- key={index}
- name={suppliers.find((s) => s.id === supplier)?.name ?? supplier}
- />
- ))}
- </AvatarGroupList>
- <AvatarOverflowIndicator />
- </AvatarGroup>
- );
-};
-
export default PurchasingRFQProperties;