@infuro/cms-core 1.0.21 → 1.0.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/admin.cjs CHANGED
@@ -401,7 +401,7 @@ var defaultValue = {
401
401
  var AdminConfigContext = (0, import_react4.createContext)(defaultValue);
402
402
 
403
403
  // src/lib/cms-version.ts
404
- var CMS_VERSION = true ? "1.0.21" : "0.0.0";
404
+ var CMS_VERSION = true ? "1.0.22" : "0.0.0";
405
405
 
406
406
  // src/components/Admin/Sidebar.tsx
407
407
  var import_jsx_runtime4 = require("react/jsx-runtime");
package/dist/admin.js CHANGED
@@ -351,7 +351,7 @@ var defaultValue = {
351
351
  var AdminConfigContext = createContext(defaultValue);
352
352
 
353
353
  // src/lib/cms-version.ts
354
- var CMS_VERSION = true ? "1.0.21" : "0.0.0";
354
+ var CMS_VERSION = true ? "1.0.22" : "0.0.0";
355
355
 
356
356
  // src/components/Admin/Sidebar.tsx
357
357
  import { jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
package/dist/api.cjs CHANGED
@@ -2947,15 +2947,33 @@ function createChatHandlers(config) {
2947
2947
  const email = body?.email?.trim();
2948
2948
  if (!name || !email) return json({ error: "name and email required" }, { status: 400 });
2949
2949
  const repo = contactRepo();
2950
- let contact = await repo.findOne({ where: { email, deleted: false } });
2951
- if (!contact) {
2952
- const created = repo.create({ name, email, phone: body.phone?.trim() || null });
2953
- contact = await repo.save(created);
2950
+ const phone = body.phone?.trim() || null;
2951
+ const existing = await repo.findOne({ where: { email } });
2952
+ let contact;
2953
+ if (!existing) {
2954
+ contact = await repo.save(repo.create({ name, email, phone }));
2955
+ } else {
2956
+ const row = existing;
2957
+ if (row.deleted) {
2958
+ await repo.update(row.id, {
2959
+ deleted: false,
2960
+ deletedAt: null,
2961
+ deletedBy: null,
2962
+ name,
2963
+ phone
2964
+ });
2965
+ const refreshed = await repo.findOne({ where: { id: row.id } });
2966
+ if (!refreshed) return json({ error: "Failed to identify", detail: "contact missing after reactivate" }, { status: 500 });
2967
+ contact = refreshed;
2968
+ } else {
2969
+ contact = existing;
2970
+ }
2954
2971
  }
2955
2972
  const convRepoInst = convRepo();
2956
- const conv = await convRepoInst.save(convRepoInst.create({ contactId: contact.id }));
2973
+ const contactId = contact.id;
2974
+ const conv = await convRepoInst.save(convRepoInst.create({ contactId }));
2957
2975
  return json({
2958
- contactId: contact.id,
2976
+ contactId,
2959
2977
  conversationId: conv.id
2960
2978
  });
2961
2979
  } catch (err) {