chore: show dates
This commit is contained in:
		| @@ -25,6 +25,23 @@ function extractTenantId(token) { | ||||
|   return ''; | ||||
| } | ||||
|  | ||||
| function formatDateSafe(value) { | ||||
|   if (!value) return '—'; | ||||
|   // Accept Date instance, ISO string, or numeric timestamp | ||||
|   const d = value instanceof Date ? value : new Date(value); | ||||
|   if (Number.isNaN(d.getTime())) return '—'; | ||||
|   // Treat placeholder/default dates as empty | ||||
|   const year = d.getUTCFullYear(); | ||||
|   if (year <= 1971) return '—'; | ||||
|   return new Intl.DateTimeFormat(undefined, { | ||||
|     year: 'numeric', | ||||
|     month: 'short', | ||||
|     day: '2-digit', | ||||
|     hour: '2-digit', | ||||
|     minute: '2-digit' | ||||
|   }).format(d); | ||||
| } | ||||
|  | ||||
| export default function AddOrEditCategoryForm({ onAdd, initialData, onCancel, materials: materialsProp = [], initialMaterialNames = [] }) { | ||||
|   const { user } = useAuth(); | ||||
|   const token = user?.thalosToken || localStorage.getItem('thalosToken'); | ||||
| @@ -349,9 +366,9 @@ const tagLabelById = useMemo(() => { | ||||
|  | ||||
|       {form._Id || form.id ? ( | ||||
|         <Box sx={{ display: 'grid', gridTemplateColumns: { xs: '1fr', md: '1fr 1fr' }, gap: 2, mt: 2 }}> | ||||
|           <TextField label="Created At" value={form.createdAt ? new Date(form.createdAt).toLocaleString() : '—'} InputProps={{ readOnly: true }} fullWidth /> | ||||
|           <TextField label="Created At" value={formatDateSafe(form.createdAt)} InputProps={{ readOnly: true }} fullWidth /> | ||||
|           <TextField label="Created By" value={form.createdBy ?? '—'} InputProps={{ readOnly: true }} fullWidth /> | ||||
|           <TextField label="Updated At" value={form.updatedAt ? new Date(form.updatedAt).toLocaleString() : '—'} InputProps={{ readOnly: true }} fullWidth /> | ||||
|           <TextField label="Updated At" value={formatDateSafe(form.updatedAt)} InputProps={{ readOnly: true }} fullWidth /> | ||||
|           <TextField label="Updated By" value={form.updatedBy ?? '—'} InputProps={{ readOnly: true }} fullWidth /> | ||||
|         </Box> | ||||
|       ) : null} | ||||
|   | ||||
| @@ -84,6 +84,10 @@ export default function Categories() { | ||||
|       materialNames: typeof r.material === 'string' | ||||
|         ? r.material.split(',').map(s => s.trim()).filter(Boolean) | ||||
|         : Array.isArray(r.material) ? r.material : [], | ||||
|       createdAt: r.createdAt ?? null, | ||||
|       createdBy: r.createdBy ?? null, | ||||
|       updatedAt: r.updatedAt ?? null, | ||||
|       updatedBy: r.updatedBy ?? null, | ||||
|     }); | ||||
|     setOpen(true); | ||||
|   }; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Rodolfo Ruiz
					Rodolfo Ruiz