add settings permissions update (#11377)

Fixes https://github.com/twentyhq/core-team-issues/issues/710
This commit is contained in:
Weiko
2025-04-04 17:40:14 +02:00
committed by GitHub
parent 6142e193ce
commit e1f6c61651
23 changed files with 528 additions and 165 deletions

View File

@ -0,0 +1,26 @@
import { isDeeplyEqual } from './isDeeplyEqual';
export const getDirtyFields = <T extends Record<string, any>>(
draft: T,
persisted: T | null | undefined,
): Partial<T> => {
if (!persisted) {
return Object.fromEntries(
Object.entries(draft).filter(([, value]) => value !== undefined),
) as Partial<T>;
}
const dirty: Partial<T> = {};
const allKeys = new Set([...Object.keys(draft), ...Object.keys(persisted)]);
for (const key of allKeys) {
const draftValue = draft[key as keyof T];
const persistedValue = persisted[key as keyof T];
if (!isDeeplyEqual(draftValue, persistedValue)) {
dirty[key as keyof T] = draftValue;
}
}
return dirty;
};