export function buildFormData(
  formGroup: any,
  fileProperties: { [key: string]: File | null } = {},
  skipFieldKeys: string[] = [],
): FormData {
  const formData = new FormData();

  Object.keys(formGroup.controls).forEach((key) => {
    if (skipFieldKeys.includes(key)) {
      return;
    }
    const control = formGroup.get(key);
    if (control && control.value !== null && control.value !== undefined) {
      formData.append(key, control.value);
    }
  });

  Object.keys(fileProperties).forEach((key) => {
    const file = fileProperties[key];
    if (file) {
      formData.append(key, file, file.name);
    }
  });

  return formData;
}
