import state from "../../store";
export default async function addStep(db, { tags, name, beforeHTML, afterHTML, fields, templateId }) {
  var _a;
  const id = db.getDocumentId();
  const docData = {
    id,
    tags,
    fields: fields || [],
    createdAt: new Date(),
    name,
    beforeHTML,
    afterHTML,
    createdBy: ((_a = state === null || state === void 0 ? void 0 : state.session) === null || _a === void 0 ? void 0 : _a.uid)
      ? db.document("users", state.session.uid)
      : null,
    template: templateId ? db.document("templates", templateId) : null,
  };
  const addDoc = await db.add("steps", docData, id);
  docData.id = addDoc.id;
  return docData;
}
