Skip to content

Commit

Permalink
feat: display updated local units in modal after editing
Browse files Browse the repository at this point in the history
  • Loading branch information
samshara committed Dec 13, 2024
1 parent 4c8d60a commit 7a862f1
Show file tree
Hide file tree
Showing 5 changed files with 281 additions and 108 deletions.
25 changes: 25 additions & 0 deletions app/src/utils/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,28 @@ export function getFirstTruthyString(

return invalidText;
}

export function compareArrays(newArray: unknown[], oldArray: unknown[]): boolean {
if (newArray.length !== oldArray.length) {
return false;
}
return newArray.every((id) => oldArray.includes(id));
}

export function flattenObject<T extends Record<string, unknown>>(
inputObject: T,
prefix?: string,
): Record<string, unknown> {
return Object.entries(inputObject).reduce((acc, [key, value]) => {
const newKey = prefix ? `${prefix}.${key}` : key;
if (typeof value === 'object' && value !== null && !Array.isArray(value)) {
return { ...acc, ...flattenObject(value as Record<string, unknown>, newKey) };
}
return { ...acc, [newKey]: value };
}, {} as Record<string, unknown>);
}

export function getLastSegment(str: string, delimiter: string) {
const parts = str.split(delimiter);
return parts[parts.length - 1];
}

This file was deleted.

Loading

0 comments on commit 7a862f1

Please sign in to comment.