import {BasePost} from '../Post';
import {parsePostAttachments} from '../Post/utils';

import {PublishPostValues} from './interfaces';

export const getBaseEventPost = (
  postToEdit: Nullable<BasePost>,
): PublishPostValues => {
  const {multimedia, files, attachmentsSize} = parsePostAttachments(
    postToEdit?.attachments || [],
  );

  return postToEdit
    ? {body: postToEdit.body, multimedia, files, attachmentsSize}
    : {body: '', multimedia: [], files: [], attachmentsSize: 0};
};
