bitsnap-react 1.3.4 → 1.3.6
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/index.js +73 -36
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +73 -36
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -4317,10 +4317,24 @@ function reducer(state, action) {
|
|
|
4317
4317
|
return state;
|
|
4318
4318
|
}
|
|
4319
4319
|
}
|
|
4320
|
-
function NotificationsComponentPublic(
|
|
4321
|
-
|
|
4320
|
+
function NotificationsComponentPublic({
|
|
4321
|
+
slug: slugProp,
|
|
4322
|
+
userID,
|
|
4323
|
+
productID: _productID,
|
|
4324
|
+
projectName,
|
|
4325
|
+
projectLogo,
|
|
4326
|
+
projectLogoDark,
|
|
4327
|
+
groups,
|
|
4328
|
+
isManaging = false,
|
|
4329
|
+
texts,
|
|
4330
|
+
showQRCode = false,
|
|
4331
|
+
showPhoneInput = false,
|
|
4332
|
+
hiddenGroupIds = [],
|
|
4333
|
+
className
|
|
4334
|
+
}) {
|
|
4335
|
+
var _a, _b, _c;
|
|
4322
4336
|
const [parent] = (0, import_react20.useAutoAnimate)();
|
|
4323
|
-
let slug = (
|
|
4337
|
+
let slug = (_a = slugProp != null ? slugProp : getProjectID()) != null ? _a : typeof window !== "undefined" ? window.location.hostname : "";
|
|
4324
4338
|
const { mutateAsync: updateUserGroups2, isPending: isUpdating } = useMutation3(
|
|
4325
4339
|
rpcProvider.notifications.updateUserGroups
|
|
4326
4340
|
);
|
|
@@ -4349,9 +4363,9 @@ function NotificationsComponentPublic(props) {
|
|
|
4349
4363
|
isLoading: isGroupsDownloading,
|
|
4350
4364
|
isUserGroupsUpdated: false,
|
|
4351
4365
|
wasChanged: false,
|
|
4352
|
-
groupsProvided:
|
|
4366
|
+
groupsProvided: groups,
|
|
4353
4367
|
groups: [],
|
|
4354
|
-
showSettings: userInfo != null &&
|
|
4368
|
+
showSettings: userInfo != null && isManaging == true,
|
|
4355
4369
|
isLoggedIn: userInfo != null,
|
|
4356
4370
|
userID: void 0
|
|
4357
4371
|
});
|
|
@@ -4364,10 +4378,10 @@ function NotificationsComponentPublic(props) {
|
|
|
4364
4378
|
value: (userInfo == null ? void 0 : userInfo.accessToken) != null
|
|
4365
4379
|
});
|
|
4366
4380
|
dispatch({ type: "SET_USER_ID", value: userInfo == null ? void 0 : userInfo.userID });
|
|
4367
|
-
if ((userInfo == null ? void 0 : userInfo.accessToken) != null &&
|
|
4381
|
+
if ((userInfo == null ? void 0 : userInfo.accessToken) != null && isManaging == true) {
|
|
4368
4382
|
dispatch({ type: "SHOW_SETTINGS" });
|
|
4369
4383
|
}
|
|
4370
|
-
}, [userInfo,
|
|
4384
|
+
}, [userInfo, isManaging]);
|
|
4371
4385
|
(0, import_react19.useEffect)(() => {
|
|
4372
4386
|
if (groupsDownloaded == null) {
|
|
4373
4387
|
return;
|
|
@@ -4395,11 +4409,10 @@ function NotificationsComponentPublic(props) {
|
|
|
4395
4409
|
};
|
|
4396
4410
|
});
|
|
4397
4411
|
dispatch({ type: "SET_GROUPS", value: newGroups });
|
|
4398
|
-
}, [groupsDownloaded, isGroupsDownloading,
|
|
4412
|
+
}, [groupsDownloaded, isGroupsDownloading, groups]);
|
|
4399
4413
|
const timeoutRef = (0, import_react19.useRef)(null);
|
|
4400
4414
|
(0, import_react19.useEffect)(() => {
|
|
4401
|
-
|
|
4402
|
-
let preparedGroups = (_a2 = props.groups) == null ? void 0 : _a2.map((el) => {
|
|
4415
|
+
let preparedGroups = groups == null ? void 0 : groups.map((el) => {
|
|
4403
4416
|
if (el.id.startsWith("group_")) {
|
|
4404
4417
|
return el;
|
|
4405
4418
|
}
|
|
@@ -4407,20 +4420,13 @@ function NotificationsComponentPublic(props) {
|
|
|
4407
4420
|
return el;
|
|
4408
4421
|
});
|
|
4409
4422
|
dispatch({ type: "SET_PUBLIC_GROUPS", value: preparedGroups });
|
|
4410
|
-
}, [
|
|
4411
|
-
const {
|
|
4412
|
-
texts,
|
|
4413
|
-
showQRCode = false,
|
|
4414
|
-
showPhoneInput = false,
|
|
4415
|
-
hiddenGroupIds = [],
|
|
4416
|
-
className
|
|
4417
|
-
} = props;
|
|
4423
|
+
}, [groups]);
|
|
4418
4424
|
const mergedTexts = { ...DEFAULT_TEXTS, ...texts };
|
|
4419
4425
|
async function updateGroups() {
|
|
4420
4426
|
await updateUserGroups2({
|
|
4421
4427
|
accessToken: userInfo == null ? void 0 : userInfo.accessToken,
|
|
4422
4428
|
slug,
|
|
4423
|
-
userId:
|
|
4429
|
+
userId: userID,
|
|
4424
4430
|
groupIds: state.groups.filter((el) => el.isOn === true).map((el) => el.id)
|
|
4425
4431
|
});
|
|
4426
4432
|
dispatch({ type: "RESET_UPDATE_STATE" });
|
|
@@ -4451,18 +4457,18 @@ function NotificationsComponentPublic(props) {
|
|
|
4451
4457
|
dispatch({ type: "SET_IS_LOGGED_IN", value: false });
|
|
4452
4458
|
dispatch({ type: "HIDE_SETTINGS" });
|
|
4453
4459
|
}
|
|
4454
|
-
async function handleLoginSuccess(
|
|
4460
|
+
async function handleLoginSuccess(userID2, accessToken) {
|
|
4455
4461
|
if (typeof window !== "undefined") {
|
|
4456
4462
|
localStorage.setItem("notifications_accessToken", accessToken);
|
|
4457
|
-
if (
|
|
4458
|
-
localStorage.setItem("notifications_userID",
|
|
4463
|
+
if (userID2 != null) {
|
|
4464
|
+
localStorage.setItem("notifications_userID", userID2);
|
|
4459
4465
|
}
|
|
4460
4466
|
}
|
|
4461
|
-
dispatch({ type: "SET_USER_ID", value:
|
|
4467
|
+
dispatch({ type: "SET_USER_ID", value: userID2 });
|
|
4462
4468
|
try {
|
|
4463
4469
|
await refetchAccessToken();
|
|
4464
4470
|
refetchGroups().then().catch().finally(() => {
|
|
4465
|
-
if (
|
|
4471
|
+
if (isManaging == true) {
|
|
4466
4472
|
dispatch({ type: "SHOW_SETTINGS" });
|
|
4467
4473
|
}
|
|
4468
4474
|
});
|
|
@@ -4477,10 +4483,10 @@ function NotificationsComponentPublic(props) {
|
|
|
4477
4483
|
}
|
|
4478
4484
|
};
|
|
4479
4485
|
}, []);
|
|
4480
|
-
const isManagingEnabled =
|
|
4486
|
+
const isManagingEnabled = isManaging == true && state.userID != null && (userInfo == null ? void 0 : userInfo.accessToken) != null;
|
|
4481
4487
|
return /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("main", { className: cn("bitsnap-checkout relative", className == null ? void 0 : className.container), children: [
|
|
4482
4488
|
mergedTexts.title != null && /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("h1", { className: "text-2xl font-semibold text-black md:text-3xl lg:text-4xl xl:text-5xl dark:text-neutral-100", children: mergedTexts.title }),
|
|
4483
|
-
!state.showSettings &&
|
|
4489
|
+
!state.showSettings && isManaging && /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
|
|
4484
4490
|
Button,
|
|
4485
4491
|
{
|
|
4486
4492
|
onClick: handleSettingsClick,
|
|
@@ -4513,9 +4519,9 @@ function NotificationsComponentPublic(props) {
|
|
|
4513
4519
|
/* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
|
|
4514
4520
|
NotificationHeader,
|
|
4515
4521
|
{
|
|
4516
|
-
projectName
|
|
4517
|
-
projectLogo
|
|
4518
|
-
projectLogoDark
|
|
4522
|
+
projectName,
|
|
4523
|
+
projectLogo,
|
|
4524
|
+
projectLogoDark,
|
|
4519
4525
|
description: mergedTexts.managingDescription,
|
|
4520
4526
|
className,
|
|
4521
4527
|
onLogout: handleLogout
|
|
@@ -4527,7 +4533,7 @@ function NotificationsComponentPublic(props) {
|
|
|
4527
4533
|
{
|
|
4528
4534
|
groups: state.groups,
|
|
4529
4535
|
hiddenGroupIds,
|
|
4530
|
-
isManaging
|
|
4536
|
+
isManaging,
|
|
4531
4537
|
onToggle: toggleGroup,
|
|
4532
4538
|
onCheckAll: checkAllGroups,
|
|
4533
4539
|
onUpdate: updateGroups,
|
|
@@ -4542,9 +4548,9 @@ function NotificationsComponentPublic(props) {
|
|
|
4542
4548
|
isManagingEnabled && /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
|
|
4543
4549
|
ManageMyData,
|
|
4544
4550
|
{
|
|
4545
|
-
accessToken: (
|
|
4551
|
+
accessToken: (_b = userInfo.accessToken) != null ? _b : "",
|
|
4546
4552
|
slug,
|
|
4547
|
-
userID: (
|
|
4553
|
+
userID: (_c = state.userID) != null ? _c : "",
|
|
4548
4554
|
className,
|
|
4549
4555
|
texts: mergedTexts
|
|
4550
4556
|
}
|
|
@@ -4573,9 +4579,9 @@ function NotificationsComponentPublic(props) {
|
|
|
4573
4579
|
onCheckAll: () => {
|
|
4574
4580
|
dispatch({ type: "CHECK_ALL_GROUPS" });
|
|
4575
4581
|
},
|
|
4576
|
-
onSuccess: (userAlreadyExists,
|
|
4582
|
+
onSuccess: (userAlreadyExists, userID2, accessToken) => {
|
|
4577
4583
|
if (accessToken != null) {
|
|
4578
|
-
handleLoginSuccess(
|
|
4584
|
+
handleLoginSuccess(userID2, accessToken);
|
|
4579
4585
|
}
|
|
4580
4586
|
if (userAlreadyExists) {
|
|
4581
4587
|
dispatch({ type: "SHOW_SETTINGS" });
|
|
@@ -4605,8 +4611,39 @@ function NotificationsComponentPublic(props) {
|
|
|
4605
4611
|
)
|
|
4606
4612
|
] });
|
|
4607
4613
|
}
|
|
4608
|
-
function Wrapper3(
|
|
4609
|
-
|
|
4614
|
+
function Wrapper3({
|
|
4615
|
+
slug,
|
|
4616
|
+
userID,
|
|
4617
|
+
productID,
|
|
4618
|
+
projectName,
|
|
4619
|
+
projectLogo,
|
|
4620
|
+
projectLogoDark,
|
|
4621
|
+
groups,
|
|
4622
|
+
isManaging,
|
|
4623
|
+
texts,
|
|
4624
|
+
showQRCode,
|
|
4625
|
+
showPhoneInput,
|
|
4626
|
+
hiddenGroupIds,
|
|
4627
|
+
className
|
|
4628
|
+
}) {
|
|
4629
|
+
return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(RpcProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
|
|
4630
|
+
NotificationsComponentPublic,
|
|
4631
|
+
{
|
|
4632
|
+
slug,
|
|
4633
|
+
userID,
|
|
4634
|
+
productID,
|
|
4635
|
+
projectName,
|
|
4636
|
+
projectLogo,
|
|
4637
|
+
projectLogoDark,
|
|
4638
|
+
groups,
|
|
4639
|
+
isManaging,
|
|
4640
|
+
texts,
|
|
4641
|
+
showQRCode,
|
|
4642
|
+
showPhoneInput,
|
|
4643
|
+
hiddenGroupIds,
|
|
4644
|
+
className
|
|
4645
|
+
}
|
|
4646
|
+
) });
|
|
4610
4647
|
}
|
|
4611
4648
|
var NotificationsComponentPublic_default = Wrapper3;
|
|
4612
4649
|
// Annotate the CommonJS export names for ESM import in node:
|