import { get } from 'idb-keyval';
import { updateDoc } from '../../providers/data/doc.firebase';
export const uploadDocs = async ({ data, userId }) => {
  if (!data || data.length <= 0) {
    return;
  }
  const promises = data.map((doc) => uploadDoc({ data: doc, userId }));
  await Promise.all(promises);
};
const uploadDoc = async ({ data, userId }) => {
  const { docId } = data;
  const doc = await get(`/docs/${docId}`);
  if (!doc) {
    return;
  }
  await updateDoc({
    id: docId,
    data: Object.assign(Object.assign({}, doc.data), { owner_id: userId })
  });
};
