Fixed creation of users + better frontend handling of permissions

This commit is contained in:
cdricms
2025-03-06 17:34:52 +01:00
parent 3c6038bce1
commit 7cb633b4c6
46 changed files with 1511 additions and 909 deletions

View File

@@ -8,3 +8,33 @@ export function cn(...inputs: ClassValue[]) {
export function toTitleCase(str: string) {
return str.replace(/\b\w/g, (char) => char.toUpperCase());
}
namespace DiffUtils {
export function getDifferences<T extends object>(
obj1: T,
obj2: T,
): Partial<T> {
return Object.entries(obj2).reduce((diff, [key, value]) => {
if (
JSON.stringify(obj1[key as keyof T]) !==
JSON.stringify(obj2[key as keyof T])
) {
diff[key as keyof T] = value as T[keyof T];
}
return diff;
}, {} as Partial<T>);
}
export function isEmpty<T extends object>(obj: T) {
return Object.keys(obj).length === 0;
}
}
// Make it globally available
if (typeof window !== "undefined") {
(window as any).DiffUtils = DiffUtils;
} else {
(global as any).DiffUtils = DiffUtils;
}
export default DiffUtils;