diff --git a/src/components/forms/fields/OrderGrid.tsx b/src/components/forms/fields/OrderGrid.tsx
index 71ded0f..27a54d6 100644
--- a/src/components/forms/fields/OrderGrid.tsx
+++ b/src/components/forms/fields/OrderGrid.tsx
@@ -345,10 +345,10 @@ export function OrderGrid({
const computedRowKgs = skuNum * bagsNum;
const isMissingProd = isCategorySelected && !currentProdVal.trim();
- const prodError = showErrors && isMissingProd ? 'Required' : undefined;
+ const prodError = showErrors && isMissingProd ? true : undefined;
const isMissingBags = isCategorySelected && (!currentBagsVal || Number(currentBagsVal) <= 0);
- const bagsError = showErrors && isMissingBags ? 'Required' : undefined;
+ const bagsError = showErrors && isMissingBags ? true : undefined;
return (
@@ -391,7 +391,7 @@ export function OrderGrid({
onChange={(e) => updateRowField(rowIdx, fieldId, e.target.value)}
disabled={!isCategorySelected && categoriesList.length > 0}
options={[
- { value: '', label: isCategorySelected || categoriesList.length === 0 ? 'Select product' : 'Select category first' },
+ { value: '', label: isCategorySelected || categoriesList.length === 0 ? (prodError ? 'Select product *' : 'Select product') : 'Select category first' },
...prodOptions
]}
error={prodError}
@@ -410,7 +410,7 @@ export function OrderGrid({
min={isMainBagsCol ? "1" : undefined}
value={numVal !== undefined && numVal !== null ? String(numVal) : ''}
onChange={(e) => updateRowField(rowIdx, fieldId, e.target.value)}
- placeholder={isMainBagsCol && isCategorySelected ? 'Bags' : '0'}
+ placeholder={isMainBagsCol ? (bagsError ? 'Bags *' : (isCategorySelected ? 'Bags' : '0')) : '0'}
error={isMainBagsCol ? bagsError : undefined}
className="w-full"
/>
diff --git a/src/components/reusable/Input.tsx b/src/components/reusable/Input.tsx
index 40d1354..1699d4b 100644
--- a/src/components/reusable/Input.tsx
+++ b/src/components/reusable/Input.tsx
@@ -4,7 +4,7 @@ import { cn } from '../../lib/cn';
export interface InputProps extends Omit, 'prefix'> {
label?: string;
hint?: string;
- error?: string;
+ error?: string | boolean;
/** Leading adornment, e.g. "₹". */
prefix?: ReactNode;
/** Trailing adornment, e.g. "/ year". */
@@ -52,8 +52,10 @@ export function Input({
/>
{suffix && {suffix}}
- {(hint || error) && (
- {error || hint}
+ {(hint || (typeof error === 'string' && error)) && (
+
+ {typeof error === 'string' ? error : hint}
+
)}
);
diff --git a/src/components/reusable/Select.tsx b/src/components/reusable/Select.tsx
index 6182029..be72480 100644
--- a/src/components/reusable/Select.tsx
+++ b/src/components/reusable/Select.tsx
@@ -12,7 +12,7 @@ export interface SelectOption {
export interface SelectProps extends SelectHTMLAttributes {
label?: string;
hint?: string;
- error?: string;
+ error?: string | boolean;
placeholder?: string;
/** Either strings or {value,label} objects. */
options?: Array;
@@ -247,8 +247,10 @@ export function Select({
))}
- {(hint || error) && (
- {error || hint}
+ {(hint || (typeof error === 'string' && error)) && (
+
+ {typeof error === 'string' ? error : hint}
+
)}
);