@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.
- package/lib/components/CustomerProfileForm.cjs.js +1 -1
- package/lib/components/CustomerProfileForm.es.js +185 -238
- package/lib/pages/cms/orders/types.d.ts +0 -1
- package/lib/pages/cms/products/actions.cjs.js +4 -4
- package/lib/pages/cms/products/actions.es.js +8 -8
- package/lib/pages/cms/products/components/ProductForm.cjs.js +1 -1
- package/lib/pages/cms/products/components/ProductForm.d.ts +3 -1
- package/lib/pages/cms/products/components/ProductForm.es.js +53 -46
- package/lib/pages/cms/products/components/SyncFreemiusPricingButton.cjs.js +5 -1
- package/lib/pages/cms/products/components/SyncFreemiusPricingButton.d.ts +3 -1
- package/lib/pages/cms/products/components/SyncFreemiusPricingButton.es.js +30 -21
- package/lib/server-actions/customer-actions.cjs.js +1 -1
- package/lib/server-actions/customer-actions.d.ts +0 -1
- package/lib/server-actions/customer-actions.es.js +12 -13
- package/package.json +4 -4
|
@@ -1,40 +1,49 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import { jsxs as
|
|
3
|
-
import { useState as
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
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
|
|
8
|
-
function
|
|
9
|
-
const [n,
|
|
10
|
-
return /* @__PURE__ */
|
|
11
|
-
|
|
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 (!
|
|
16
|
+
if (!i) {
|
|
16
17
|
e.error("Product ID is missing");
|
|
17
18
|
return;
|
|
18
19
|
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
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__ */
|
|
33
|
-
n ? "Syncing..." : "Sync
|
|
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
|
-
|
|
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:
|
|
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,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
|
|
7
|
-
const e = p(), { data: { user:
|
|
8
|
-
if (l || !
|
|
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
|
|
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:
|
|
18
|
-
if (
|
|
19
|
-
throw console.error("Error updating profile:",
|
|
20
|
-
const
|
|
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:
|
|
23
|
-
billingAddress:
|
|
24
|
-
shippingAddress:
|
|
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
|
-
|
|
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.
|
|
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.
|
|
14
|
-
"@nextblock-cms/ui": "^0.12.
|
|
15
|
-
"@nextblock-cms/utils": "^0.12.
|
|
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",
|