Skip to content

Commit d1824d4

Browse files
Merge pull request #62 from KushagraJaiswar02/pr/record-detail-dynamic-fields
fix: display all dynamic fields in record detail panel
2 parents f8c293e + d85a7c3 commit d1824d4

1 file changed

Lines changed: 11 additions & 34 deletions

File tree

apps/web-dashboard/src/components/RowDetailDrawer.jsx

Lines changed: 11 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -158,12 +158,14 @@ export default function RowDetailDrawer({ isOpen, onClose, record, fields = [],
158158
gridTemplateColumns: isWideForm ? "repeat(2, 1fr)" : "1fr",
159159
gap: "1.25rem",
160160
}}>
161-
{fields.map((field) => (
161+
{Object.entries(record)
162+
.filter(([key]) => !['_id', '__v', 'createdAt', 'updatedAt'].includes(key))
163+
.map(([key, value]) => (
162164
<div
163-
key={field.key}
165+
key={key}
164166
className="form-group"
165167
style={{
166-
gridColumn: (isWideForm && (field.type === "String" && field.key.length > 20)) ? "span 2" : "auto"
168+
gridColumn: (isWideForm && typeof value === 'string' && value.length > 20) ? "span 2" : "auto"
167169
}}
168170
>
169171
<label className="form-label" style={{
@@ -174,38 +176,11 @@ export default function RowDetailDrawer({ isOpen, onClose, record, fields = [],
174176
color: "var(--color-text-secondary)"
175177
}}>
176178
<span style={{ display: "flex", alignItems: "center", gap: "6px" }}>
177-
{field.key}
179+
{key}
178180
</span>
179-
<span className="field-type-hint" style={{
180-
fontSize: "0.7rem",
181-
color: "var(--color-text-muted)",
182-
background: "rgba(255,255,255,0.05)",
183-
padding: "2px 6px",
184-
borderRadius: "4px"
185-
}}>{field.type}</span>
186181
</label>
187182

188-
{/* Read Only Input Field matching AddRecordDrawer */}
189-
{field.type === "Boolean" ? (
190-
<select
191-
className="form-select"
192-
disabled
193-
value={String(record[field.key] ?? "")}
194-
style={{ cursor: "default", appearance: "none" /* removes dropdown arrow */}}
195-
>
196-
<option value="">Empty</option>
197-
<option value="true">True</option>
198-
<option value="false">False</option>
199-
</select>
200-
) : field.type === "Date" ? (
201-
<input
202-
type="text"
203-
className="form-input"
204-
readOnly
205-
value={record[field.key] ? new Date(record[field.key]).toLocaleString() : "Empty"}
206-
style={{ cursor: "default" }}
207-
/>
208-
) : field.type === "Object" || field.type === "Array" || typeof record[field.key] === "object" ? (
183+
{typeof value === 'object' && value !== null ? (
209184
<div className="form-input custom-scrollbar" style={{
210185
padding: "12px",
211186
fontSize: "0.85rem",
@@ -215,14 +190,16 @@ export default function RowDetailDrawer({ isOpen, onClose, record, fields = [],
215190
maxHeight: "300px",
216191
overflowY: "auto"
217192
}}>
218-
<JsonViewer data={record[field.key] ?? {}} />
193+
<JsonViewer data={value} />
219194
</div>
220195
) : (
221196
<input
222197
type="text"
223198
className="form-input"
224199
readOnly
225-
value={record[field.key] !== null && record[field.key] !== undefined ? String(record[field.key]) : "Empty"}
200+
value={value === null || value === undefined ? '—' :
201+
typeof value === 'boolean' ? String(value) :
202+
String(value)}
226203
style={{ cursor: "default" }}
227204
/>
228205
)}

0 commit comments

Comments
 (0)