import state from "../../store";
export default async function addNote(db, { html, tags, jobId, userId, companyId, sendAlert, locationId }) {
  var _a, _b, _c;
  const docData = {
    html,
    tags,
    location: locationId || ((_a = state === null || state === void 0 ? void 0 : state.claims) === null || _a === void 0 ? void 0 : _a.locationId)
      ? db.document("locations", locationId || ((_b = state === null || state === void 0 ? void 0 : state.claims) === null || _b === void 0 ? void 0 : _b.locationId))
      : null,
    job: jobId ? db.document("jobs", jobId) : null,
    user: userId ? db.document("users", userId) : null,
    company: companyId ? db.document("companies", companyId) : null,
    createdAt: new Date(),
    createdBy: ((_c = state === null || state === void 0 ? void 0 : state.session) === null || _c === void 0 ? void 0 : _c.uid)
      ? db.document("users", state.session.uid)
      : null,
    sendAlert,
  };
  const addDoc = await db.add("notes", docData);
  docData.id = addDoc.id;
  return docData;
}
