@visns-studio/visns-components 5.10.10 → 5.11.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +85 -0
- package/package.json +6 -6
- package/src/components/cms/DataGrid.jsx +83 -3
- package/src/components/crm/columns/ColumnRenderers.jsx +97 -2
- package/src/components/crm/generic/ContactSelectorModal.jsx +380 -0
- package/src/components/crm/generic/DatePickerDialog.jsx +302 -0
- package/src/components/crm/generic/GenericDetail.jsx +67 -2
- package/src/components/crm/generic/GenericGrid.jsx +1534 -0
- package/src/components/crm/generic/GenericIndex.jsx +5 -1255
- package/src/components/crm/generic/GenericReportForm.jsx +194 -0
- package/src/components/crm/generic/shared/formatters.js +125 -0
- package/src/components/crm/generic/shared/gridUtils.js +194 -0
- package/src/components/crm/generic/styles/ContactSelectorModal.css +367 -0
- package/src/components/crm/generic/styles/DatePickerDialog.css +84 -0
- package/src/components/crm/generic/styles/GenericDetail.module.scss +77 -0
- package/src/components/crm/generic/styles/GenericIndex.module.scss +176 -0
- package/src/index.js +4 -0
|
@@ -686,8 +686,73 @@ function GenericDetail({
|
|
|
686
686
|
|
|
687
687
|
const renderExist = () => (truncatedValue ? 'Yes' : 'No');
|
|
688
688
|
|
|
689
|
-
const renderJson = () =>
|
|
690
|
-
|
|
689
|
+
const renderJson = () => {
|
|
690
|
+
if (!value) return null;
|
|
691
|
+
|
|
692
|
+
try {
|
|
693
|
+
const jsonData = typeof value === 'string' ? JSON.parse(value) : value;
|
|
694
|
+
|
|
695
|
+
// Check if this looks like a question/answer format
|
|
696
|
+
const isQuestionAnswerFormat = Object.values(jsonData).every(item =>
|
|
697
|
+
item && typeof item === 'object' &&
|
|
698
|
+
(item.hasOwnProperty('question') || item.hasOwnProperty('answer'))
|
|
699
|
+
);
|
|
700
|
+
|
|
701
|
+
if (isQuestionAnswerFormat) {
|
|
702
|
+
return (
|
|
703
|
+
<div className={styles.jsonQuestionAnswer}>
|
|
704
|
+
{Object.entries(jsonData).map(([key, item]) => {
|
|
705
|
+
if (!item || typeof item !== 'object') return null;
|
|
706
|
+
|
|
707
|
+
const question = item.question || key.replace(/_/g, ' ').replace(/\b\w/g, l => l.toUpperCase());
|
|
708
|
+
const answer = item.answer !== undefined ?
|
|
709
|
+
(typeof item.answer === 'boolean' ? (item.answer ? 'Yes' : 'No') : String(item.answer)) :
|
|
710
|
+
'N/A';
|
|
711
|
+
|
|
712
|
+
return (
|
|
713
|
+
<div key={key} className={styles.questionAnswerPair}>
|
|
714
|
+
<div className={styles.question}>
|
|
715
|
+
<strong>{question}</strong>
|
|
716
|
+
</div>
|
|
717
|
+
<div className={styles.answer}>
|
|
718
|
+
{answer}
|
|
719
|
+
</div>
|
|
720
|
+
</div>
|
|
721
|
+
);
|
|
722
|
+
})}
|
|
723
|
+
</div>
|
|
724
|
+
);
|
|
725
|
+
}
|
|
726
|
+
|
|
727
|
+
// Check if this is a simple key-value object
|
|
728
|
+
const isSimpleKeyValue = Object.values(jsonData).every(val =>
|
|
729
|
+
typeof val !== 'object' || val === null
|
|
730
|
+
);
|
|
731
|
+
|
|
732
|
+
if (isSimpleKeyValue) {
|
|
733
|
+
return (
|
|
734
|
+
<div className={styles.jsonKeyValue}>
|
|
735
|
+
{Object.entries(jsonData).map(([key, val]) => (
|
|
736
|
+
<div key={key} className={styles.keyValuePair}>
|
|
737
|
+
<strong>{key.replace(/_/g, ' ').replace(/\b\w/g, l => l.toUpperCase())}:</strong> {
|
|
738
|
+
val !== null && val !== undefined ?
|
|
739
|
+
(typeof val === 'boolean' ? (val ? 'Yes' : 'No') : String(val)) :
|
|
740
|
+
'N/A'
|
|
741
|
+
}
|
|
742
|
+
</div>
|
|
743
|
+
))}
|
|
744
|
+
</div>
|
|
745
|
+
);
|
|
746
|
+
}
|
|
747
|
+
|
|
748
|
+
// For complex nested objects, fall back to formatted JSON
|
|
749
|
+
return <pre className={styles.jsonRaw}>{JSON.stringify(jsonData, null, 2)}</pre>;
|
|
750
|
+
|
|
751
|
+
} catch (error) {
|
|
752
|
+
// If parsing fails, show raw value
|
|
753
|
+
return <pre className={styles.jsonRaw}>{JSON.stringify(value, null, 2)}</pre>;
|
|
754
|
+
}
|
|
755
|
+
};
|
|
691
756
|
|
|
692
757
|
const renderLatestNotes = () => formatNoteValue();
|
|
693
758
|
|