@deepfrog/pangents-widget 2.1.2 → 2.1.4

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/README.md CHANGED
@@ -29,6 +29,7 @@ function App() {
29
29
  pangentsApiKey="Ph75vjKOsJbDuPyxR8-wW0_GYYm7ytVF0XQid2GXEZQ"
30
30
  tenantId="69386fa4a5248bcd50a4fdd2"
31
31
  email="user@example.com" // Optional: pre-fill login email
32
+ zIndex={9999} // Optional: control overlay stacking order
32
33
  theme={{
33
34
  primaryColor: '#1e40af',
34
35
  headerBg: '#1e40af',
@@ -54,6 +55,7 @@ function App() {
54
55
  pangentsApiKey: '<api_key>',
55
56
  tenantId: '<tenant_id>',
56
57
  email: 'user@example.com', // Optional: pre-fill login email
58
+ zIndex: 9999, // Optional: control overlay stacking order
57
59
  theme: {
58
60
  primaryColor: '#1e40af',
59
61
  headerBg: '#1e40af',
@@ -78,6 +80,7 @@ function App() {
78
80
  pangentsApiKey: '<api_key>',
79
81
  tenantId: '<tenant_id>',
80
82
  email: 'user@example.com', // Optional: pre-fill login email
83
+ zIndex: 9999, // Optional: control overlay stacking order
81
84
  theme: {
82
85
  primaryColor: '#1e40af',
83
86
  headerBg: '#1e40af',
package/dist/preview.html CHANGED
@@ -240,6 +240,7 @@ import Chatbot from "https://chat-widget-gamma-azure.vercel.app/widget.js";
240
240
  },
241
241
  position: "bottom-left",
242
242
  margin: "20px",
243
+ zIndex: 9999,
243
244
  });
244
245
  </script>
245
246
  </body>
package/dist/widget.js CHANGED
@@ -10108,6 +10108,7 @@ function chatReducer(state, action) {
10108
10108
  const ChatContext = reactExports.createContext(void 0);
10109
10109
  function ChatProvider({ children, initialTheme, apiKey, tenantId, email }) {
10110
10110
  const [state, dispatch] = reactExports.useReducer(chatReducer, initialState$2);
10111
+ const prevProps = reactExports.useRef({});
10111
10112
  reactExports.useEffect(() => {
10112
10113
  const savedAuth = storageUtils.getAuth();
10113
10114
  const savedSessions = storageUtils.getSessions();
@@ -10253,6 +10254,28 @@ function ChatProvider({ children, initialTheme, apiKey, tenantId, email }) {
10253
10254
  storageUtils.clearAll();
10254
10255
  dispatch({ type: "CLEAR_DATA" });
10255
10256
  };
10257
+ reactExports.useEffect(() => {
10258
+ const storedApiKey = storageUtils.getApiKey();
10259
+ if (apiKey && apiKey !== storedApiKey) {
10260
+ storageUtils.saveApiKey(apiKey);
10261
+ }
10262
+ if (!apiKey && storedApiKey) {
10263
+ storageUtils.clearApiKey();
10264
+ }
10265
+ const storedAuth = storageUtils.getAuth();
10266
+ const storedEmail = storedAuth == null ? void 0 : storedAuth.email;
10267
+ if (email && email !== storedEmail) {
10268
+ storageUtils.clearAuth();
10269
+ storageUtils.saveSessions([]);
10270
+ storageUtils.saveCurrentSession(null);
10271
+ }
10272
+ if (tenantId && prevProps.current.tenantId !== tenantId) {
10273
+ storageUtils.clearAuth();
10274
+ storageUtils.saveSessions([]);
10275
+ storageUtils.saveCurrentSession(null);
10276
+ }
10277
+ prevProps.current = { apiKey, tenantId, email };
10278
+ }, [apiKey, tenantId, email]);
10256
10279
  const contextValue = {
10257
10280
  ...state,
10258
10281
  openWidget,
@@ -33463,11 +33486,15 @@ function Pagination({
33463
33486
  primaryColor
33464
33487
  }) {
33465
33488
  const pages = [];
33466
- for (let i = 1; i <= Math.min(3, totalPages); i++) {
33467
- pages.push(i);
33468
- }
33469
- if (totalPages > 4) {
33470
- pages.push(-1);
33489
+ if (totalPages <= 5) {
33490
+ for (let i = 1; i <= totalPages; i++) pages.push(i);
33491
+ } else {
33492
+ pages.push(1);
33493
+ if (currentPage > 3) pages.push(-1);
33494
+ const start = Math.max(2, currentPage - 1);
33495
+ const end = Math.min(totalPages - 1, currentPage + 1);
33496
+ for (let i = start; i <= end; i++) pages.push(i);
33497
+ if (currentPage < totalPages - 2) pages.push(-1);
33471
33498
  pages.push(totalPages);
33472
33499
  }
33473
33500
  return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-center gap-1 py-3", children: [
@@ -34012,14 +34039,32 @@ function EmailLeadDetailPage() {
34012
34039
  ) : /* @__PURE__ */ jsxRuntimeExports.jsx(CarrierEmailView, { theme }) })
34013
34040
  ] });
34014
34041
  }
34015
- const EMAIL_LEADS_STATS = {
34016
- totalDraftLoads: 45,
34017
- newToday: 9,
34018
- valueOfPotentialLoad: 12330,
34019
- quotesWon: { current: 45, total: 67 },
34020
- conversionsThisMonth: 15,
34021
- timeSaved: 120
34022
- };
34042
+ class DashboardService {
34043
+ static async getEmailsClassifiedTodayCount() {
34044
+ const response = await api.get("/crm/emails/me/metric/clasified_today_count");
34045
+ return response.data;
34046
+ }
34047
+ static async getLeadsTodayCount() {
34048
+ const response = await api.get("/crm/leads/me/leads/count_today");
34049
+ return response.data;
34050
+ }
34051
+ static async getLeadsTillDateCount() {
34052
+ const response = await api.get("/crm/leads/me/leads/count_till_date");
34053
+ return response.data;
34054
+ }
34055
+ static async getDashboardStats() {
34056
+ const [emails, leadsToday, leadsTillDate] = await Promise.all([
34057
+ this.getEmailsClassifiedTodayCount(),
34058
+ this.getLeadsTodayCount(),
34059
+ this.getLeadsTillDateCount()
34060
+ ]);
34061
+ return {
34062
+ emailsClassifiedToday: emails.count ?? 0,
34063
+ leadsToday: leadsToday.count ?? 0,
34064
+ leadsTillDate: leadsTillDate.count ?? 0
34065
+ };
34066
+ }
34067
+ }
34023
34068
  const generateHeatmapData = () => {
34024
34069
  const data = [];
34025
34070
  for (let i = 0; i < 35; i++) {
@@ -34075,6 +34120,8 @@ function Home() {
34075
34120
  var _a2;
34076
34121
  const { theme, user } = useChatContext();
34077
34122
  useNavigate();
34123
+ const [stats, setStats] = reactExports.useState(null);
34124
+ const [statsLoading, setStatsLoading] = reactExports.useState(false);
34078
34125
  const currentDate = (/* @__PURE__ */ new Date()).toLocaleDateString("en-US", {
34079
34126
  weekday: "long",
34080
34127
  month: "long",
@@ -34084,6 +34131,20 @@ function Home() {
34084
34131
  const primaryColor = theme.primaryColor || "#1e40af";
34085
34132
  const userName = ((_a2 = user == null ? void 0 : user.email) == null ? void 0 : _a2.split("@")[0]) || "User";
34086
34133
  const capitalizedName = userName.charAt(0).toUpperCase() + userName.slice(1);
34134
+ reactExports.useEffect(() => {
34135
+ let mounted = true;
34136
+ setStatsLoading(true);
34137
+ DashboardService.getDashboardStats().then((data) => {
34138
+ if (mounted) setStats(data);
34139
+ }).catch(() => {
34140
+ if (mounted) setStats({ emailsClassifiedToday: 0, leadsToday: 0, leadsTillDate: 0 });
34141
+ }).finally(() => {
34142
+ if (mounted) setStatsLoading(false);
34143
+ });
34144
+ return () => {
34145
+ mounted = false;
34146
+ };
34147
+ }, []);
34087
34148
  return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col h-full bg-white overflow-y-auto", style: { fontFamily: theme.fontFamily }, children: [
34088
34149
  /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "px-5 py-4", children: [
34089
34150
  /* @__PURE__ */ jsxRuntimeExports.jsxs("h1", { className: "text-lg text-gray-800", children: [
@@ -34100,8 +34161,8 @@ function Home() {
34100
34161
  /* @__PURE__ */ jsxRuntimeExports.jsx(
34101
34162
  StatCard,
34102
34163
  {
34103
- title: "Total Draft Loads created",
34104
- value: EMAIL_LEADS_STATS.totalDraftLoads,
34164
+ title: "Leads Till Date",
34165
+ value: (stats == null ? void 0 : stats.leadsTillDate) ?? "—",
34105
34166
  borderColor: primaryColor,
34106
34167
  iconBg: `${primaryColor}15`,
34107
34168
  iconColor: primaryColor,
@@ -34111,8 +34172,8 @@ function Home() {
34111
34172
  /* @__PURE__ */ jsxRuntimeExports.jsx(
34112
34173
  StatCard,
34113
34174
  {
34114
- title: "New Today",
34115
- value: `0${EMAIL_LEADS_STATS.newToday}`,
34175
+ title: "Leads Today",
34176
+ value: stats ? `${stats.leadsToday}` : "—",
34116
34177
  borderColor: "#ef4444",
34117
34178
  iconBg: "#fef2f2",
34118
34179
  iconColor: "#ef4444",
@@ -34122,8 +34183,8 @@ function Home() {
34122
34183
  /* @__PURE__ */ jsxRuntimeExports.jsx(
34123
34184
  StatCard,
34124
34185
  {
34125
- title: "Value of Potential Load",
34126
- value: `$${EMAIL_LEADS_STATS.valueOfPotentialLoad.toLocaleString()}`,
34186
+ title: "Emails Classified Today",
34187
+ value: (stats == null ? void 0 : stats.emailsClassifiedToday) ?? "—",
34127
34188
  borderColor: "#ef4444",
34128
34189
  iconBg: "#fef2f2",
34129
34190
  iconColor: "#ef4444",
@@ -34136,7 +34197,7 @@ function Home() {
34136
34197
  StatCard,
34137
34198
  {
34138
34199
  title: "Quotes Won",
34139
- value: `${EMAIL_LEADS_STATS.quotesWon.current}/${EMAIL_LEADS_STATS.quotesWon.total}`,
34200
+ value: "—",
34140
34201
  borderColor: "#22c55e",
34141
34202
  iconBg: "#f0fdf4",
34142
34203
  iconColor: "#22c55e",
@@ -34149,7 +34210,7 @@ function Home() {
34149
34210
  /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "w-6 h-6 rounded-full flex items-center justify-center", style: { backgroundColor: `${primaryColor}15` }, children: /* @__PURE__ */ jsxRuntimeExports.jsx(TrendingUp, { className: "w-3 h-3", style: { color: primaryColor } }) }),
34150
34211
  /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-xs text-gray-600", children: "Conversions this month" })
34151
34212
  ] }),
34152
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "mt-2", children: /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-xl font-bold", style: { color: primaryColor }, children: EMAIL_LEADS_STATS.conversionsThisMonth }) })
34213
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "mt-2", children: /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-xl font-bold", style: { color: primaryColor }, children: "—" }) })
34153
34214
  ] }),
34154
34215
  /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex-shrink-0", children: /* @__PURE__ */ jsxRuntimeExports.jsx(ActivityHeatmap, { primaryColor }) })
34155
34216
  ] }) })
@@ -34158,7 +34219,7 @@ function Home() {
34158
34219
  StatCard,
34159
34220
  {
34160
34221
  title: "Time Saved",
34161
- value: `${EMAIL_LEADS_STATS.timeSaved} Mins`,
34222
+ value: "—",
34162
34223
  borderColor: primaryColor,
34163
34224
  iconBg: `${primaryColor}15`,
34164
34225
  iconColor: primaryColor,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@deepfrog/pangents-widget",
3
3
  "private": false,
4
- "version": "2.1.2",
4
+ "version": "2.1.4",
5
5
  "description": "Pangents AI - Embeddable AI widget for web applications",
6
6
  "type": "module",
7
7
  "main": "dist/index.cjs.js",