import React from 'react';
import { Badge } from '@/components/ui/badge';
import { cn } from '@/lib/utils';
// Simple renderers without importing components
export const columnRenderers = {
// Status badge renderer
status: (colorMap = {}, defaultColor = 'bg-gray-100 text-gray-800') => {
return (value) => {
if (!value) return -;
const color = colorMap[value] || defaultColor;
return (
{value}
);
};
},
// Image renderer
image: (className = 'h-16 w-20 rounded-md object-cover shadow-sm', fallbackSrc = 'https://placehold.co/200x150?text=Image+Not+Found') => {
return (_, row, key) => {
if (!row[key]) return
No image
;
const imageSrc = typeof row[key] === 'string' && row[key].startsWith('http')
? row[key]
: `/storage/${row[key]}`;
return (

{
e.currentTarget.src = fallbackSrc;
}}
/>
);
};
},
// Price renderer
price: (currency = 'USD', locale = 'en-US') => {
return (value) => {
if (value === null || value === undefined) return -;
const numValue = typeof value === 'string' ? parseFloat(value) : value;
return (
{numValue.toLocaleString(locale, { style: 'currency', currency })}
);
};
},
// Date renderer
date: (format = { dateStyle: 'medium' }, locale = 'en-US') => {
return (value) => {
if (!value) return -;
try {
const date = new Date(value);
return {date.toLocaleDateString(locale, format)};
} catch (e) {
return {value};
}
};
},
// Boolean renderer
boolean: () => {
return (value) => {value ? 'Yes' : 'No'};
},
// Relation renderer
relation: (field) => {
return (_, row, key) => {
const relation = row[key];
return relation ? {relation[field]} : -;
};
}
};