@djb25/digit-ui-module-ekyc 1.0.6 → 1.0.7
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/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +1006 -489
- package/dist/index.modern.js.map +1 -1
- package/package.json +4 -2
- package/src/components/DesktopInbox.js +207 -59
- package/src/components/StatusCards.js +167 -16
- package/src/pages/employee/AadhaarVerification.js +323 -280
- package/src/pages/employee/AddressDetails.js +124 -100
- package/src/pages/employee/Create.js +31 -19
- package/src/pages/employee/Inbox.js +11 -4
- package/src/pages/employee/PropertyInfo.js +382 -319
- package/src/pages/employee/Review.js +314 -226
- package/src/utils/index.js +46 -0
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Compares initial and current objects and returns an object containing only the differences.
|
|
3
|
+
* Highly optimized for partial updates (PATCH-like behavior).
|
|
4
|
+
*
|
|
5
|
+
* @param {Object} initial - The original data from the backend.
|
|
6
|
+
* @param {Object} current - The current form state.
|
|
7
|
+
* @returns {Object} - An object with only the changed fields.
|
|
8
|
+
*/
|
|
9
|
+
export const getPayloadDiff = (initial, current) => {
|
|
10
|
+
const diff = {};
|
|
11
|
+
|
|
12
|
+
Object.keys(current).forEach(key => {
|
|
13
|
+
const initialVal = initial?.[key];
|
|
14
|
+
const currentVal = current[key];
|
|
15
|
+
|
|
16
|
+
// Handle nested objects (like addressDetails or aadhaarDetails)
|
|
17
|
+
if (currentVal && typeof currentVal === 'object' && !Array.isArray(currentVal) && !(currentVal instanceof File)) {
|
|
18
|
+
const nestedDiff = getPayloadDiff(initialVal || {}, currentVal);
|
|
19
|
+
if (Object.keys(nestedDiff).length > 0) {
|
|
20
|
+
diff[key] = nestedDiff;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
// Handle primitive types or arrays/files
|
|
24
|
+
else if (JSON.stringify(initialVal) !== JSON.stringify(currentVal)) {
|
|
25
|
+
diff[key] = currentVal;
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
return diff;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Safely retrieves and parses JSON data from sessionStorage.
|
|
34
|
+
* @param {string} key - The storage key.
|
|
35
|
+
* @param {*} fallback - Default value if no data is found.
|
|
36
|
+
* @returns {*} The parsed data or fallback.
|
|
37
|
+
*/
|
|
38
|
+
export const getSavedData = (key, fallback) => {
|
|
39
|
+
const saved = sessionStorage.getItem(key);
|
|
40
|
+
try {
|
|
41
|
+
return saved ? JSON.parse(saved) : fallback;
|
|
42
|
+
} catch (e) {
|
|
43
|
+
console.warn(`Error parsing sessionStorage key "${key}":`, e);
|
|
44
|
+
return fallback;
|
|
45
|
+
}
|
|
46
|
+
};
|