@nextblock-cms/ecom 0.12.13 → 0.12.15

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.
@@ -1,40 +1,49 @@
1
1
  'use client';
2
- import { jsxs as t, jsx as o } from "react/jsx-runtime";
3
- import { useState as c } from "react";
4
- import { Button as a } from "@nextblock-cms/ui";
5
- import { RefreshCw as m } from "lucide-react";
2
+ import { jsxs as c, jsx as a } from "react/jsx-runtime";
3
+ import { useState as u } from "react";
4
+ import { useRouter as f } from "next/navigation";
5
+ import { Button as l } from "@nextblock-cms/ui";
6
+ import { RefreshCw as d } from "lucide-react";
6
7
  import { toast as e } from "sonner";
7
- import { triggerSingleProductSync as l } from "../actions.es.js";
8
- function P({ productId: s }) {
9
- const [n, i] = c(!1);
10
- return /* @__PURE__ */ t(
11
- a,
8
+ import { triggerSingleProductSync as m } from "../actions.es.js";
9
+ function v({ productId: i, hasOpenDraft: s = !1 }) {
10
+ const o = f(), [n, t] = u(!1);
11
+ return /* @__PURE__ */ c(
12
+ l,
12
13
  {
13
14
  variant: "outline",
14
15
  onClick: async () => {
15
- if (!s) {
16
+ if (!i) {
16
17
  e.error("Product ID is missing");
17
18
  return;
18
19
  }
19
- i(!0);
20
- try {
21
- const r = await l(s);
22
- r.error ? e.error(r.error) : e.success("Pricing sync complete!");
23
- } catch (r) {
24
- e.error(r.message || "An unexpected error occurred during sync");
25
- } finally {
26
- i(!1);
20
+ if (!(s && !window.confirm(
21
+ `You have unpublished draft changes for this product.
22
+
23
+ Syncing updates the live pricing now, but publishing your draft afterward will overwrite it with the draft’s older values. Publish or discard your draft first to keep the synced prices.
24
+
25
+ Sync anyway?`
26
+ ))) {
27
+ t(!0);
28
+ try {
29
+ const r = await m(i);
30
+ r.error ? e.error(r.error) : (e.success("Pricing sync complete!"), o.refresh());
31
+ } catch (r) {
32
+ e.error(r.message || "An unexpected error occurred during sync");
33
+ } finally {
34
+ t(!1);
35
+ }
27
36
  }
28
37
  },
29
38
  disabled: n,
30
39
  className: "gap-2",
31
40
  children: [
32
- /* @__PURE__ */ o(m, { className: `w-4 h-4 ${n ? "animate-spin" : ""}` }),
33
- n ? "Syncing..." : "Sync Prices from Freemius"
41
+ /* @__PURE__ */ a(d, { className: `w-4 h-4 ${n ? "animate-spin" : ""}` }),
42
+ n ? "Syncing..." : "Sync Plans & Pricing from Freemius"
34
43
  ]
35
44
  }
36
45
  );
37
46
  }
38
47
  export {
39
- P as SyncFreemiusPricingButton
48
+ v as SyncFreemiusPricingButton
40
49
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("@nextblock-cms/db/server"),o=require("next/cache"),n=require("../customer.cjs.js"),c=require("../customer-addresses.cjs.js");async function p(e){const r=d.createClient(),{data:{user:s},error:u}=await r.auth.getUser();if(u||!s)throw new Error("Unauthorized");const l={full_name:e.full_name||null,avatar_url:e.avatar_url||null,website:e.website||null,github_username:e.github_username||null,phone:e.phone||null,updated_at:new Date().toISOString()},{error:t}=await r.from("profiles").update(l).eq("id",s.id);if(t)throw console.error("Error updating profile:",t),new Error("Failed to update profile");const i=n.normalizeCustomerAddress(e.billing_address),a=e.use_billing_for_shipping?i:n.normalizeCustomerAddress(e.shipping_address);return await c.upsertDefaultUserAddresses({userId:s.id,billingAddress:i,shippingAddress:a,client:r}),o.revalidatePath("/profile"),o.revalidatePath("/checkout"),{success:!0}}exports.updateProfile=p;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("@nextblock-cms/db/server"),o=require("next/cache"),n=require("../customer.cjs.js"),c=require("../customer-addresses.cjs.js");async function p(e){const r=d.createClient(),{data:{user:s},error:l}=await r.auth.getUser();if(l||!s)throw new Error("Unauthorized");const u={full_name:e.full_name||null,avatar_url:e.avatar_url||null,website:e.website||null,phone:e.phone||null,updated_at:new Date().toISOString()},{error:t}=await r.from("profiles").update(u).eq("id",s.id);if(t)throw console.error("Error updating profile:",t),new Error("Failed to update profile");const i=n.normalizeCustomerAddress(e.billing_address),a=e.use_billing_for_shipping?i:n.normalizeCustomerAddress(e.shipping_address);return await c.upsertDefaultUserAddresses({userId:s.id,billingAddress:i,shippingAddress:a,client:r}),o.revalidatePath("/profile"),o.revalidatePath("/checkout"),{success:!0}}exports.updateProfile=p;
@@ -3,7 +3,6 @@ export interface ProfileUpdateData {
3
3
  full_name?: string;
4
4
  avatar_url?: string;
5
5
  website?: string;
6
- github_username?: string;
7
6
  phone?: string;
8
7
  billing_address?: CustomerAddressInput | null;
9
8
  shipping_address?: CustomerAddressInput | null;
@@ -3,28 +3,27 @@ import { createClient as p } from "@nextblock-cms/db/server";
3
3
  import { revalidatePath as s } from "next/cache";
4
4
  import { normalizeCustomerAddress as n } from "../customer.es.js";
5
5
  import { upsertDefaultUserAddresses as d } from "../customer-addresses.es.js";
6
- async function _(r) {
7
- const e = p(), { data: { user: i }, error: l } = await e.auth.getUser();
8
- if (l || !i)
6
+ async function w(r) {
7
+ const e = p(), { data: { user: o }, error: l } = await e.auth.getUser();
8
+ if (l || !o)
9
9
  throw new Error("Unauthorized");
10
- const u = {
10
+ const a = {
11
11
  full_name: r.full_name || null,
12
12
  avatar_url: r.avatar_url || null,
13
13
  website: r.website || null,
14
- github_username: r.github_username || null,
15
14
  phone: r.phone || null,
16
15
  updated_at: (/* @__PURE__ */ new Date()).toISOString()
17
- }, { error: o } = await e.from("profiles").update(u).eq("id", i.id);
18
- if (o)
19
- throw console.error("Error updating profile:", o), new Error("Failed to update profile");
20
- const t = n(r.billing_address), a = r.use_billing_for_shipping ? t : n(r.shipping_address);
16
+ }, { error: t } = await e.from("profiles").update(a).eq("id", o.id);
17
+ if (t)
18
+ throw console.error("Error updating profile:", t), new Error("Failed to update profile");
19
+ const i = n(r.billing_address), u = r.use_billing_for_shipping ? i : n(r.shipping_address);
21
20
  return await d({
22
- userId: i.id,
23
- billingAddress: t,
24
- shippingAddress: a,
21
+ userId: o.id,
22
+ billingAddress: i,
23
+ shippingAddress: u,
25
24
  client: e
26
25
  }), s("/profile"), s("/checkout"), { success: !0 };
27
26
  }
28
27
  export {
29
- _ as updateProfile
28
+ w as updateProfile
30
29
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nextblock-cms/ecom",
3
- "version": "0.12.13",
3
+ "version": "0.12.15",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -10,9 +10,9 @@
10
10
  },
11
11
  "type": "module",
12
12
  "dependencies": {
13
- "@nextblock-cms/db": "^0.12.13",
14
- "@nextblock-cms/ui": "^0.12.13",
15
- "@nextblock-cms/utils": "^0.12.13",
13
+ "@nextblock-cms/db": "^0.12.15",
14
+ "@nextblock-cms/ui": "^0.12.15",
15
+ "@nextblock-cms/utils": "^0.12.15",
16
16
  "@freemius/checkout": "^1.4.1",
17
17
  "@freemius/sdk": "^0.3.0",
18
18
  "@hookform/resolvers": "^5.2.2",