- {Object.entries(data).map(([subKey, value], index) => (
-
-
{subKey}:{" "}
-
- {typeof value === 'object' ? JSON.stringify(value, null, 2) : String(value)}
-
+ const StockTableComponent: React.FC<{ data: StockData }> = ({ data }) => (
+
+ {Object.entries(data).map(([color, sizes], index) => (
+
+
{color}
+
+ {Object.entries(sizes).map(([size, quantity], sizeIndex) => (
+
+ {size}: {quantity} {sizeIndex % 2 !== 0 &&
}{" "}
+ {/* Add line break after every two sizes */}
+
+ ))}
+
))}
);
- const ObjectComponentCell = (row, data: string) => (
-
+ const StockTableComponentCell = (row, data: StockData) => (
+
);
- return ObjectComponentCell;
-
+ return StockTableComponentCell;
}
+
+ interface StockData {
+ [color: string]: {
+ [size: string]: number;
+ };
+ }
+
if (typeof element[key] == "object") {
const DateComponent: React.FC<{ children?: React.ReactNode }> = ({
children,