Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
91 changes: 7 additions & 84 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 1 addition & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,9 @@
"cmdk": "^1.1.1",
"date-fns": "^4.1.0",
"dompurify": "^3.3.3",
"fast-deep-equal": "^3.1.3",
"lodash.capitalize": "^4.2.1",
"lodash.get": "^4.4.2",
"lodash.groupby": "^4.6.0",
"lodash.isequal": "^4.5.0",
"lodash.isnull": "^3.0.0",
"lodash.mergewith": "^4.6.2",
"lodash.omit": "^4.5.0",
Expand All @@ -132,9 +131,7 @@
"@testing-library/user-event": "^14.6.1",
"@types/jsdom": "^28.0.1",
"@types/lodash.capitalize": "^4.2.9",
"@types/lodash.get": "^4.4.9",
"@types/lodash.groupby": "^4.6.9",
"@types/lodash.isequal": "^4.5.8",
"@types/lodash.isnull": "^3.0.9",
"@types/lodash.mergewith": "^4.6.9",
"@types/lodash.omit": "^4.5.9",
Expand Down
16 changes: 8 additions & 8 deletions src/components/JsonSchemaComparison/formDiffDetector.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { $TSFixMe, JSFField } from '@/src/types/remoteFlows';
import isEqual from 'lodash.isequal';
import equal from 'fast-deep-equal';

export type DiffType = 'added' | 'removed' | 'modified' | 'unchanged';

Expand Down Expand Up @@ -65,7 +65,7 @@ const compareOptions = (
}>;
}
| undefined => {
if (isEqual(options1, options2)) return undefined;
if (equal(options1, options2)) return undefined;

const map1 = new Map((options1 || []).map((o) => [o.value, o]));
const map2 = new Map((options2 || []).map((o) => [o.value, o]));
Expand All @@ -88,7 +88,7 @@ const compareOptions = (
removed.push({ value: option1.value, label: option1.label });
} else {
const option2 = map2.get(value)!;
if (!isEqual(option1, option2)) {
if (!equal(option1, option2)) {
const changes: { label?: { old: string; new: string } } = {};
if (option1.label !== option2.label) {
changes.label = { old: option1.label, new: option2.label };
Expand Down Expand Up @@ -145,21 +145,21 @@ const isFieldModified = (

// Only compare user-facing schema properties, not internal/computed ones
// Ignore: schema (Yup), computedAttributes, scopedJsonSchema, errorMessage, meta, description
// Note: nested fields are checked via compareNestedFields to avoid deep isEqual with problematic properties
// Note: nested fields are checked via compareNestedFields to avoid deep equal with problematic properties
const checks = {
label: field1.label !== field2.label,
required: field1.required !== field2.required,
inputType: field1.inputType !== field2.inputType,
type: field1.type !== field2.type,
jsonType: !isEqual(field1.jsonType, field2.jsonType), // Use isEqual since jsonType can be an array like ['string', 'null']
jsonType: !equal(field1.jsonType, field2.jsonType), // Use equal since jsonType can be an array like ['string', 'null']
name: field1.name !== field2.name,
defaultValue: field1.defaultValue !== field2.defaultValue,
minDate: field1.minDate !== field2.minDate,
maxDate: field1.maxDate !== field2.maxDate,
maxLength: field1.maxLength !== field2.maxLength,
multiple: field1.multiple !== field2.multiple,
isVisible: field1.isVisible !== field2.isVisible,
options: !isEqual(field1.options, field2.options),
options: !equal(field1.options, field2.options),
};

// Check for nested field changes using compareNestedFields to avoid deep isEqual
Expand Down Expand Up @@ -211,14 +211,14 @@ const getFieldChanges = (field1: JSFField, field2: JSFField) => {
};
}

if (!isEqual(field1.jsonType, field2.jsonType)) {
if (!equal(field1.jsonType, field2.jsonType)) {
changes.jsonType = {
old: field1.jsonType,
new: field2.jsonType,
};
}

if (!isEqual(field1.defaultValue, field2.defaultValue)) {
if (!equal(field1.defaultValue, field2.defaultValue)) {
changes.defaultValue = {
old: field1.defaultValue,
new: field2.defaultValue,
Expand Down
8 changes: 4 additions & 4 deletions src/components/form/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import { JSFFields } from '@/src/types/remoteFlows';
import { convertFilesToBase64 } from '@/src/lib/files';
import { addBusinessDays, isWeekend, nextMonday } from 'date-fns';
import get from 'lodash.get';
import { getNestedValue } from '@/src/lib/utils';

const textInputTypes = {
TEXT: 'text',
Expand Down Expand Up @@ -353,7 +353,7 @@
case supportedTypes.TEXTAREA:
case supportedTypes.TEXT:
// Attempt to remove null bytes from form values - https://gitlab.com/remote-com/employ-starbase/tracker/-/issues/10670
acc[field.name] = formValues[field.name].replace(/\0/g, '');

Check warning on line 356 in src/components/form/utils.ts

View workflow job for this annotation

GitHub Actions / Checks and Tests

eslint(no-control-regex)

Unexpected control character
break;

case supportedTypes.GROUP_ARRAY: {
Expand Down Expand Up @@ -473,7 +473,7 @@
: parentFieldKeyPath;
}

const valueOfField = get(values, fieldKeyPath!);
const valueOfField = getNestedValue(values, fieldKeyPath!);

// keepTruthyInvisibleValues: false/undefined -> remove invisible field
// keepTruthyInvisibleValues: true -> keep invisible field if it has a value
Expand Down Expand Up @@ -601,9 +601,9 @@
defaultValues: Record<string, any>,
field: Field,
) {
// lodash get is needed because some values could be nested object, like billing address
// getNestedValue is needed because some values could be nested object, like billing address
// use camelCase to support forms with fields in snake_case or kebab_case.
const defaultFieldValue = get(defaultValues, field.name);
const defaultFieldValue = getNestedValue(defaultValues, field.name);
const fieldTransformValueFromAPI =
field?.transformValueFromAPI ||
fieldTypesTransformations[field.type]?.transformValueFromAPI;
Expand Down
Loading
Loading