@alphabite/medusa-wishlist 0.7.1 → 0.7.3

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.
@@ -6,6 +6,7 @@ const reactQuery = require("@tanstack/react-query");
6
6
  const Medusa = require("@medusajs/js-sdk");
7
7
  const icons = require("@medusajs/icons");
8
8
  const react = require("react");
9
+ const reactRouterDom = require("react-router-dom");
9
10
  const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
10
11
  const Medusa__default = /* @__PURE__ */ _interopDefault(Medusa);
11
12
  const sdk = new Medusa__default.default({
@@ -82,10 +83,7 @@ const WishlistAnalyticsTab = () => {
82
83
  }
83
84
  });
84
85
  const maxTrend = react.useMemo(
85
- () => Math.max(
86
- 1,
87
- ...(data == null ? void 0 : data.trend.map((t) => Math.max(t.wishlists, t.items))) ?? [1]
88
- ),
86
+ () => Math.max(1, ...(data == null ? void 0 : data.trend.map((t) => t.items)) ?? [1]),
89
87
  [data]
90
88
  );
91
89
  if (isError) {
@@ -115,14 +113,6 @@ const WishlistAnalyticsTab = () => {
115
113
  ] }),
116
114
  !hasData ? /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "text-ui-fg-subtle", children: "No wishlist activity in this period yet." }) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
117
115
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3", children: [
118
- /* @__PURE__ */ jsxRuntime.jsx(
119
- KpiCard,
120
- {
121
- label: "Total wishlists",
122
- value: String(data.kpis.total_wishlists.value),
123
- delta: data.kpis.total_wishlists.delta_pct
124
- }
125
- ),
126
116
  /* @__PURE__ */ jsxRuntime.jsx(
127
117
  KpiCard,
128
118
  {
@@ -163,41 +153,26 @@ const WishlistAnalyticsTab = () => {
163
153
  )
164
154
  ] }),
165
155
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-2 rounded-lg border p-4", children: [
166
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", weight: "plus", children: "Activity over time" }),
156
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", weight: "plus", children: "Items added over time" }),
167
157
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex h-40 items-end gap-1 overflow-x-auto", children: data.trend.map((t) => /* @__PURE__ */ jsxRuntime.jsx(
168
158
  "div",
169
159
  {
170
160
  className: "flex min-w-[10px] flex-1 flex-col items-center justify-end gap-0.5",
171
- title: `${t.date}: ${t.wishlists} wishlists, ${t.items} items`,
172
- children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex h-32 w-full items-end justify-center gap-0.5", children: [
173
- /* @__PURE__ */ jsxRuntime.jsx(
174
- "div",
175
- {
176
- className: "w-1/2 rounded-t bg-ui-fg-interactive",
177
- style: {
178
- height: `${t.wishlists / maxTrend * 100}%`,
179
- minHeight: t.wishlists > 0 ? "2px" : void 0
180
- }
181
- }
182
- ),
183
- /* @__PURE__ */ jsxRuntime.jsx(
184
- "div",
185
- {
186
- className: "w-1/2 rounded-t bg-ui-fg-muted",
187
- style: {
188
- height: `${t.items / maxTrend * 100}%`,
189
- minHeight: t.items > 0 ? "2px" : void 0
190
- }
161
+ title: `${t.date}: ${t.items} items`,
162
+ children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex h-32 w-full items-end justify-center", children: /* @__PURE__ */ jsxRuntime.jsx(
163
+ "div",
164
+ {
165
+ className: "w-full rounded-t bg-ui-fg-interactive",
166
+ style: {
167
+ height: `${t.items / maxTrend * 100}%`,
168
+ minHeight: t.items > 0 ? "2px" : void 0
191
169
  }
192
- )
193
- ] })
170
+ }
171
+ ) })
194
172
  },
195
173
  t.date
196
174
  )) }),
197
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex gap-4", children: [
198
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "xsmall", className: "text-ui-fg-subtle", children: "▮ Wishlists" }),
199
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "xsmall", className: "text-ui-fg-muted", children: "▮ Items" })
200
- ] })
175
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex gap-4", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "xsmall", className: "text-ui-fg-subtle", children: "▮ Items" }) })
201
176
  ] }),
202
177
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-2", children: [
203
178
  /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h3", children: "Most-wishlisted products (top 10)" }),
@@ -208,17 +183,24 @@ const WishlistAnalyticsTab = () => {
208
183
  /* @__PURE__ */ jsxRuntime.jsx(ui.Table.HeaderCell, { className: "text-right", children: "Items" })
209
184
  ] }) }),
210
185
  /* @__PURE__ */ jsxRuntime.jsx(ui.Table.Body, { children: data.top_products.map((p) => /* @__PURE__ */ jsxRuntime.jsxs(ui.Table.Row, { children: [
211
- /* @__PURE__ */ jsxRuntime.jsx(ui.Table.Cell, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [
212
- p.thumbnail ? /* @__PURE__ */ jsxRuntime.jsx(
213
- "img",
214
- {
215
- src: p.thumbnail,
216
- alt: "",
217
- className: "h-8 w-8 rounded object-cover"
218
- }
219
- ) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-8 w-8 rounded bg-ui-bg-subtle" }),
220
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", children: p.title })
221
- ] }) }),
186
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Table.Cell, { children: /* @__PURE__ */ jsxRuntime.jsxs(
187
+ reactRouterDom.Link,
188
+ {
189
+ to: `/products/${p.product_id}`,
190
+ className: "flex items-center gap-2 hover:underline",
191
+ children: [
192
+ p.thumbnail ? /* @__PURE__ */ jsxRuntime.jsx(
193
+ "img",
194
+ {
195
+ src: p.thumbnail,
196
+ alt: "",
197
+ className: "h-8 w-8 rounded object-cover"
198
+ }
199
+ ) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-8 w-8 rounded bg-ui-bg-subtle" }),
200
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-interactive", children: p.title })
201
+ ]
202
+ }
203
+ ) }),
222
204
  /* @__PURE__ */ jsxRuntime.jsx(ui.Table.Cell, { className: "text-right", children: p.wishlist_count }),
223
205
  /* @__PURE__ */ jsxRuntime.jsx(ui.Table.Cell, { className: "text-right", children: p.item_count })
224
206
  ] }, p.product_id)) })
@@ -232,7 +214,14 @@ const WishlistAnalyticsTab = () => {
232
214
  /* @__PURE__ */ jsxRuntime.jsx(ui.Table.HeaderCell, { className: "text-right", children: "Wishlists" })
233
215
  ] }) }),
234
216
  /* @__PURE__ */ jsxRuntime.jsx(ui.Table.Body, { children: data.top_variants.map((v) => /* @__PURE__ */ jsxRuntime.jsxs(ui.Table.Row, { children: [
235
- /* @__PURE__ */ jsxRuntime.jsx(ui.Table.Cell, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", children: v.title }) }),
217
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Table.Cell, { children: /* @__PURE__ */ jsxRuntime.jsx(
218
+ reactRouterDom.Link,
219
+ {
220
+ to: `/products/${v.product_id}`,
221
+ className: "hover:underline",
222
+ children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-interactive", children: v.title })
223
+ }
224
+ ) }),
236
225
  /* @__PURE__ */ jsxRuntime.jsx(ui.Table.Cell, { className: "text-right", children: v.wishlist_count })
237
226
  ] }, v.product_variant_id)) })
238
227
  ] })
@@ -5,6 +5,7 @@ import { useQuery, useQueryClient, useMutation } from "@tanstack/react-query";
5
5
  import Medusa from "@medusajs/js-sdk";
6
6
  import { Heart } from "@medusajs/icons";
7
7
  import { useState, useMemo, useEffect } from "react";
8
+ import { Link } from "react-router-dom";
8
9
  const sdk = new Medusa({
9
10
  baseUrl: __BACKEND_URL__ || "http://localhost:9000",
10
11
  debug: process.env.NODE_ENV === "development",
@@ -79,10 +80,7 @@ const WishlistAnalyticsTab = () => {
79
80
  }
80
81
  });
81
82
  const maxTrend = useMemo(
82
- () => Math.max(
83
- 1,
84
- ...(data == null ? void 0 : data.trend.map((t) => Math.max(t.wishlists, t.items))) ?? [1]
85
- ),
83
+ () => Math.max(1, ...(data == null ? void 0 : data.trend.map((t) => t.items)) ?? [1]),
86
84
  [data]
87
85
  );
88
86
  if (isError) {
@@ -112,14 +110,6 @@ const WishlistAnalyticsTab = () => {
112
110
  ] }),
113
111
  !hasData ? /* @__PURE__ */ jsx(Text, { className: "text-ui-fg-subtle", children: "No wishlist activity in this period yet." }) : /* @__PURE__ */ jsxs(Fragment, { children: [
114
112
  /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3", children: [
115
- /* @__PURE__ */ jsx(
116
- KpiCard,
117
- {
118
- label: "Total wishlists",
119
- value: String(data.kpis.total_wishlists.value),
120
- delta: data.kpis.total_wishlists.delta_pct
121
- }
122
- ),
123
113
  /* @__PURE__ */ jsx(
124
114
  KpiCard,
125
115
  {
@@ -160,41 +150,26 @@ const WishlistAnalyticsTab = () => {
160
150
  )
161
151
  ] }),
162
152
  /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-2 rounded-lg border p-4", children: [
163
- /* @__PURE__ */ jsx(Text, { size: "small", weight: "plus", children: "Activity over time" }),
153
+ /* @__PURE__ */ jsx(Text, { size: "small", weight: "plus", children: "Items added over time" }),
164
154
  /* @__PURE__ */ jsx("div", { className: "flex h-40 items-end gap-1 overflow-x-auto", children: data.trend.map((t) => /* @__PURE__ */ jsx(
165
155
  "div",
166
156
  {
167
157
  className: "flex min-w-[10px] flex-1 flex-col items-center justify-end gap-0.5",
168
- title: `${t.date}: ${t.wishlists} wishlists, ${t.items} items`,
169
- children: /* @__PURE__ */ jsxs("div", { className: "flex h-32 w-full items-end justify-center gap-0.5", children: [
170
- /* @__PURE__ */ jsx(
171
- "div",
172
- {
173
- className: "w-1/2 rounded-t bg-ui-fg-interactive",
174
- style: {
175
- height: `${t.wishlists / maxTrend * 100}%`,
176
- minHeight: t.wishlists > 0 ? "2px" : void 0
177
- }
178
- }
179
- ),
180
- /* @__PURE__ */ jsx(
181
- "div",
182
- {
183
- className: "w-1/2 rounded-t bg-ui-fg-muted",
184
- style: {
185
- height: `${t.items / maxTrend * 100}%`,
186
- minHeight: t.items > 0 ? "2px" : void 0
187
- }
158
+ title: `${t.date}: ${t.items} items`,
159
+ children: /* @__PURE__ */ jsx("div", { className: "flex h-32 w-full items-end justify-center", children: /* @__PURE__ */ jsx(
160
+ "div",
161
+ {
162
+ className: "w-full rounded-t bg-ui-fg-interactive",
163
+ style: {
164
+ height: `${t.items / maxTrend * 100}%`,
165
+ minHeight: t.items > 0 ? "2px" : void 0
188
166
  }
189
- )
190
- ] })
167
+ }
168
+ ) })
191
169
  },
192
170
  t.date
193
171
  )) }),
194
- /* @__PURE__ */ jsxs("div", { className: "flex gap-4", children: [
195
- /* @__PURE__ */ jsx(Text, { size: "xsmall", className: "text-ui-fg-subtle", children: "▮ Wishlists" }),
196
- /* @__PURE__ */ jsx(Text, { size: "xsmall", className: "text-ui-fg-muted", children: "▮ Items" })
197
- ] })
172
+ /* @__PURE__ */ jsx("div", { className: "flex gap-4", children: /* @__PURE__ */ jsx(Text, { size: "xsmall", className: "text-ui-fg-subtle", children: "▮ Items" }) })
198
173
  ] }),
199
174
  /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-2", children: [
200
175
  /* @__PURE__ */ jsx(Heading, { level: "h3", children: "Most-wishlisted products (top 10)" }),
@@ -205,17 +180,24 @@ const WishlistAnalyticsTab = () => {
205
180
  /* @__PURE__ */ jsx(Table.HeaderCell, { className: "text-right", children: "Items" })
206
181
  ] }) }),
207
182
  /* @__PURE__ */ jsx(Table.Body, { children: data.top_products.map((p) => /* @__PURE__ */ jsxs(Table.Row, { children: [
208
- /* @__PURE__ */ jsx(Table.Cell, { children: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
209
- p.thumbnail ? /* @__PURE__ */ jsx(
210
- "img",
211
- {
212
- src: p.thumbnail,
213
- alt: "",
214
- className: "h-8 w-8 rounded object-cover"
215
- }
216
- ) : /* @__PURE__ */ jsx("div", { className: "h-8 w-8 rounded bg-ui-bg-subtle" }),
217
- /* @__PURE__ */ jsx(Text, { size: "small", children: p.title })
218
- ] }) }),
183
+ /* @__PURE__ */ jsx(Table.Cell, { children: /* @__PURE__ */ jsxs(
184
+ Link,
185
+ {
186
+ to: `/products/${p.product_id}`,
187
+ className: "flex items-center gap-2 hover:underline",
188
+ children: [
189
+ p.thumbnail ? /* @__PURE__ */ jsx(
190
+ "img",
191
+ {
192
+ src: p.thumbnail,
193
+ alt: "",
194
+ className: "h-8 w-8 rounded object-cover"
195
+ }
196
+ ) : /* @__PURE__ */ jsx("div", { className: "h-8 w-8 rounded bg-ui-bg-subtle" }),
197
+ /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-interactive", children: p.title })
198
+ ]
199
+ }
200
+ ) }),
219
201
  /* @__PURE__ */ jsx(Table.Cell, { className: "text-right", children: p.wishlist_count }),
220
202
  /* @__PURE__ */ jsx(Table.Cell, { className: "text-right", children: p.item_count })
221
203
  ] }, p.product_id)) })
@@ -229,7 +211,14 @@ const WishlistAnalyticsTab = () => {
229
211
  /* @__PURE__ */ jsx(Table.HeaderCell, { className: "text-right", children: "Wishlists" })
230
212
  ] }) }),
231
213
  /* @__PURE__ */ jsx(Table.Body, { children: data.top_variants.map((v) => /* @__PURE__ */ jsxs(Table.Row, { children: [
232
- /* @__PURE__ */ jsx(Table.Cell, { children: /* @__PURE__ */ jsx(Text, { size: "small", children: v.title }) }),
214
+ /* @__PURE__ */ jsx(Table.Cell, { children: /* @__PURE__ */ jsx(
215
+ Link,
216
+ {
217
+ to: `/products/${v.product_id}`,
218
+ className: "hover:underline",
219
+ children: /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-interactive", children: v.title })
220
+ }
221
+ ) }),
233
222
  /* @__PURE__ */ jsx(Table.Cell, { className: "text-right", children: v.wishlist_count })
234
223
  ] }, v.product_variant_id)) })
235
224
  ] })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alphabite/medusa-wishlist",
3
- "version": "0.7.1",
3
+ "version": "0.7.3",
4
4
  "description": "Alphabite's Medusa Wishlist Plugin",
5
5
  "author": "Alphabite (https://alphabite.io)",
6
6
  "license": "MIT",