@controleonline/ui-customers 1.0.86 → 1.0.87

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@controleonline/ui-customers",
3
- "version": "1.0.86",
3
+ "version": "1.0.87",
4
4
  "author": "ControleOnline",
5
5
  "description": "ControleOnline customers Quasar UI Component",
6
6
  "license": "MIT",
@@ -63,11 +63,24 @@ const DocumentsTab = ({ client, customStyles, isEditing, onUpdateClient }) => {
63
63
  const getters = documentsTypesStore.getters || {};
64
64
  const { items = [] } = getters;
65
65
 
66
- const resolveTypeLabel = typeIri =>
67
- items.find(item => item['@id'] === typeIri)?.documentType || String(typeIri || '');
66
+ const resolveTypeLabel = (typeIri, rawDocument) => {
67
+ const rawType = rawDocument?.documentType;
68
+ const embeddedLabel =
69
+ rawType && typeof rawType === 'object' ? rawType.documentType : '';
70
+ if (embeddedLabel) {
71
+ return String(embeddedLabel);
72
+ }
73
+ const storeLabel = items.find(item => item['@id'] === typeIri)?.documentType;
74
+ if (storeLabel) {
75
+ return String(storeLabel);
76
+ }
77
+ return /^\/?document_types\/\d+$/.test(String(typeIri || ''))
78
+ ? ''
79
+ : String(typeIri || '');
80
+ };
68
81
 
69
- const applyMask = (value, type) =>
70
- applyDocumentMask(value, resolveTypeLabel(type));
82
+ const applyMask = (value, type, rawDocument) =>
83
+ applyDocumentMask(value, resolveTypeLabel(type, rawDocument));
71
84
 
72
85
  const syncClientDocuments = nextDocuments => {
73
86
  if (typeof onUpdateClient !== 'function') {
@@ -77,7 +90,10 @@ const DocumentsTab = ({ client, customStyles, isEditing, onUpdateClient }) => {
77
90
  '@id': `/documents/${documentItem.id}`,
78
91
  id: documentItem.id,
79
92
  document: documentItem.value,
80
- documentType: documentItem.type,
93
+ documentType:
94
+ documentItem.raw?.documentType?.['@id'] === documentItem.type
95
+ ? documentItem.raw.documentType
96
+ : documentItem.type,
81
97
  documentFiles: documentItem.files || [],
82
98
  file: documentItem.files?.[0]?.file || null,
83
99
  }));
@@ -122,7 +138,7 @@ const DocumentsTab = ({ client, customStyles, isEditing, onUpdateClient }) => {
122
138
  setEditingItem(item);
123
139
  setFormData(
124
140
  item
125
- ? { type: item.type, value: applyMask(String(item.value || ''), item.type) }
141
+ ? { type: item.type, value: applyMask(String(item.value || ''), item.type, item.raw) }
126
142
  : { type: '', value: '' },
127
143
  );
128
144
  setShowModal(true);
@@ -320,9 +336,13 @@ const DocumentsTab = ({ client, customStyles, isEditing, onUpdateClient }) => {
320
336
  <Icon name="description" size={20} color={customStyles.cardItemIcon.color} />
321
337
  <View>
322
338
  <Text style={customStyles.itemText}>
323
- {applyMask(String(doc.value || ''), doc.type)}
339
+ {[
340
+ resolveTypeLabel(doc.type, doc.raw),
341
+ applyMask(String(doc.value || ''), doc.type, doc.raw),
342
+ ]
343
+ .filter(Boolean)
344
+ .join(': ')}
324
345
  </Text>
325
- <Text style={customStyles.itemSubtext}>{resolveTypeLabel(doc.type)}</Text>
326
346
  </View>
327
347
  </View>
328
348
  {isEditing && (