mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-12 19:03:47 +00:00
aa4ee546ec
--------- Co-authored-by: Carlos Valente <carlosvalente@pm.me>
18 lines
546 B
TypeScript
18 lines
546 B
TypeScript
import { DatabaseModel, isKeyOfType } from 'ontime-types';
|
|
|
|
export async function makeProjectPatch(data: DatabaseModel, mergeKeys: Record<string, boolean>) {
|
|
const patchObject: Partial<DatabaseModel> = {};
|
|
|
|
for (const key in mergeKeys) {
|
|
if (isKeyOfType(key, data) && mergeKeys[key]) {
|
|
// if the rundown is merged we also need the custom fields
|
|
if (key === 'rundown') {
|
|
patchObject.customFields = data['customFields'];
|
|
}
|
|
Object.assign(patchObject, { [key]: data[key] });
|
|
}
|
|
}
|
|
|
|
return patchObject;
|
|
}
|