import type { FormScreenField } from '../../../api/types'; import { StorePotentialGrid } from './StorePotentialGrid'; import { OrderGrid } from './OrderGrid'; import { PotentialMiningGrid } from './PotentialMiningGrid'; export interface SmartGridFieldProps { label: string; columns: FormScreenField[]; value: Record[]; onChange: (val: Record[]) => void; totalBagsValue?: number; totalKgsValue?: number; showErrors?: boolean; disableAddRow?: boolean; hideTotal?: boolean; readOnlyCols?: string[]; isPotentialMining?: boolean; // We will pass this from DynamicForm } export function SmartGridField(props: SmartGridFieldProps) { const { label, isPotentialMining, disableAddRow } = props; // Use PotentialMiningGrid if explicitly requested or if we're disabling add row (as a fallback heuristic) if (isPotentialMining || (disableAddRow && label.toLowerCase().includes('potential'))) { return ; } // Use OrderGrid if it's an order/product details grid const isOrderGrid = label.toLowerCase().includes('order') || label.toLowerCase().includes('product'); if (isOrderGrid) { return ; } // Use StorePotentialGrid for simpler grids like Store adding potential return ; }