@infuro/cms-core 1.0.40 → 1.0.41
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 +107 -107
- package/dist/admin.js +107 -107
- package/dist/api.cjs +32 -32
- package/dist/api.js +1 -1
- package/dist/{chunk-RCMUL6SZ.js → chunk-EG4ICILK.js} +32 -70
- package/dist/{chunk-T7GCOO5Y.cjs → chunk-QU554KAZ.cjs} +32 -70
- package/dist/index.cjs +189 -189
- package/dist/index.js +2 -2
- package/package.json +2 -2
package/dist/admin.cjs
CHANGED
|
@@ -492,7 +492,7 @@ var init_admin_config_context = __esm({
|
|
|
492
492
|
var CMS_VERSION;
|
|
493
493
|
var init_cms_version = __esm({
|
|
494
494
|
"src/lib/cms-version.ts"() {
|
|
495
|
-
CMS_VERSION = "1.0.
|
|
495
|
+
CMS_VERSION = "1.0.41" ;
|
|
496
496
|
}
|
|
497
497
|
});
|
|
498
498
|
function useCatalogCategories(enabled = true) {
|
|
@@ -31568,11 +31568,10 @@ function VendorEditPage({ vendorId }) {
|
|
|
31568
31568
|
const [ownerPhone, setOwnerPhone] = React26.useState("");
|
|
31569
31569
|
const [ownerDesignation, setOwnerDesignation] = React26.useState("");
|
|
31570
31570
|
const [termsAccepted, setTermsAccepted] = React26.useState(false);
|
|
31571
|
-
const [activationMode, setActivationMode] = React26.useState("invite");
|
|
31572
|
-
const [sendOwnerEmail, setSendOwnerEmail] = React26.useState(true);
|
|
31573
|
-
const [ownerPassword, setOwnerPassword] = React26.useState("");
|
|
31574
|
-
const [ownerPasswordConfirm, setOwnerPasswordConfirm] = React26.useState("");
|
|
31575
31571
|
const [reinviting, setReinviting] = React26.useState(false);
|
|
31572
|
+
const [inviteDialog, setInviteDialog] = React26.useState(null);
|
|
31573
|
+
const [sendingInviteEmail, setSendingInviteEmail] = React26.useState(false);
|
|
31574
|
+
const [linkCopied, setLinkCopied] = React26.useState(false);
|
|
31576
31575
|
const vendorPayload = /* @__PURE__ */ __name(() => ({
|
|
31577
31576
|
name: name.trim(),
|
|
31578
31577
|
legalName: legalName.trim() || null,
|
|
@@ -31708,6 +31707,59 @@ function VendorEditPage({ vendorId }) {
|
|
|
31708
31707
|
groupName: sessionUser?.groupName
|
|
31709
31708
|
});
|
|
31710
31709
|
}
|
|
31710
|
+
const copyInviteLink = /* @__PURE__ */ __name(async () => {
|
|
31711
|
+
const inviteLink = inviteDialog?.inviteLink;
|
|
31712
|
+
if (!inviteLink) {
|
|
31713
|
+
sonner.toast.error("Invite link is not available");
|
|
31714
|
+
return;
|
|
31715
|
+
}
|
|
31716
|
+
try {
|
|
31717
|
+
await navigator.clipboard.writeText(inviteLink);
|
|
31718
|
+
setLinkCopied(true);
|
|
31719
|
+
sonner.toast.success("Invite link copied");
|
|
31720
|
+
window.setTimeout(() => setLinkCopied(false), 2e3);
|
|
31721
|
+
} catch {
|
|
31722
|
+
sonner.toast.error("Could not copy invite link");
|
|
31723
|
+
}
|
|
31724
|
+
}, "copyInviteLink");
|
|
31725
|
+
const sendInviteEmail = /* @__PURE__ */ __name(async () => {
|
|
31726
|
+
if (!inviteDialog) return;
|
|
31727
|
+
setSendingInviteEmail(true);
|
|
31728
|
+
try {
|
|
31729
|
+
const res = await fetch(`/api/admin/vendors/${inviteDialog.vendorId}/resend-invite`, {
|
|
31730
|
+
method: "POST",
|
|
31731
|
+
headers: {
|
|
31732
|
+
"Content-Type": "application/json"
|
|
31733
|
+
},
|
|
31734
|
+
body: JSON.stringify({
|
|
31735
|
+
sendEmail: true,
|
|
31736
|
+
rotate: false
|
|
31737
|
+
})
|
|
31738
|
+
});
|
|
31739
|
+
const data = await res.json();
|
|
31740
|
+
if (!res.ok) {
|
|
31741
|
+
sonner.toast.error(data.error || data.message || "Failed to send invite email");
|
|
31742
|
+
return;
|
|
31743
|
+
}
|
|
31744
|
+
const nextLink = typeof data.inviteLink === "string" ? data.inviteLink.trim() : "";
|
|
31745
|
+
if (nextLink) {
|
|
31746
|
+
setInviteDialog((prev) => prev ? {
|
|
31747
|
+
...prev,
|
|
31748
|
+
inviteLink: nextLink
|
|
31749
|
+
} : prev);
|
|
31750
|
+
}
|
|
31751
|
+
sonner.toast.success(data.emailSent ? "Invite email sent" : data.message || "Invite email queued");
|
|
31752
|
+
} catch {
|
|
31753
|
+
sonner.toast.error("Failed to send invite email");
|
|
31754
|
+
} finally {
|
|
31755
|
+
setSendingInviteEmail(false);
|
|
31756
|
+
}
|
|
31757
|
+
}, "sendInviteEmail");
|
|
31758
|
+
const closeInviteDialog = /* @__PURE__ */ __name(() => {
|
|
31759
|
+
setInviteDialog(null);
|
|
31760
|
+
setLinkCopied(false);
|
|
31761
|
+
router.push(listReturnUrl);
|
|
31762
|
+
}, "closeInviteDialog");
|
|
31711
31763
|
const handleCreate = /* @__PURE__ */ __name(async () => {
|
|
31712
31764
|
setSaving(true);
|
|
31713
31765
|
setErrors([]);
|
|
@@ -31733,29 +31785,6 @@ function VendorEditPage({ vendorId }) {
|
|
|
31733
31785
|
setSaving(false);
|
|
31734
31786
|
return;
|
|
31735
31787
|
}
|
|
31736
|
-
if (activationMode === "password") {
|
|
31737
|
-
if (!ownerPassword) {
|
|
31738
|
-
setErrors([
|
|
31739
|
-
"Enter a password for the owner account"
|
|
31740
|
-
]);
|
|
31741
|
-
setSaving(false);
|
|
31742
|
-
return;
|
|
31743
|
-
}
|
|
31744
|
-
if (ownerPassword !== ownerPasswordConfirm) {
|
|
31745
|
-
setErrors([
|
|
31746
|
-
"Passwords do not match"
|
|
31747
|
-
]);
|
|
31748
|
-
setSaving(false);
|
|
31749
|
-
return;
|
|
31750
|
-
}
|
|
31751
|
-
if (ownerPassword.length < 6) {
|
|
31752
|
-
setErrors([
|
|
31753
|
-
"Password must be at least 6 characters"
|
|
31754
|
-
]);
|
|
31755
|
-
setSaving(false);
|
|
31756
|
-
return;
|
|
31757
|
-
}
|
|
31758
|
-
}
|
|
31759
31788
|
try {
|
|
31760
31789
|
const res = await fetch("/api/admin/vendors/onboard", {
|
|
31761
31790
|
method: "POST",
|
|
@@ -31763,18 +31792,15 @@ function VendorEditPage({ vendorId }) {
|
|
|
31763
31792
|
"Content-Type": "application/json"
|
|
31764
31793
|
},
|
|
31765
31794
|
body: JSON.stringify({
|
|
31766
|
-
activation:
|
|
31767
|
-
sendOwnerEmail,
|
|
31795
|
+
activation: "invite",
|
|
31796
|
+
sendOwnerEmail: false,
|
|
31768
31797
|
termsAccepted: true,
|
|
31769
31798
|
vendor: vendorPayload(),
|
|
31770
31799
|
user: {
|
|
31771
31800
|
name: ownerName.trim(),
|
|
31772
31801
|
email: ownerEmail.trim(),
|
|
31773
31802
|
phone: ownerPhone.trim() || void 0,
|
|
31774
|
-
designation: ownerDesignation.trim() || void 0
|
|
31775
|
-
...activationMode === "password" ? {
|
|
31776
|
-
password: ownerPassword
|
|
31777
|
-
} : {}
|
|
31803
|
+
designation: ownerDesignation.trim() || void 0
|
|
31778
31804
|
}
|
|
31779
31805
|
})
|
|
31780
31806
|
});
|
|
@@ -31785,22 +31811,19 @@ function VendorEditPage({ vendorId }) {
|
|
|
31785
31811
|
]);
|
|
31786
31812
|
return;
|
|
31787
31813
|
}
|
|
31788
|
-
const
|
|
31789
|
-
const inviteLink = typeof data.inviteLink === "string" ? data.inviteLink.trim() : "";
|
|
31790
|
-
if (inviteLink) {
|
|
31791
|
-
|
|
31792
|
-
|
|
31793
|
-
|
|
31794
|
-
} catch {
|
|
31795
|
-
sonner.toast.success(message);
|
|
31796
|
-
sonner.toast.message("Invite link", {
|
|
31797
|
-
description: inviteLink
|
|
31798
|
-
});
|
|
31799
|
-
}
|
|
31800
|
-
} else {
|
|
31801
|
-
sonner.toast.success(message);
|
|
31814
|
+
const vendorIdNum = Number(data.vendor?.id);
|
|
31815
|
+
const inviteLink = typeof data.inviteLink === "string" && data.inviteLink.trim() ? data.inviteLink.trim() : "";
|
|
31816
|
+
if (!Number.isFinite(vendorIdNum) || vendorIdNum <= 0 || !inviteLink) {
|
|
31817
|
+
sonner.toast.success(data.message || "Vendor created");
|
|
31818
|
+
router.push(listReturnUrl);
|
|
31819
|
+
return;
|
|
31802
31820
|
}
|
|
31803
|
-
|
|
31821
|
+
sonner.toast.success(data.message || "Vendor created");
|
|
31822
|
+
setLinkCopied(false);
|
|
31823
|
+
setInviteDialog({
|
|
31824
|
+
vendorId: vendorIdNum,
|
|
31825
|
+
inviteLink
|
|
31826
|
+
});
|
|
31804
31827
|
} catch {
|
|
31805
31828
|
setErrors([
|
|
31806
31829
|
"Request failed"
|
|
@@ -31871,7 +31894,6 @@ function VendorEditPage({ vendorId }) {
|
|
|
31871
31894
|
setSaving(false);
|
|
31872
31895
|
}
|
|
31873
31896
|
}, "handleSave");
|
|
31874
|
-
const createSubmitLabel = activationMode === "password" ? sendOwnerEmail ? "Create vendor & send welcome email" : "Create vendor & set password" : sendOwnerEmail ? "Create vendor & send invite" : "Create vendor & copy invite link";
|
|
31875
31897
|
if (loading) {
|
|
31876
31898
|
return /* @__PURE__ */ React26__namespace.default.createElement("div", {
|
|
31877
31899
|
className: "flex items-center justify-center py-12"
|
|
@@ -31883,11 +31905,11 @@ function VendorEditPage({ vendorId }) {
|
|
|
31883
31905
|
className: "rounded-lg bg-white shadow-md min-h-[420px]"
|
|
31884
31906
|
}, /* @__PURE__ */ React26__namespace.default.createElement(DetailPageHeader, {
|
|
31885
31907
|
title: create ? "Add vendor" : "Edit vendor",
|
|
31886
|
-
subtitle: create ? "Register a vendor store and create the owner
|
|
31908
|
+
subtitle: create ? "Register a vendor store and create the owner invite" : "Update store and registration details",
|
|
31887
31909
|
closeHref: listReturnUrl,
|
|
31888
31910
|
menuItems: create ? [
|
|
31889
31911
|
{
|
|
31890
|
-
label: saving ? "Creating\u2026" :
|
|
31912
|
+
label: saving ? "Creating\u2026" : "Create vendor",
|
|
31891
31913
|
icon: LucideIcons.Save,
|
|
31892
31914
|
onClick: handleCreate
|
|
31893
31915
|
}
|
|
@@ -32155,64 +32177,42 @@ function VendorEditPage({ vendorId }) {
|
|
|
32155
32177
|
className: "text-xs font-semibold text-gray-400 uppercase tracking-wider mb-2"
|
|
32156
32178
|
}, "Owner access"), /* @__PURE__ */ React26__namespace.default.createElement("div", {
|
|
32157
32179
|
className: sectionCls6
|
|
32158
|
-
}, /* @__PURE__ */ React26__namespace.default.createElement(
|
|
32159
|
-
|
|
32160
|
-
|
|
32161
|
-
className: "gap-3"
|
|
32162
|
-
}, /* @__PURE__ */ React26__namespace.default.createElement("div", {
|
|
32163
|
-
className: "flex items-start gap-2"
|
|
32164
|
-
}, /* @__PURE__ */ React26__namespace.default.createElement(RadioGroupItem, {
|
|
32165
|
-
value: "invite",
|
|
32166
|
-
id: "activation-invite",
|
|
32167
|
-
className: "mt-0.5"
|
|
32168
|
-
}), /* @__PURE__ */ React26__namespace.default.createElement(Label3, {
|
|
32169
|
-
htmlFor: "activation-invite",
|
|
32170
|
-
className: "font-normal cursor-pointer text-sm"
|
|
32171
|
-
}, "Send invite link")), /* @__PURE__ */ React26__namespace.default.createElement("div", {
|
|
32172
|
-
className: "flex items-start gap-2"
|
|
32173
|
-
}, /* @__PURE__ */ React26__namespace.default.createElement(RadioGroupItem, {
|
|
32174
|
-
value: "password",
|
|
32175
|
-
id: "activation-password",
|
|
32176
|
-
className: "mt-0.5"
|
|
32177
|
-
}), /* @__PURE__ */ React26__namespace.default.createElement(Label3, {
|
|
32178
|
-
htmlFor: "activation-password",
|
|
32179
|
-
className: "font-normal cursor-pointer text-sm"
|
|
32180
|
-
}, "Set password now"))), /* @__PURE__ */ React26__namespace.default.createElement("div", {
|
|
32181
|
-
className: "flex items-center gap-2 pt-1"
|
|
32182
|
-
}, /* @__PURE__ */ React26__namespace.default.createElement(Checkbox, {
|
|
32183
|
-
id: "sendOwnerEmail",
|
|
32184
|
-
checked: sendOwnerEmail,
|
|
32185
|
-
onCheckedChange: /* @__PURE__ */ __name((checked) => setSendOwnerEmail(checked === true), "onCheckedChange")
|
|
32186
|
-
}), /* @__PURE__ */ React26__namespace.default.createElement(Label3, {
|
|
32187
|
-
htmlFor: "sendOwnerEmail",
|
|
32188
|
-
className: "font-normal cursor-pointer text-sm"
|
|
32189
|
-
}, activationMode === "invite" ? "Send invite email" : "Send welcome email")), activationMode === "password" && /* @__PURE__ */ React26__namespace.default.createElement("div", {
|
|
32190
|
-
className: "space-y-3 pt-1"
|
|
32191
|
-
}, /* @__PURE__ */ React26__namespace.default.createElement("div", null, /* @__PURE__ */ React26__namespace.default.createElement(FieldLabel, {
|
|
32192
|
-
htmlFor: "ownerPassword",
|
|
32193
|
-
required: true
|
|
32194
|
-
}, "Password"), /* @__PURE__ */ React26__namespace.default.createElement(Input, {
|
|
32195
|
-
id: "ownerPassword",
|
|
32196
|
-
type: "password",
|
|
32197
|
-
value: ownerPassword,
|
|
32198
|
-
onChange: /* @__PURE__ */ __name((e) => setOwnerPassword(e.target.value), "onChange"),
|
|
32199
|
-
className: `mt-1 ${fieldClass}`
|
|
32200
|
-
})), /* @__PURE__ */ React26__namespace.default.createElement("div", null, /* @__PURE__ */ React26__namespace.default.createElement(FieldLabel, {
|
|
32201
|
-
htmlFor: "ownerPasswordConfirm",
|
|
32202
|
-
required: true
|
|
32203
|
-
}, "Confirm password"), /* @__PURE__ */ React26__namespace.default.createElement(Input, {
|
|
32204
|
-
id: "ownerPasswordConfirm",
|
|
32205
|
-
type: "password",
|
|
32206
|
-
value: ownerPasswordConfirm,
|
|
32207
|
-
onChange: /* @__PURE__ */ __name((e) => setOwnerPasswordConfirm(e.target.value), "onChange"),
|
|
32208
|
-
className: `mt-1 ${fieldClass}`
|
|
32209
|
-
}))), /* @__PURE__ */ React26__namespace.default.createElement(Button, {
|
|
32180
|
+
}, /* @__PURE__ */ React26__namespace.default.createElement("p", {
|
|
32181
|
+
className: "text-sm text-gray-600"
|
|
32182
|
+
}, "Creates the vendor and an invite for the owner. After create, you can send the invite email or copy the invite link."), /* @__PURE__ */ React26__namespace.default.createElement(Button, {
|
|
32210
32183
|
type: "button",
|
|
32211
32184
|
disabled: saving,
|
|
32212
32185
|
onClick: handleCreate,
|
|
32213
32186
|
className: "w-full"
|
|
32214
|
-
}, saving ? "Creating\u2026" :
|
|
32215
|
-
})
|
|
32187
|
+
}, saving ? "Creating\u2026" : "Create vendor"))) : void 0)
|
|
32188
|
+
}), /* @__PURE__ */ React26__namespace.default.createElement(Dialog, {
|
|
32189
|
+
open: inviteDialog != null,
|
|
32190
|
+
onOpenChange: /* @__PURE__ */ __name((open) => {
|
|
32191
|
+
if (!open) closeInviteDialog();
|
|
32192
|
+
}, "onOpenChange")
|
|
32193
|
+
}, /* @__PURE__ */ React26__namespace.default.createElement(DialogContent, {
|
|
32194
|
+
className: "max-w-md"
|
|
32195
|
+
}, /* @__PURE__ */ React26__namespace.default.createElement(DialogHeader, null, /* @__PURE__ */ React26__namespace.default.createElement(DialogTitle, null, "Vendor created"), /* @__PURE__ */ React26__namespace.default.createElement(DialogDescription, null, "Send an invite email to the owner, or copy the invite link to share another way. The link is not shown here.")), /* @__PURE__ */ React26__namespace.default.createElement("div", {
|
|
32196
|
+
className: "flex flex-col gap-2 py-2"
|
|
32197
|
+
}, /* @__PURE__ */ React26__namespace.default.createElement(Button, {
|
|
32198
|
+
type: "button",
|
|
32199
|
+
disabled: sendingInviteEmail,
|
|
32200
|
+
onClick: /* @__PURE__ */ __name(() => void sendInviteEmail(), "onClick")
|
|
32201
|
+
}, /* @__PURE__ */ React26__namespace.default.createElement(LucideIcons.Mail, {
|
|
32202
|
+
className: "h-4 w-4 mr-2"
|
|
32203
|
+
}), sendingInviteEmail ? "Sending\u2026" : "Send email"), /* @__PURE__ */ React26__namespace.default.createElement(Button, {
|
|
32204
|
+
type: "button",
|
|
32205
|
+
variant: "outline",
|
|
32206
|
+
onClick: /* @__PURE__ */ __name(() => void copyInviteLink(), "onClick")
|
|
32207
|
+
}, linkCopied ? /* @__PURE__ */ React26__namespace.default.createElement(LucideIcons.Check, {
|
|
32208
|
+
className: "h-4 w-4 mr-2"
|
|
32209
|
+
}) : /* @__PURE__ */ React26__namespace.default.createElement(LucideIcons.Copy, {
|
|
32210
|
+
className: "h-4 w-4 mr-2"
|
|
32211
|
+
}), linkCopied ? "Copied" : "Copy invite link")), /* @__PURE__ */ React26__namespace.default.createElement(DialogFooter, null, /* @__PURE__ */ React26__namespace.default.createElement(Button, {
|
|
32212
|
+
type: "button",
|
|
32213
|
+
variant: "secondary",
|
|
32214
|
+
onClick: closeInviteDialog
|
|
32215
|
+
}, "Done")))));
|
|
32216
32216
|
}
|
|
32217
32217
|
var isCreate6, fieldClass, selectClass, sectionCls6;
|
|
32218
32218
|
var init_VendorEditPage = __esm({
|
|
@@ -32228,7 +32228,7 @@ var init_VendorEditPage = __esm({
|
|
|
32228
32228
|
init_label();
|
|
32229
32229
|
init_textarea();
|
|
32230
32230
|
init_checkbox();
|
|
32231
|
-
|
|
32231
|
+
init_dialog();
|
|
32232
32232
|
init_vendor_profile();
|
|
32233
32233
|
init_vendor_list_config();
|
|
32234
32234
|
init_vendor_access_denied();
|
package/dist/admin.js
CHANGED
|
@@ -457,7 +457,7 @@ var init_admin_config_context = __esm({
|
|
|
457
457
|
var CMS_VERSION;
|
|
458
458
|
var init_cms_version = __esm({
|
|
459
459
|
"src/lib/cms-version.ts"() {
|
|
460
|
-
CMS_VERSION = "1.0.
|
|
460
|
+
CMS_VERSION = "1.0.41" ;
|
|
461
461
|
}
|
|
462
462
|
});
|
|
463
463
|
function useCatalogCategories(enabled = true) {
|
|
@@ -31533,11 +31533,10 @@ function VendorEditPage({ vendorId }) {
|
|
|
31533
31533
|
const [ownerPhone, setOwnerPhone] = useState("");
|
|
31534
31534
|
const [ownerDesignation, setOwnerDesignation] = useState("");
|
|
31535
31535
|
const [termsAccepted, setTermsAccepted] = useState(false);
|
|
31536
|
-
const [activationMode, setActivationMode] = useState("invite");
|
|
31537
|
-
const [sendOwnerEmail, setSendOwnerEmail] = useState(true);
|
|
31538
|
-
const [ownerPassword, setOwnerPassword] = useState("");
|
|
31539
|
-
const [ownerPasswordConfirm, setOwnerPasswordConfirm] = useState("");
|
|
31540
31536
|
const [reinviting, setReinviting] = useState(false);
|
|
31537
|
+
const [inviteDialog, setInviteDialog] = useState(null);
|
|
31538
|
+
const [sendingInviteEmail, setSendingInviteEmail] = useState(false);
|
|
31539
|
+
const [linkCopied, setLinkCopied] = useState(false);
|
|
31541
31540
|
const vendorPayload = /* @__PURE__ */ __name(() => ({
|
|
31542
31541
|
name: name.trim(),
|
|
31543
31542
|
legalName: legalName.trim() || null,
|
|
@@ -31673,6 +31672,59 @@ function VendorEditPage({ vendorId }) {
|
|
|
31673
31672
|
groupName: sessionUser?.groupName
|
|
31674
31673
|
});
|
|
31675
31674
|
}
|
|
31675
|
+
const copyInviteLink = /* @__PURE__ */ __name(async () => {
|
|
31676
|
+
const inviteLink = inviteDialog?.inviteLink;
|
|
31677
|
+
if (!inviteLink) {
|
|
31678
|
+
toast.error("Invite link is not available");
|
|
31679
|
+
return;
|
|
31680
|
+
}
|
|
31681
|
+
try {
|
|
31682
|
+
await navigator.clipboard.writeText(inviteLink);
|
|
31683
|
+
setLinkCopied(true);
|
|
31684
|
+
toast.success("Invite link copied");
|
|
31685
|
+
window.setTimeout(() => setLinkCopied(false), 2e3);
|
|
31686
|
+
} catch {
|
|
31687
|
+
toast.error("Could not copy invite link");
|
|
31688
|
+
}
|
|
31689
|
+
}, "copyInviteLink");
|
|
31690
|
+
const sendInviteEmail = /* @__PURE__ */ __name(async () => {
|
|
31691
|
+
if (!inviteDialog) return;
|
|
31692
|
+
setSendingInviteEmail(true);
|
|
31693
|
+
try {
|
|
31694
|
+
const res = await fetch(`/api/admin/vendors/${inviteDialog.vendorId}/resend-invite`, {
|
|
31695
|
+
method: "POST",
|
|
31696
|
+
headers: {
|
|
31697
|
+
"Content-Type": "application/json"
|
|
31698
|
+
},
|
|
31699
|
+
body: JSON.stringify({
|
|
31700
|
+
sendEmail: true,
|
|
31701
|
+
rotate: false
|
|
31702
|
+
})
|
|
31703
|
+
});
|
|
31704
|
+
const data = await res.json();
|
|
31705
|
+
if (!res.ok) {
|
|
31706
|
+
toast.error(data.error || data.message || "Failed to send invite email");
|
|
31707
|
+
return;
|
|
31708
|
+
}
|
|
31709
|
+
const nextLink = typeof data.inviteLink === "string" ? data.inviteLink.trim() : "";
|
|
31710
|
+
if (nextLink) {
|
|
31711
|
+
setInviteDialog((prev) => prev ? {
|
|
31712
|
+
...prev,
|
|
31713
|
+
inviteLink: nextLink
|
|
31714
|
+
} : prev);
|
|
31715
|
+
}
|
|
31716
|
+
toast.success(data.emailSent ? "Invite email sent" : data.message || "Invite email queued");
|
|
31717
|
+
} catch {
|
|
31718
|
+
toast.error("Failed to send invite email");
|
|
31719
|
+
} finally {
|
|
31720
|
+
setSendingInviteEmail(false);
|
|
31721
|
+
}
|
|
31722
|
+
}, "sendInviteEmail");
|
|
31723
|
+
const closeInviteDialog = /* @__PURE__ */ __name(() => {
|
|
31724
|
+
setInviteDialog(null);
|
|
31725
|
+
setLinkCopied(false);
|
|
31726
|
+
router.push(listReturnUrl);
|
|
31727
|
+
}, "closeInviteDialog");
|
|
31676
31728
|
const handleCreate = /* @__PURE__ */ __name(async () => {
|
|
31677
31729
|
setSaving(true);
|
|
31678
31730
|
setErrors([]);
|
|
@@ -31698,29 +31750,6 @@ function VendorEditPage({ vendorId }) {
|
|
|
31698
31750
|
setSaving(false);
|
|
31699
31751
|
return;
|
|
31700
31752
|
}
|
|
31701
|
-
if (activationMode === "password") {
|
|
31702
|
-
if (!ownerPassword) {
|
|
31703
|
-
setErrors([
|
|
31704
|
-
"Enter a password for the owner account"
|
|
31705
|
-
]);
|
|
31706
|
-
setSaving(false);
|
|
31707
|
-
return;
|
|
31708
|
-
}
|
|
31709
|
-
if (ownerPassword !== ownerPasswordConfirm) {
|
|
31710
|
-
setErrors([
|
|
31711
|
-
"Passwords do not match"
|
|
31712
|
-
]);
|
|
31713
|
-
setSaving(false);
|
|
31714
|
-
return;
|
|
31715
|
-
}
|
|
31716
|
-
if (ownerPassword.length < 6) {
|
|
31717
|
-
setErrors([
|
|
31718
|
-
"Password must be at least 6 characters"
|
|
31719
|
-
]);
|
|
31720
|
-
setSaving(false);
|
|
31721
|
-
return;
|
|
31722
|
-
}
|
|
31723
|
-
}
|
|
31724
31753
|
try {
|
|
31725
31754
|
const res = await fetch("/api/admin/vendors/onboard", {
|
|
31726
31755
|
method: "POST",
|
|
@@ -31728,18 +31757,15 @@ function VendorEditPage({ vendorId }) {
|
|
|
31728
31757
|
"Content-Type": "application/json"
|
|
31729
31758
|
},
|
|
31730
31759
|
body: JSON.stringify({
|
|
31731
|
-
activation:
|
|
31732
|
-
sendOwnerEmail,
|
|
31760
|
+
activation: "invite",
|
|
31761
|
+
sendOwnerEmail: false,
|
|
31733
31762
|
termsAccepted: true,
|
|
31734
31763
|
vendor: vendorPayload(),
|
|
31735
31764
|
user: {
|
|
31736
31765
|
name: ownerName.trim(),
|
|
31737
31766
|
email: ownerEmail.trim(),
|
|
31738
31767
|
phone: ownerPhone.trim() || void 0,
|
|
31739
|
-
designation: ownerDesignation.trim() || void 0
|
|
31740
|
-
...activationMode === "password" ? {
|
|
31741
|
-
password: ownerPassword
|
|
31742
|
-
} : {}
|
|
31768
|
+
designation: ownerDesignation.trim() || void 0
|
|
31743
31769
|
}
|
|
31744
31770
|
})
|
|
31745
31771
|
});
|
|
@@ -31750,22 +31776,19 @@ function VendorEditPage({ vendorId }) {
|
|
|
31750
31776
|
]);
|
|
31751
31777
|
return;
|
|
31752
31778
|
}
|
|
31753
|
-
const
|
|
31754
|
-
const inviteLink = typeof data.inviteLink === "string" ? data.inviteLink.trim() : "";
|
|
31755
|
-
if (inviteLink) {
|
|
31756
|
-
|
|
31757
|
-
|
|
31758
|
-
|
|
31759
|
-
} catch {
|
|
31760
|
-
toast.success(message);
|
|
31761
|
-
toast.message("Invite link", {
|
|
31762
|
-
description: inviteLink
|
|
31763
|
-
});
|
|
31764
|
-
}
|
|
31765
|
-
} else {
|
|
31766
|
-
toast.success(message);
|
|
31779
|
+
const vendorIdNum = Number(data.vendor?.id);
|
|
31780
|
+
const inviteLink = typeof data.inviteLink === "string" && data.inviteLink.trim() ? data.inviteLink.trim() : "";
|
|
31781
|
+
if (!Number.isFinite(vendorIdNum) || vendorIdNum <= 0 || !inviteLink) {
|
|
31782
|
+
toast.success(data.message || "Vendor created");
|
|
31783
|
+
router.push(listReturnUrl);
|
|
31784
|
+
return;
|
|
31767
31785
|
}
|
|
31768
|
-
|
|
31786
|
+
toast.success(data.message || "Vendor created");
|
|
31787
|
+
setLinkCopied(false);
|
|
31788
|
+
setInviteDialog({
|
|
31789
|
+
vendorId: vendorIdNum,
|
|
31790
|
+
inviteLink
|
|
31791
|
+
});
|
|
31769
31792
|
} catch {
|
|
31770
31793
|
setErrors([
|
|
31771
31794
|
"Request failed"
|
|
@@ -31836,7 +31859,6 @@ function VendorEditPage({ vendorId }) {
|
|
|
31836
31859
|
setSaving(false);
|
|
31837
31860
|
}
|
|
31838
31861
|
}, "handleSave");
|
|
31839
|
-
const createSubmitLabel = activationMode === "password" ? sendOwnerEmail ? "Create vendor & send welcome email" : "Create vendor & set password" : sendOwnerEmail ? "Create vendor & send invite" : "Create vendor & copy invite link";
|
|
31840
31862
|
if (loading) {
|
|
31841
31863
|
return /* @__PURE__ */ React26__default.createElement("div", {
|
|
31842
31864
|
className: "flex items-center justify-center py-12"
|
|
@@ -31848,11 +31870,11 @@ function VendorEditPage({ vendorId }) {
|
|
|
31848
31870
|
className: "rounded-lg bg-white shadow-md min-h-[420px]"
|
|
31849
31871
|
}, /* @__PURE__ */ React26__default.createElement(DetailPageHeader, {
|
|
31850
31872
|
title: create ? "Add vendor" : "Edit vendor",
|
|
31851
|
-
subtitle: create ? "Register a vendor store and create the owner
|
|
31873
|
+
subtitle: create ? "Register a vendor store and create the owner invite" : "Update store and registration details",
|
|
31852
31874
|
closeHref: listReturnUrl,
|
|
31853
31875
|
menuItems: create ? [
|
|
31854
31876
|
{
|
|
31855
|
-
label: saving ? "Creating\u2026" :
|
|
31877
|
+
label: saving ? "Creating\u2026" : "Create vendor",
|
|
31856
31878
|
icon: Save,
|
|
31857
31879
|
onClick: handleCreate
|
|
31858
31880
|
}
|
|
@@ -32120,64 +32142,42 @@ function VendorEditPage({ vendorId }) {
|
|
|
32120
32142
|
className: "text-xs font-semibold text-gray-400 uppercase tracking-wider mb-2"
|
|
32121
32143
|
}, "Owner access"), /* @__PURE__ */ React26__default.createElement("div", {
|
|
32122
32144
|
className: sectionCls6
|
|
32123
|
-
}, /* @__PURE__ */ React26__default.createElement(
|
|
32124
|
-
|
|
32125
|
-
|
|
32126
|
-
className: "gap-3"
|
|
32127
|
-
}, /* @__PURE__ */ React26__default.createElement("div", {
|
|
32128
|
-
className: "flex items-start gap-2"
|
|
32129
|
-
}, /* @__PURE__ */ React26__default.createElement(RadioGroupItem, {
|
|
32130
|
-
value: "invite",
|
|
32131
|
-
id: "activation-invite",
|
|
32132
|
-
className: "mt-0.5"
|
|
32133
|
-
}), /* @__PURE__ */ React26__default.createElement(Label3, {
|
|
32134
|
-
htmlFor: "activation-invite",
|
|
32135
|
-
className: "font-normal cursor-pointer text-sm"
|
|
32136
|
-
}, "Send invite link")), /* @__PURE__ */ React26__default.createElement("div", {
|
|
32137
|
-
className: "flex items-start gap-2"
|
|
32138
|
-
}, /* @__PURE__ */ React26__default.createElement(RadioGroupItem, {
|
|
32139
|
-
value: "password",
|
|
32140
|
-
id: "activation-password",
|
|
32141
|
-
className: "mt-0.5"
|
|
32142
|
-
}), /* @__PURE__ */ React26__default.createElement(Label3, {
|
|
32143
|
-
htmlFor: "activation-password",
|
|
32144
|
-
className: "font-normal cursor-pointer text-sm"
|
|
32145
|
-
}, "Set password now"))), /* @__PURE__ */ React26__default.createElement("div", {
|
|
32146
|
-
className: "flex items-center gap-2 pt-1"
|
|
32147
|
-
}, /* @__PURE__ */ React26__default.createElement(Checkbox, {
|
|
32148
|
-
id: "sendOwnerEmail",
|
|
32149
|
-
checked: sendOwnerEmail,
|
|
32150
|
-
onCheckedChange: /* @__PURE__ */ __name((checked) => setSendOwnerEmail(checked === true), "onCheckedChange")
|
|
32151
|
-
}), /* @__PURE__ */ React26__default.createElement(Label3, {
|
|
32152
|
-
htmlFor: "sendOwnerEmail",
|
|
32153
|
-
className: "font-normal cursor-pointer text-sm"
|
|
32154
|
-
}, activationMode === "invite" ? "Send invite email" : "Send welcome email")), activationMode === "password" && /* @__PURE__ */ React26__default.createElement("div", {
|
|
32155
|
-
className: "space-y-3 pt-1"
|
|
32156
|
-
}, /* @__PURE__ */ React26__default.createElement("div", null, /* @__PURE__ */ React26__default.createElement(FieldLabel, {
|
|
32157
|
-
htmlFor: "ownerPassword",
|
|
32158
|
-
required: true
|
|
32159
|
-
}, "Password"), /* @__PURE__ */ React26__default.createElement(Input, {
|
|
32160
|
-
id: "ownerPassword",
|
|
32161
|
-
type: "password",
|
|
32162
|
-
value: ownerPassword,
|
|
32163
|
-
onChange: /* @__PURE__ */ __name((e) => setOwnerPassword(e.target.value), "onChange"),
|
|
32164
|
-
className: `mt-1 ${fieldClass}`
|
|
32165
|
-
})), /* @__PURE__ */ React26__default.createElement("div", null, /* @__PURE__ */ React26__default.createElement(FieldLabel, {
|
|
32166
|
-
htmlFor: "ownerPasswordConfirm",
|
|
32167
|
-
required: true
|
|
32168
|
-
}, "Confirm password"), /* @__PURE__ */ React26__default.createElement(Input, {
|
|
32169
|
-
id: "ownerPasswordConfirm",
|
|
32170
|
-
type: "password",
|
|
32171
|
-
value: ownerPasswordConfirm,
|
|
32172
|
-
onChange: /* @__PURE__ */ __name((e) => setOwnerPasswordConfirm(e.target.value), "onChange"),
|
|
32173
|
-
className: `mt-1 ${fieldClass}`
|
|
32174
|
-
}))), /* @__PURE__ */ React26__default.createElement(Button, {
|
|
32145
|
+
}, /* @__PURE__ */ React26__default.createElement("p", {
|
|
32146
|
+
className: "text-sm text-gray-600"
|
|
32147
|
+
}, "Creates the vendor and an invite for the owner. After create, you can send the invite email or copy the invite link."), /* @__PURE__ */ React26__default.createElement(Button, {
|
|
32175
32148
|
type: "button",
|
|
32176
32149
|
disabled: saving,
|
|
32177
32150
|
onClick: handleCreate,
|
|
32178
32151
|
className: "w-full"
|
|
32179
|
-
}, saving ? "Creating\u2026" :
|
|
32180
|
-
})
|
|
32152
|
+
}, saving ? "Creating\u2026" : "Create vendor"))) : void 0)
|
|
32153
|
+
}), /* @__PURE__ */ React26__default.createElement(Dialog, {
|
|
32154
|
+
open: inviteDialog != null,
|
|
32155
|
+
onOpenChange: /* @__PURE__ */ __name((open) => {
|
|
32156
|
+
if (!open) closeInviteDialog();
|
|
32157
|
+
}, "onOpenChange")
|
|
32158
|
+
}, /* @__PURE__ */ React26__default.createElement(DialogContent, {
|
|
32159
|
+
className: "max-w-md"
|
|
32160
|
+
}, /* @__PURE__ */ React26__default.createElement(DialogHeader, null, /* @__PURE__ */ React26__default.createElement(DialogTitle, null, "Vendor created"), /* @__PURE__ */ React26__default.createElement(DialogDescription, null, "Send an invite email to the owner, or copy the invite link to share another way. The link is not shown here.")), /* @__PURE__ */ React26__default.createElement("div", {
|
|
32161
|
+
className: "flex flex-col gap-2 py-2"
|
|
32162
|
+
}, /* @__PURE__ */ React26__default.createElement(Button, {
|
|
32163
|
+
type: "button",
|
|
32164
|
+
disabled: sendingInviteEmail,
|
|
32165
|
+
onClick: /* @__PURE__ */ __name(() => void sendInviteEmail(), "onClick")
|
|
32166
|
+
}, /* @__PURE__ */ React26__default.createElement(Mail, {
|
|
32167
|
+
className: "h-4 w-4 mr-2"
|
|
32168
|
+
}), sendingInviteEmail ? "Sending\u2026" : "Send email"), /* @__PURE__ */ React26__default.createElement(Button, {
|
|
32169
|
+
type: "button",
|
|
32170
|
+
variant: "outline",
|
|
32171
|
+
onClick: /* @__PURE__ */ __name(() => void copyInviteLink(), "onClick")
|
|
32172
|
+
}, linkCopied ? /* @__PURE__ */ React26__default.createElement(Check, {
|
|
32173
|
+
className: "h-4 w-4 mr-2"
|
|
32174
|
+
}) : /* @__PURE__ */ React26__default.createElement(Copy, {
|
|
32175
|
+
className: "h-4 w-4 mr-2"
|
|
32176
|
+
}), linkCopied ? "Copied" : "Copy invite link")), /* @__PURE__ */ React26__default.createElement(DialogFooter, null, /* @__PURE__ */ React26__default.createElement(Button, {
|
|
32177
|
+
type: "button",
|
|
32178
|
+
variant: "secondary",
|
|
32179
|
+
onClick: closeInviteDialog
|
|
32180
|
+
}, "Done")))));
|
|
32181
32181
|
}
|
|
32182
32182
|
var isCreate6, fieldClass, selectClass, sectionCls6;
|
|
32183
32183
|
var init_VendorEditPage = __esm({
|
|
@@ -32193,7 +32193,7 @@ var init_VendorEditPage = __esm({
|
|
|
32193
32193
|
init_label();
|
|
32194
32194
|
init_textarea();
|
|
32195
32195
|
init_checkbox();
|
|
32196
|
-
|
|
32196
|
+
init_dialog();
|
|
32197
32197
|
init_vendor_profile();
|
|
32198
32198
|
init_vendor_list_config();
|
|
32199
32199
|
init_vendor_access_denied();
|