diff --git a/src/components/RecordModal.jsx b/src/components/RecordModal.jsx new file mode 100644 index 0000000..61b0ebb --- /dev/null +++ b/src/components/RecordModal.jsx @@ -0,0 +1,326 @@ +import { useEffect, useState, useCallback } from 'react'; +import { apiPatch, apiFetchOne } from '../lib/api'; +import { STATUS_COLORS } from '../lib/tables'; + +const READ_ONLY_FIELDS = new Set(['id', 'created_at', 'updated_at']); +const TIMESTAMP_RE = /(_at|_timestamp)$/; + +function isReadOnly(key) { + return READ_ONLY_FIELDS.has(key) || TIMESTAMP_RE.test(key); +} + +function FieldLabel({ name }) { + return ( + + {name.replace(/_/g, ' ')} + + ); +} + +function ReadOnlyValue({ fieldKey, value }) { + if (value == null || value === '') return —; + + if (Array.isArray(value)) { + if (value.length === 0) return []; + return ( +