@homefile/components-v2 2.12.0 → 2.13.0
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/dist/components/forms/dynamicForm/ItemFormPanel/ItemFormTabs.d.ts +1 -1
- package/dist/components/forms/dynamicForm/ItemFormPanel/ItemFormTabs.js +2 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/interfaces/forms/ItemFormPanel/ItemFormTabs.interface.d.ts +1 -0
- package/dist/mocks/forms/dynamicForm.mock.d.ts +1 -0
- package/dist/mocks/forms/dynamicForm.mock.js +70 -0
- package/dist/utils/DynamicForm.utils.d.ts +8 -0
- package/dist/utils/DynamicForm.utils.js +119 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +1 -0
- package/package.json +1 -1
- package/src/components/forms/dynamicForm/ItemFormPanel/ItemFormTabs.tsx +2 -2
- package/src/index.ts +1 -1
- package/src/interfaces/forms/ItemFormPanel/ItemFormTabs.interface.ts +1 -0
- package/src/mocks/forms/dynamicForm.mock.ts +72 -0
- package/src/utils/DynamicForm.utils.ts +150 -0
- package/src/utils/index.ts +1 -0
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { ItemFormTabsI } from '../../../../interfaces';
|
|
2
|
-
export declare const ItemFormTabs: ({ form, onAISend, ...props }: ItemFormTabsI) => import("react/jsx-runtime").JSX.Element;
|
|
2
|
+
export declare const ItemFormTabs: ({ form, onAISend, searching, ...props }: ItemFormTabsI) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -14,12 +14,12 @@ import { t } from 'i18next';
|
|
|
14
14
|
import { DynamicForm, TabsHeader, ItemFormTabImage } from '../../..';
|
|
15
15
|
import { v4 as uuidv4 } from 'uuid';
|
|
16
16
|
export const ItemFormTabs = (_a) => {
|
|
17
|
-
var { form = [], onAISend } = _a, props = __rest(_a, ["form", "onAISend"]);
|
|
17
|
+
var { form = [], onAISend, searching } = _a, props = __rest(_a, ["form", "onAISend", "searching"]);
|
|
18
18
|
const formWithIds = form.map((item) => (Object.assign(Object.assign({}, item), { id: item.id || uuidv4() })));
|
|
19
19
|
const tabList = [
|
|
20
20
|
{
|
|
21
21
|
label: t('createDocument.tabs.tab1'),
|
|
22
|
-
component: _jsx(DynamicForm, { onAISend: onAISend, form: formWithIds }),
|
|
22
|
+
component: _jsx(DynamicForm, { searching: searching, onAISend: onAISend, form: formWithIds }),
|
|
23
23
|
},
|
|
24
24
|
{
|
|
25
25
|
label: t('createDocument.tabs.tab2'),
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { ActivateAccount, ActiveSubscription, AddCardBanner, AddEditContactPanel, AddFolder, AddHomeContent, AddHomeItem, AddHomeItemHeader, AddMedia, AddPropertyRecords, Address, AddPopup, AddTile, AlertBanner, AphwTile, AppBar, AssignableReceipts, BackHeader, BarDivider, CancelAccount, CatalogPopup, CloudsAnimation, ContactList, ContactsContent, ContainerHeader, CreateDocumentHeader, CreateHouseholdItemHeader, CreditCardContainer, CreditCardError, CustomerTile, DeleteBanner, Dialog, DisplayFiles, DisplayFilesDetail, DisplayOptions, DisplayReceipts, DocumentMenu, DocumentNameHeader, DocumentPreview, DynamicForm, EditAccountType, EditHomeBody, EditHomeFooter, EditHomeHeader, EditHomePanel, EmailPermissions, EmailValidation, Feedback, FileDetail, FilesUploader, FlowStep, FolderDetail, FolderDetailBody, FolderDetailContent, FolderDetailFooter, FolderDetailHeader, FolderInfo, FolderSharing, FolderTypeSelection, FooterButtons, FooterDrawer, GenericBackHeader, GroupCard, GroupsContainer, GroupsHeader, Header, HelpContent, HomeAssistant, HomeAssistantPanel, HomeBoardGrid, HomeBoardTour, HomeCard, HomeCardWithRecipent, HomeDetailsContent, HomefileMonitoring, HomeHeader, HomeMonitor, HomeMonitorSteps, HomeSharedWith, InboxForwardBanner, InboxTile, ItemFormPanel, ItemFormTabs, ItemNameHeader, ItemsReviewBanner, ItemSubTypeSelect, Launchpad, LaunchpadAutofilerBanner, LaunchpadReceiptAutofiler, LaunchpadReceiptPanel, LaunchpadTour, LeftPanel, Loading, MediaDetailsStep, MessagePanel, MessageChatPanel, MonitorAlerts, MonthlyCharge, MortgageInfo, MoveModal, MyHomes, MyProfileBody, MyProfileContent, MyProfileFooter, MyProfileHeader, MyProfilePanel, NewCreditCard, NewCreditCardHeader, NewPassword, NotBeChargedBanner, Notifications, NotificationsReminder, NotificationsPanel, NotificationCard, Overlay, PanelHeader, PartnerActiveSubscription, PartnerCatalogPanel, PartnerContent, PartnerCustomerCode, PartnerDetails, PartnerImages, PartnerPanel, PasswordInput, PaymentReceipts, PdfButton, PeopleConnected, ProfileDetailsTab, ProfilePaymentTab, ProjectList, PropertyRecords, PropertyTaxes, ReadOnlyDynamicForm, ReadOnlyImage, ReadOnlyToggle, ReceiptAutofiler, ReceiptBody, ReceiptContent, ReceiptDetails, ReceiptFilters, ReceiptFooter, ReceiptHeader, ReceiptInfos, ReceiptItem, ReceiptItems, ReceiptPDF, ReceiptsDisplayOptions, ReceiptsFiled, ReceiptsHeader, ReceiptsInfo, ReceiptsReceivedContent, RecipientForm, RecipientsToShare, RecipientTab, RecordsInputs, ResendResetPassword, ResetPassword, ReviewBanner, RightPanel, RolePermissionsTab, RoomHeader, RoomsBoardTour, RoomsMenu, RoomsMenuMobile, RoomStep, RoomVideo, SalesTax, SatisfactionTile, SectionHeader, SendCommunication, ShareContactsContent, SharedAccounts, SharedHomeContent, SharedHomeHeader, ShareHome, ShareHomeConnections, ShareHomeForm, ShineTile, ShortPartnerTile, SignIn, SignUp, SkeletonBox, StepHeader, StorageUsed, Subscription, SubscriptionCard, SubscriptionTable, Summary, TabsHeader, TextInput, ToBeDeletedBody, ToBeDeletedContent, ToBeDeletedFooter, ToBeDeletedHeader, TourButton, Trash, TrendingValue, TrialBanner, TutorialsButton, TwoFactor, TwoFactorSetting, UpdateList, UserDetails, ValueMonitor, ViewContactPanel, VideoPlayer, VideoPlayerModal, WellDone, YtdTile, } from './components';
|
|
2
2
|
export { useCustomToast } from './hooks';
|
|
3
|
-
export { randomColor } from './utils';
|
|
3
|
+
export { randomColor, mapApiObjectToFormFields } from './utils';
|
|
4
4
|
export { Contacts, MagnifyingGlassReport, Message, Register, Receipts, Price, BlueFolderShared, Calendar, Create, Notes, } from './assets/images';
|
|
5
5
|
export { billingProxy, dynamicFormProxy, homeCardProxy, partnerContentProxy, partnerDetailsProxy, paymentMethodProxy, recordsInputsProxy, recordsInputsToDBProxy, userDetailsProxy, confirmAddressProxy, } from './proxies';
|
|
6
6
|
import theme from './theme';
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { ActivateAccount, ActiveSubscription, AddCardBanner, AddEditContactPanel, AddFolder, AddHomeContent, AddHomeItem, AddHomeItemHeader, AddMedia, AddPropertyRecords, Address, AddPopup, AddTile, AlertBanner, AphwTile, AppBar, AssignableReceipts, BackHeader, BarDivider, CancelAccount, CatalogPopup, CloudsAnimation, ContactList, ContactsContent, ContainerHeader, CreateDocumentHeader, CreateHouseholdItemHeader, CreditCardContainer, CreditCardError, CustomerTile, DeleteBanner, Dialog, DisplayFiles, DisplayFilesDetail, DisplayOptions, DisplayReceipts, DocumentMenu, DocumentNameHeader, DocumentPreview, DynamicForm, EditAccountType, EditHomeBody, EditHomeFooter, EditHomeHeader, EditHomePanel, EmailPermissions, EmailValidation, Feedback, FileDetail, FilesUploader, FlowStep, FolderDetail, FolderDetailBody, FolderDetailContent, FolderDetailFooter, FolderDetailHeader, FolderInfo, FolderSharing, FolderTypeSelection, FooterButtons, FooterDrawer, GenericBackHeader, GroupCard, GroupsContainer, GroupsHeader, Header, HelpContent, HomeAssistant, HomeAssistantPanel, HomeBoardGrid, HomeBoardTour, HomeCard, HomeCardWithRecipent, HomeDetailsContent, HomefileMonitoring, HomeHeader, HomeMonitor, HomeMonitorSteps, HomeSharedWith, InboxForwardBanner, InboxTile, ItemFormPanel, ItemFormTabs, ItemNameHeader, ItemsReviewBanner, ItemSubTypeSelect, Launchpad, LaunchpadAutofilerBanner, LaunchpadReceiptAutofiler, LaunchpadReceiptPanel, LaunchpadTour, LeftPanel, Loading, MediaDetailsStep, MessagePanel, MessageChatPanel, MonitorAlerts, MonthlyCharge, MortgageInfo, MoveModal, MyHomes, MyProfileBody, MyProfileContent, MyProfileFooter, MyProfileHeader, MyProfilePanel, NewCreditCard, NewCreditCardHeader, NewPassword, NotBeChargedBanner, Notifications, NotificationsReminder, NotificationsPanel, NotificationCard, Overlay, PanelHeader, PartnerActiveSubscription, PartnerCatalogPanel, PartnerContent, PartnerCustomerCode, PartnerDetails, PartnerImages, PartnerPanel, PasswordInput, PaymentReceipts, PdfButton, PeopleConnected, ProfileDetailsTab, ProfilePaymentTab, ProjectList, PropertyRecords, PropertyTaxes, ReadOnlyDynamicForm, ReadOnlyImage, ReadOnlyToggle, ReceiptAutofiler, ReceiptBody, ReceiptContent, ReceiptDetails, ReceiptFilters, ReceiptFooter, ReceiptHeader, ReceiptInfos, ReceiptItem, ReceiptItems, ReceiptPDF, ReceiptsDisplayOptions, ReceiptsFiled, ReceiptsHeader, ReceiptsInfo, ReceiptsReceivedContent, RecipientForm, RecipientsToShare, RecipientTab, RecordsInputs, ResendResetPassword, ResetPassword, ReviewBanner, RightPanel, RolePermissionsTab, RoomHeader, RoomsBoardTour, RoomsMenu, RoomsMenuMobile, RoomStep, RoomVideo, SalesTax, SatisfactionTile, SectionHeader, SendCommunication, ShareContactsContent, SharedAccounts, SharedHomeContent, SharedHomeHeader, ShareHome, ShareHomeConnections, ShareHomeForm, ShineTile, ShortPartnerTile, SignIn, SignUp, SkeletonBox, StepHeader, StorageUsed, Subscription, SubscriptionCard, SubscriptionTable, Summary, TabsHeader, TextInput, ToBeDeletedBody, ToBeDeletedContent, ToBeDeletedFooter, ToBeDeletedHeader, TourButton, Trash, TrendingValue, TrialBanner, TutorialsButton, TwoFactor, TwoFactorSetting, UpdateList, UserDetails, ValueMonitor, ViewContactPanel, VideoPlayer, VideoPlayerModal, WellDone, YtdTile, } from './components';
|
|
2
2
|
export { useCustomToast } from './hooks';
|
|
3
|
-
export { randomColor } from './utils';
|
|
3
|
+
export { randomColor, mapApiObjectToFormFields } from './utils';
|
|
4
4
|
export { Contacts, MagnifyingGlassReport, Message, Register, Receipts, Price, BlueFolderShared, Calendar, Create, Notes, } from './assets/images';
|
|
5
5
|
export { billingProxy, dynamicFormProxy, homeCardProxy, partnerContentProxy, partnerDetailsProxy, paymentMethodProxy, recordsInputsProxy, recordsInputsToDBProxy, userDetailsProxy, confirmAddressProxy, } from './proxies';
|
|
6
6
|
import theme from './theme';
|
|
@@ -744,3 +744,73 @@ export const viewingHomeItemMock = [
|
|
|
744
744
|
options: [],
|
|
745
745
|
},
|
|
746
746
|
];
|
|
747
|
+
export const unknownFormMock = {
|
|
748
|
+
_id: '680155efb02260ca2e10c1d0',
|
|
749
|
+
name: 'LG Electronics GBB71PZDMN',
|
|
750
|
+
brand: 'LG Electronics',
|
|
751
|
+
model: 'GBB71PZDMN',
|
|
752
|
+
upc: '',
|
|
753
|
+
type: 'Bottom Freezer Refrigerator',
|
|
754
|
+
productClass: '',
|
|
755
|
+
misc: {
|
|
756
|
+
information: {
|
|
757
|
+
description: 'The LG GBB71PZDMN is a premium refrigerator that offers fresh storage solutions with advanced features.',
|
|
758
|
+
features: [
|
|
759
|
+
'Inverter Linear Compressor for energy efficiency',
|
|
760
|
+
'Multi-Air Flow cooling system',
|
|
761
|
+
'Frost-free design',
|
|
762
|
+
'Smart Diagnosis technology',
|
|
763
|
+
'LED interior lighting',
|
|
764
|
+
],
|
|
765
|
+
},
|
|
766
|
+
warranty: {
|
|
767
|
+
generalWarranty: '2 years',
|
|
768
|
+
compressorWarranty: '10 years',
|
|
769
|
+
},
|
|
770
|
+
estimatedYearOfManufacture: '2020',
|
|
771
|
+
specifications: {
|
|
772
|
+
dimensions: {
|
|
773
|
+
width: '595 mm',
|
|
774
|
+
height: '2010 mm',
|
|
775
|
+
depth: '682 mm',
|
|
776
|
+
},
|
|
777
|
+
capacity: {
|
|
778
|
+
totalNetCapacity: '341 liters',
|
|
779
|
+
fridgeNetCapacity: '229 liters',
|
|
780
|
+
freezerNetCapacity: '112 liters',
|
|
781
|
+
},
|
|
782
|
+
energyRating: 'A++',
|
|
783
|
+
color: 'Silver',
|
|
784
|
+
weight: '70 kg',
|
|
785
|
+
installationType: 'Freestanding',
|
|
786
|
+
},
|
|
787
|
+
troubleshootingTips: [
|
|
788
|
+
{
|
|
789
|
+
issue: 'Refrigerator not cooling',
|
|
790
|
+
tips: [
|
|
791
|
+
'Check if the refrigerator is plugged in and receiving power.',
|
|
792
|
+
'Ensure the temperature settings are correct.',
|
|
793
|
+
'Make sure the vents are not blocked.',
|
|
794
|
+
'Check for a faulty compressor or other internal components.',
|
|
795
|
+
],
|
|
796
|
+
},
|
|
797
|
+
{
|
|
798
|
+
issue: 'Water pooling inside the fridge',
|
|
799
|
+
tips: [
|
|
800
|
+
'Check the drainage hole for blockages.',
|
|
801
|
+
'Inspect the door seals for proper sealing.',
|
|
802
|
+
'Ensure that food items do not block airflow.',
|
|
803
|
+
],
|
|
804
|
+
},
|
|
805
|
+
],
|
|
806
|
+
replacementParts: {
|
|
807
|
+
compressor: 'LG part number 4924JA0211A',
|
|
808
|
+
doorSeal: 'LG part number 4986JJ3001A',
|
|
809
|
+
fanMotor: 'LG part number 4681JB1028C',
|
|
810
|
+
lighting: 'LG part number 6912JB2004E',
|
|
811
|
+
},
|
|
812
|
+
},
|
|
813
|
+
createdAt: '2025-04-17T19:26:39.435Z',
|
|
814
|
+
updatedAt: '2025-04-17T19:26:39.435Z',
|
|
815
|
+
__v: 0,
|
|
816
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ReportI } from '../interfaces';
|
|
2
|
+
interface MapApiObjectToFormFieldsI {
|
|
3
|
+
obj?: Record<string, any>;
|
|
4
|
+
depth?: number;
|
|
5
|
+
labelPrefix?: string;
|
|
6
|
+
}
|
|
7
|
+
export declare const mapApiObjectToFormFields: ({ obj, depth, labelPrefix, }?: MapApiObjectToFormFieldsI) => ReportI[];
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { v4 as uuidv4 } from 'uuid';
|
|
2
|
+
const MAX_DEPTH = 10;
|
|
3
|
+
const FIELDS_TO_IGNORE = ['_id', '__v', 'createdAt', 'updatedAt'];
|
|
4
|
+
export const mapApiObjectToFormFields = ({ obj = {}, depth = 0, labelPrefix = '', } = {}) => {
|
|
5
|
+
if (depth > MAX_DEPTH)
|
|
6
|
+
return [];
|
|
7
|
+
const misc = 'misc' in obj && typeof obj.misc === 'object' && obj.misc !== null
|
|
8
|
+
? obj.misc
|
|
9
|
+
: {};
|
|
10
|
+
const rest = Object.assign({}, obj);
|
|
11
|
+
delete rest.misc;
|
|
12
|
+
const miscEntries = Object.entries(misc);
|
|
13
|
+
const rootEntries = Object.entries(rest);
|
|
14
|
+
const allEntries = [
|
|
15
|
+
...rootEntries.map(([key, value]) => [key, value]),
|
|
16
|
+
...miscEntries.map(([key, value]) => [key, value]),
|
|
17
|
+
];
|
|
18
|
+
return allEntries
|
|
19
|
+
.filter(([key]) => !FIELDS_TO_IGNORE.includes(key))
|
|
20
|
+
.flatMap(([key, value]) => {
|
|
21
|
+
const currentLabel = `${labelPrefix ? `${labelPrefix} - ` : ''}${capitalize(key)}`;
|
|
22
|
+
if (typeof value === 'string') {
|
|
23
|
+
return [
|
|
24
|
+
{
|
|
25
|
+
id: uuidv4(),
|
|
26
|
+
name: currentLabel,
|
|
27
|
+
description: '',
|
|
28
|
+
comments: '',
|
|
29
|
+
value,
|
|
30
|
+
type: 'text',
|
|
31
|
+
visible: true,
|
|
32
|
+
},
|
|
33
|
+
];
|
|
34
|
+
}
|
|
35
|
+
if (typeof value === 'number') {
|
|
36
|
+
return [
|
|
37
|
+
{
|
|
38
|
+
id: uuidv4(),
|
|
39
|
+
name: currentLabel,
|
|
40
|
+
description: '',
|
|
41
|
+
comments: '',
|
|
42
|
+
value,
|
|
43
|
+
type: 'number',
|
|
44
|
+
visible: true,
|
|
45
|
+
},
|
|
46
|
+
];
|
|
47
|
+
}
|
|
48
|
+
if (typeof value === 'boolean') {
|
|
49
|
+
return [
|
|
50
|
+
{
|
|
51
|
+
id: uuidv4(),
|
|
52
|
+
name: currentLabel,
|
|
53
|
+
description: '',
|
|
54
|
+
comments: '',
|
|
55
|
+
value,
|
|
56
|
+
type: 'switch',
|
|
57
|
+
visible: true,
|
|
58
|
+
},
|
|
59
|
+
];
|
|
60
|
+
}
|
|
61
|
+
if (Array.isArray(value) && value.every((v) => typeof v === 'string')) {
|
|
62
|
+
const htmlValue = `<ul>${value
|
|
63
|
+
.map((v) => `<li>${v}</li>`)
|
|
64
|
+
.join('')}</ul>`;
|
|
65
|
+
return [
|
|
66
|
+
{
|
|
67
|
+
id: uuidv4(),
|
|
68
|
+
name: currentLabel,
|
|
69
|
+
description: '',
|
|
70
|
+
comments: '',
|
|
71
|
+
value: htmlValue,
|
|
72
|
+
type: 'textarea',
|
|
73
|
+
visible: true,
|
|
74
|
+
},
|
|
75
|
+
];
|
|
76
|
+
}
|
|
77
|
+
if (Array.isArray(value) &&
|
|
78
|
+
value.every((v) => Object.prototype.toString.call(v) === '[object Object]')) {
|
|
79
|
+
return value.flatMap((item, index) => {
|
|
80
|
+
const itemLabel = `${currentLabel} [${index + 1}]`;
|
|
81
|
+
return [
|
|
82
|
+
{
|
|
83
|
+
id: uuidv4(),
|
|
84
|
+
name: itemLabel,
|
|
85
|
+
description: '',
|
|
86
|
+
comments: '',
|
|
87
|
+
value: '',
|
|
88
|
+
type: 'group',
|
|
89
|
+
visible: true,
|
|
90
|
+
children: mapApiObjectToFormFields({
|
|
91
|
+
obj: item,
|
|
92
|
+
depth: depth + 1,
|
|
93
|
+
labelPrefix: itemLabel,
|
|
94
|
+
}),
|
|
95
|
+
},
|
|
96
|
+
];
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
if (Object.prototype.toString.call(value) === '[object Object]') {
|
|
100
|
+
return mapApiObjectToFormFields({
|
|
101
|
+
obj: value,
|
|
102
|
+
depth: depth + 1,
|
|
103
|
+
labelPrefix: currentLabel,
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
return [
|
|
107
|
+
{
|
|
108
|
+
id: uuidv4(),
|
|
109
|
+
name: currentLabel,
|
|
110
|
+
description: '',
|
|
111
|
+
comments: '',
|
|
112
|
+
value: String(value),
|
|
113
|
+
type: 'default',
|
|
114
|
+
visible: false,
|
|
115
|
+
},
|
|
116
|
+
];
|
|
117
|
+
});
|
|
118
|
+
};
|
|
119
|
+
const capitalize = (str) => str.charAt(0).toUpperCase() + str.slice(1);
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ export * from './Animations.utils';
|
|
|
3
3
|
export * from './Avatars.utils';
|
|
4
4
|
export * from './BrowserDetectors.utils';
|
|
5
5
|
export * from './BubblesTour.utils';
|
|
6
|
+
export * from './DynamicForm.utils';
|
|
6
7
|
export * from './Formaters.utils';
|
|
7
8
|
export * from './IconAlt.utils';
|
|
8
9
|
export * from './ImageAlt.utils';
|
package/dist/utils/index.js
CHANGED
|
@@ -3,6 +3,7 @@ export * from './Animations.utils';
|
|
|
3
3
|
export * from './Avatars.utils';
|
|
4
4
|
export * from './BrowserDetectors.utils';
|
|
5
5
|
export * from './BubblesTour.utils';
|
|
6
|
+
export * from './DynamicForm.utils';
|
|
6
7
|
export * from './Formaters.utils';
|
|
7
8
|
export * from './IconAlt.utils';
|
|
8
9
|
export * from './ImageAlt.utils';
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@ import { DynamicForm, TabsHeader, ItemFormTabImage } from '@/components'
|
|
|
3
3
|
import { ItemFormTabsI } from '@/interfaces'
|
|
4
4
|
import { v4 as uuidv4 } from 'uuid'
|
|
5
5
|
|
|
6
|
-
export const ItemFormTabs = ({ form = [], onAISend, ...props }: ItemFormTabsI) => {
|
|
6
|
+
export const ItemFormTabs = ({ form = [], onAISend, searching, ...props }: ItemFormTabsI) => {
|
|
7
7
|
const formWithIds = form.map((item) => ({
|
|
8
8
|
...item,
|
|
9
9
|
id: item.id || uuidv4(),
|
|
@@ -12,7 +12,7 @@ export const ItemFormTabs = ({ form = [], onAISend, ...props }: ItemFormTabsI) =
|
|
|
12
12
|
const tabList = [
|
|
13
13
|
{
|
|
14
14
|
label: t('createDocument.tabs.tab1'),
|
|
15
|
-
component: <DynamicForm onAISend={onAISend} form={formWithIds} />,
|
|
15
|
+
component: <DynamicForm searching={searching} onAISend={onAISend} form={formWithIds} />,
|
|
16
16
|
},
|
|
17
17
|
{
|
|
18
18
|
label: t('createDocument.tabs.tab2'),
|
package/src/index.ts
CHANGED
|
@@ -753,3 +753,75 @@ export const viewingHomeItemMock: ReportI[] = [
|
|
|
753
753
|
options: [],
|
|
754
754
|
},
|
|
755
755
|
]
|
|
756
|
+
|
|
757
|
+
export const unknownFormMock: Record<string, any> = {
|
|
758
|
+
_id: '680155efb02260ca2e10c1d0',
|
|
759
|
+
name: 'LG Electronics GBB71PZDMN',
|
|
760
|
+
brand: 'LG Electronics',
|
|
761
|
+
model: 'GBB71PZDMN',
|
|
762
|
+
upc: '',
|
|
763
|
+
type: 'Bottom Freezer Refrigerator',
|
|
764
|
+
productClass: '',
|
|
765
|
+
misc: {
|
|
766
|
+
information: {
|
|
767
|
+
description:
|
|
768
|
+
'The LG GBB71PZDMN is a premium refrigerator that offers fresh storage solutions with advanced features.',
|
|
769
|
+
features: [
|
|
770
|
+
'Inverter Linear Compressor for energy efficiency',
|
|
771
|
+
'Multi-Air Flow cooling system',
|
|
772
|
+
'Frost-free design',
|
|
773
|
+
'Smart Diagnosis technology',
|
|
774
|
+
'LED interior lighting',
|
|
775
|
+
],
|
|
776
|
+
},
|
|
777
|
+
warranty: {
|
|
778
|
+
generalWarranty: '2 years',
|
|
779
|
+
compressorWarranty: '10 years',
|
|
780
|
+
},
|
|
781
|
+
estimatedYearOfManufacture: '2020',
|
|
782
|
+
specifications: {
|
|
783
|
+
dimensions: {
|
|
784
|
+
width: '595 mm',
|
|
785
|
+
height: '2010 mm',
|
|
786
|
+
depth: '682 mm',
|
|
787
|
+
},
|
|
788
|
+
capacity: {
|
|
789
|
+
totalNetCapacity: '341 liters',
|
|
790
|
+
fridgeNetCapacity: '229 liters',
|
|
791
|
+
freezerNetCapacity: '112 liters',
|
|
792
|
+
},
|
|
793
|
+
energyRating: 'A++',
|
|
794
|
+
color: 'Silver',
|
|
795
|
+
weight: '70 kg',
|
|
796
|
+
installationType: 'Freestanding',
|
|
797
|
+
},
|
|
798
|
+
troubleshootingTips: [
|
|
799
|
+
{
|
|
800
|
+
issue: 'Refrigerator not cooling',
|
|
801
|
+
tips: [
|
|
802
|
+
'Check if the refrigerator is plugged in and receiving power.',
|
|
803
|
+
'Ensure the temperature settings are correct.',
|
|
804
|
+
'Make sure the vents are not blocked.',
|
|
805
|
+
'Check for a faulty compressor or other internal components.',
|
|
806
|
+
],
|
|
807
|
+
},
|
|
808
|
+
{
|
|
809
|
+
issue: 'Water pooling inside the fridge',
|
|
810
|
+
tips: [
|
|
811
|
+
'Check the drainage hole for blockages.',
|
|
812
|
+
'Inspect the door seals for proper sealing.',
|
|
813
|
+
'Ensure that food items do not block airflow.',
|
|
814
|
+
],
|
|
815
|
+
},
|
|
816
|
+
],
|
|
817
|
+
replacementParts: {
|
|
818
|
+
compressor: 'LG part number 4924JA0211A',
|
|
819
|
+
doorSeal: 'LG part number 4986JJ3001A',
|
|
820
|
+
fanMotor: 'LG part number 4681JB1028C',
|
|
821
|
+
lighting: 'LG part number 6912JB2004E',
|
|
822
|
+
},
|
|
823
|
+
},
|
|
824
|
+
createdAt: '2025-04-17T19:26:39.435Z',
|
|
825
|
+
updatedAt: '2025-04-17T19:26:39.435Z',
|
|
826
|
+
__v: 0,
|
|
827
|
+
}
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import { ReportI } from '@/interfaces'
|
|
2
|
+
import { v4 as uuidv4 } from 'uuid'
|
|
3
|
+
|
|
4
|
+
interface MapApiObjectToFormFieldsI {
|
|
5
|
+
obj?: Record<string, any>
|
|
6
|
+
depth?: number
|
|
7
|
+
labelPrefix?: string
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const MAX_DEPTH = 10
|
|
11
|
+
const FIELDS_TO_IGNORE = ['_id', '__v', 'createdAt', 'updatedAt']
|
|
12
|
+
|
|
13
|
+
export const mapApiObjectToFormFields = ({
|
|
14
|
+
obj = {},
|
|
15
|
+
depth = 0,
|
|
16
|
+
labelPrefix = '',
|
|
17
|
+
}: MapApiObjectToFormFieldsI = {}): ReportI[] => {
|
|
18
|
+
if (depth > MAX_DEPTH) return []
|
|
19
|
+
|
|
20
|
+
const misc =
|
|
21
|
+
'misc' in obj && typeof obj.misc === 'object' && obj.misc !== null
|
|
22
|
+
? obj.misc
|
|
23
|
+
: {}
|
|
24
|
+
const rest = { ...obj }
|
|
25
|
+
delete rest.misc
|
|
26
|
+
|
|
27
|
+
const miscEntries = Object.entries(misc)
|
|
28
|
+
const rootEntries = Object.entries(rest)
|
|
29
|
+
|
|
30
|
+
const allEntries = [
|
|
31
|
+
...rootEntries.map(([key, value]) => [key, value] as const),
|
|
32
|
+
...miscEntries.map(([key, value]) => [key, value] as const),
|
|
33
|
+
]
|
|
34
|
+
|
|
35
|
+
return allEntries
|
|
36
|
+
.filter(([key]) => !FIELDS_TO_IGNORE.includes(key))
|
|
37
|
+
.flatMap(([key, value]) => {
|
|
38
|
+
const currentLabel = `${
|
|
39
|
+
labelPrefix ? `${labelPrefix} - ` : ''
|
|
40
|
+
}${capitalize(key)}`
|
|
41
|
+
|
|
42
|
+
if (typeof value === 'string') {
|
|
43
|
+
return [
|
|
44
|
+
{
|
|
45
|
+
id: uuidv4(),
|
|
46
|
+
name: currentLabel,
|
|
47
|
+
description: '',
|
|
48
|
+
comments: '',
|
|
49
|
+
value,
|
|
50
|
+
type: 'text',
|
|
51
|
+
visible: true,
|
|
52
|
+
},
|
|
53
|
+
]
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
if (typeof value === 'number') {
|
|
57
|
+
return [
|
|
58
|
+
{
|
|
59
|
+
id: uuidv4(),
|
|
60
|
+
name: currentLabel,
|
|
61
|
+
description: '',
|
|
62
|
+
comments: '',
|
|
63
|
+
value,
|
|
64
|
+
type: 'number',
|
|
65
|
+
visible: true,
|
|
66
|
+
},
|
|
67
|
+
]
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
if (typeof value === 'boolean') {
|
|
71
|
+
return [
|
|
72
|
+
{
|
|
73
|
+
id: uuidv4(),
|
|
74
|
+
name: currentLabel,
|
|
75
|
+
description: '',
|
|
76
|
+
comments: '',
|
|
77
|
+
value,
|
|
78
|
+
type: 'switch',
|
|
79
|
+
visible: true,
|
|
80
|
+
},
|
|
81
|
+
]
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
if (Array.isArray(value) && value.every((v) => typeof v === 'string')) {
|
|
85
|
+
const htmlValue = `<ul>${value
|
|
86
|
+
.map((v) => `<li>${v}</li>`)
|
|
87
|
+
.join('')}</ul>`
|
|
88
|
+
return [
|
|
89
|
+
{
|
|
90
|
+
id: uuidv4(),
|
|
91
|
+
name: currentLabel,
|
|
92
|
+
description: '',
|
|
93
|
+
comments: '',
|
|
94
|
+
value: htmlValue,
|
|
95
|
+
type: 'textarea',
|
|
96
|
+
visible: true,
|
|
97
|
+
},
|
|
98
|
+
]
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
if (
|
|
102
|
+
Array.isArray(value) &&
|
|
103
|
+
value.every(
|
|
104
|
+
(v) => Object.prototype.toString.call(v) === '[object Object]'
|
|
105
|
+
)
|
|
106
|
+
) {
|
|
107
|
+
return value.flatMap((item, index) => {
|
|
108
|
+
const itemLabel = `${currentLabel} [${index + 1}]`
|
|
109
|
+
return [
|
|
110
|
+
{
|
|
111
|
+
id: uuidv4(),
|
|
112
|
+
name: itemLabel,
|
|
113
|
+
description: '',
|
|
114
|
+
comments: '',
|
|
115
|
+
value: '',
|
|
116
|
+
type: 'group',
|
|
117
|
+
visible: true,
|
|
118
|
+
children: mapApiObjectToFormFields({
|
|
119
|
+
obj: item,
|
|
120
|
+
depth: depth + 1,
|
|
121
|
+
labelPrefix: itemLabel,
|
|
122
|
+
}),
|
|
123
|
+
},
|
|
124
|
+
]
|
|
125
|
+
})
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
if (Object.prototype.toString.call(value) === '[object Object]') {
|
|
129
|
+
return mapApiObjectToFormFields({
|
|
130
|
+
obj: value,
|
|
131
|
+
depth: depth + 1,
|
|
132
|
+
labelPrefix: currentLabel,
|
|
133
|
+
})
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
return [
|
|
137
|
+
{
|
|
138
|
+
id: uuidv4(),
|
|
139
|
+
name: currentLabel,
|
|
140
|
+
description: '',
|
|
141
|
+
comments: '',
|
|
142
|
+
value: String(value),
|
|
143
|
+
type: 'default',
|
|
144
|
+
visible: false,
|
|
145
|
+
},
|
|
146
|
+
]
|
|
147
|
+
})
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
const capitalize = (str: string) => str.charAt(0).toUpperCase() + str.slice(1)
|
package/src/utils/index.ts
CHANGED
|
@@ -3,6 +3,7 @@ export * from './Animations.utils'
|
|
|
3
3
|
export * from './Avatars.utils'
|
|
4
4
|
export * from './BrowserDetectors.utils'
|
|
5
5
|
export * from './BubblesTour.utils'
|
|
6
|
+
export * from './DynamicForm.utils'
|
|
6
7
|
export * from './Formaters.utils'
|
|
7
8
|
export * from './IconAlt.utils'
|
|
8
9
|
export * from './ImageAlt.utils'
|