bitsnap-react 1.3.5 → 1.3.7
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.mjs +73 -36
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/dist/errors.js +0 -2
- package/dist/errors.js.map +0 -1
- package/dist/index.js +0 -4626
- package/dist/index.js.map +0 -1
- package/dist/internal.js +0 -2
- package/dist/internal.js.map +0 -1
- package/dist/models.js +0 -106
- package/dist/models.js.map +0 -1
package/dist/index.mjs
CHANGED
|
@@ -4283,10 +4283,24 @@ function reducer(state, action) {
|
|
|
4283
4283
|
return state;
|
|
4284
4284
|
}
|
|
4285
4285
|
}
|
|
4286
|
-
function NotificationsComponentPublic(
|
|
4287
|
-
|
|
4286
|
+
function NotificationsComponentPublic({
|
|
4287
|
+
slug: slugProp,
|
|
4288
|
+
userID,
|
|
4289
|
+
productID: _productID,
|
|
4290
|
+
projectName,
|
|
4291
|
+
projectLogo,
|
|
4292
|
+
projectLogoDark,
|
|
4293
|
+
groups,
|
|
4294
|
+
isManaging = false,
|
|
4295
|
+
texts,
|
|
4296
|
+
showQRCode = false,
|
|
4297
|
+
showPhoneInput = false,
|
|
4298
|
+
hiddenGroupIds = [],
|
|
4299
|
+
className
|
|
4300
|
+
}) {
|
|
4301
|
+
var _a, _b, _c;
|
|
4288
4302
|
const [parent] = useAutoAnimate7();
|
|
4289
|
-
let slug = (
|
|
4303
|
+
let slug = (_a = slugProp != null ? slugProp : getProjectID()) != null ? _a : typeof window !== "undefined" ? window.location.hostname : "";
|
|
4290
4304
|
const { mutateAsync: updateUserGroups2, isPending: isUpdating } = useMutation3(
|
|
4291
4305
|
rpcProvider.notifications.updateUserGroups
|
|
4292
4306
|
);
|
|
@@ -4315,9 +4329,9 @@ function NotificationsComponentPublic(props) {
|
|
|
4315
4329
|
isLoading: isGroupsDownloading,
|
|
4316
4330
|
isUserGroupsUpdated: false,
|
|
4317
4331
|
wasChanged: false,
|
|
4318
|
-
groupsProvided:
|
|
4332
|
+
groupsProvided: groups,
|
|
4319
4333
|
groups: [],
|
|
4320
|
-
showSettings: userInfo != null &&
|
|
4334
|
+
showSettings: userInfo != null && isManaging == true,
|
|
4321
4335
|
isLoggedIn: userInfo != null,
|
|
4322
4336
|
userID: void 0
|
|
4323
4337
|
});
|
|
@@ -4330,10 +4344,10 @@ function NotificationsComponentPublic(props) {
|
|
|
4330
4344
|
value: (userInfo == null ? void 0 : userInfo.accessToken) != null
|
|
4331
4345
|
});
|
|
4332
4346
|
dispatch({ type: "SET_USER_ID", value: userInfo == null ? void 0 : userInfo.userID });
|
|
4333
|
-
if ((userInfo == null ? void 0 : userInfo.accessToken) != null &&
|
|
4347
|
+
if ((userInfo == null ? void 0 : userInfo.accessToken) != null && isManaging == true) {
|
|
4334
4348
|
dispatch({ type: "SHOW_SETTINGS" });
|
|
4335
4349
|
}
|
|
4336
|
-
}, [userInfo,
|
|
4350
|
+
}, [userInfo, isManaging]);
|
|
4337
4351
|
useEffect7(() => {
|
|
4338
4352
|
if (groupsDownloaded == null) {
|
|
4339
4353
|
return;
|
|
@@ -4361,11 +4375,10 @@ function NotificationsComponentPublic(props) {
|
|
|
4361
4375
|
};
|
|
4362
4376
|
});
|
|
4363
4377
|
dispatch({ type: "SET_GROUPS", value: newGroups });
|
|
4364
|
-
}, [groupsDownloaded, isGroupsDownloading,
|
|
4378
|
+
}, [groupsDownloaded, isGroupsDownloading, groups]);
|
|
4365
4379
|
const timeoutRef = useRef2(null);
|
|
4366
4380
|
useEffect7(() => {
|
|
4367
|
-
|
|
4368
|
-
let preparedGroups = (_a2 = props.groups) == null ? void 0 : _a2.map((el) => {
|
|
4381
|
+
let preparedGroups = groups == null ? void 0 : groups.map((el) => {
|
|
4369
4382
|
if (el.id.startsWith("group_")) {
|
|
4370
4383
|
return el;
|
|
4371
4384
|
}
|
|
@@ -4373,20 +4386,13 @@ function NotificationsComponentPublic(props) {
|
|
|
4373
4386
|
return el;
|
|
4374
4387
|
});
|
|
4375
4388
|
dispatch({ type: "SET_PUBLIC_GROUPS", value: preparedGroups });
|
|
4376
|
-
}, [
|
|
4377
|
-
const {
|
|
4378
|
-
texts,
|
|
4379
|
-
showQRCode = false,
|
|
4380
|
-
showPhoneInput = false,
|
|
4381
|
-
hiddenGroupIds = [],
|
|
4382
|
-
className
|
|
4383
|
-
} = props;
|
|
4389
|
+
}, [groups]);
|
|
4384
4390
|
const mergedTexts = { ...DEFAULT_TEXTS, ...texts };
|
|
4385
4391
|
async function updateGroups() {
|
|
4386
4392
|
await updateUserGroups2({
|
|
4387
4393
|
accessToken: userInfo == null ? void 0 : userInfo.accessToken,
|
|
4388
4394
|
slug,
|
|
4389
|
-
userId:
|
|
4395
|
+
userId: userID,
|
|
4390
4396
|
groupIds: state.groups.filter((el) => el.isOn === true).map((el) => el.id)
|
|
4391
4397
|
});
|
|
4392
4398
|
dispatch({ type: "RESET_UPDATE_STATE" });
|
|
@@ -4417,18 +4423,18 @@ function NotificationsComponentPublic(props) {
|
|
|
4417
4423
|
dispatch({ type: "SET_IS_LOGGED_IN", value: false });
|
|
4418
4424
|
dispatch({ type: "HIDE_SETTINGS" });
|
|
4419
4425
|
}
|
|
4420
|
-
async function handleLoginSuccess(
|
|
4426
|
+
async function handleLoginSuccess(userID2, accessToken) {
|
|
4421
4427
|
if (typeof window !== "undefined") {
|
|
4422
4428
|
localStorage.setItem("notifications_accessToken", accessToken);
|
|
4423
|
-
if (
|
|
4424
|
-
localStorage.setItem("notifications_userID",
|
|
4429
|
+
if (userID2 != null) {
|
|
4430
|
+
localStorage.setItem("notifications_userID", userID2);
|
|
4425
4431
|
}
|
|
4426
4432
|
}
|
|
4427
|
-
dispatch({ type: "SET_USER_ID", value:
|
|
4433
|
+
dispatch({ type: "SET_USER_ID", value: userID2 });
|
|
4428
4434
|
try {
|
|
4429
4435
|
await refetchAccessToken();
|
|
4430
4436
|
refetchGroups().then().catch().finally(() => {
|
|
4431
|
-
if (
|
|
4437
|
+
if (isManaging == true) {
|
|
4432
4438
|
dispatch({ type: "SHOW_SETTINGS" });
|
|
4433
4439
|
}
|
|
4434
4440
|
});
|
|
@@ -4443,10 +4449,10 @@ function NotificationsComponentPublic(props) {
|
|
|
4443
4449
|
}
|
|
4444
4450
|
};
|
|
4445
4451
|
}, []);
|
|
4446
|
-
const isManagingEnabled =
|
|
4452
|
+
const isManagingEnabled = isManaging == true && state.userID != null && (userInfo == null ? void 0 : userInfo.accessToken) != null;
|
|
4447
4453
|
return /* @__PURE__ */ jsxs19("main", { className: cn("bitsnap-checkout relative", className == null ? void 0 : className.container), children: [
|
|
4448
4454
|
mergedTexts.title != null && /* @__PURE__ */ jsx31("h1", { className: "text-2xl font-semibold text-black md:text-3xl lg:text-4xl xl:text-5xl dark:text-neutral-100", children: mergedTexts.title }),
|
|
4449
|
-
!state.showSettings &&
|
|
4455
|
+
!state.showSettings && isManaging && /* @__PURE__ */ jsx31(
|
|
4450
4456
|
Button,
|
|
4451
4457
|
{
|
|
4452
4458
|
onClick: handleSettingsClick,
|
|
@@ -4479,9 +4485,9 @@ function NotificationsComponentPublic(props) {
|
|
|
4479
4485
|
/* @__PURE__ */ jsx31(
|
|
4480
4486
|
NotificationHeader,
|
|
4481
4487
|
{
|
|
4482
|
-
projectName
|
|
4483
|
-
projectLogo
|
|
4484
|
-
projectLogoDark
|
|
4488
|
+
projectName,
|
|
4489
|
+
projectLogo,
|
|
4490
|
+
projectLogoDark,
|
|
4485
4491
|
description: mergedTexts.managingDescription,
|
|
4486
4492
|
className,
|
|
4487
4493
|
onLogout: handleLogout
|
|
@@ -4493,7 +4499,7 @@ function NotificationsComponentPublic(props) {
|
|
|
4493
4499
|
{
|
|
4494
4500
|
groups: state.groups,
|
|
4495
4501
|
hiddenGroupIds,
|
|
4496
|
-
isManaging
|
|
4502
|
+
isManaging,
|
|
4497
4503
|
onToggle: toggleGroup,
|
|
4498
4504
|
onCheckAll: checkAllGroups,
|
|
4499
4505
|
onUpdate: updateGroups,
|
|
@@ -4508,9 +4514,9 @@ function NotificationsComponentPublic(props) {
|
|
|
4508
4514
|
isManagingEnabled && /* @__PURE__ */ jsx31(
|
|
4509
4515
|
ManageMyData,
|
|
4510
4516
|
{
|
|
4511
|
-
accessToken: (
|
|
4517
|
+
accessToken: (_b = userInfo.accessToken) != null ? _b : "",
|
|
4512
4518
|
slug,
|
|
4513
|
-
userID: (
|
|
4519
|
+
userID: (_c = state.userID) != null ? _c : "",
|
|
4514
4520
|
className,
|
|
4515
4521
|
texts: mergedTexts
|
|
4516
4522
|
}
|
|
@@ -4539,9 +4545,9 @@ function NotificationsComponentPublic(props) {
|
|
|
4539
4545
|
onCheckAll: () => {
|
|
4540
4546
|
dispatch({ type: "CHECK_ALL_GROUPS" });
|
|
4541
4547
|
},
|
|
4542
|
-
onSuccess: (userAlreadyExists,
|
|
4548
|
+
onSuccess: (userAlreadyExists, userID2, accessToken) => {
|
|
4543
4549
|
if (accessToken != null) {
|
|
4544
|
-
handleLoginSuccess(
|
|
4550
|
+
handleLoginSuccess(userID2, accessToken);
|
|
4545
4551
|
}
|
|
4546
4552
|
if (userAlreadyExists) {
|
|
4547
4553
|
dispatch({ type: "SHOW_SETTINGS" });
|
|
@@ -4571,8 +4577,39 @@ function NotificationsComponentPublic(props) {
|
|
|
4571
4577
|
)
|
|
4572
4578
|
] });
|
|
4573
4579
|
}
|
|
4574
|
-
function Wrapper3(
|
|
4575
|
-
|
|
4580
|
+
function Wrapper3({
|
|
4581
|
+
slug,
|
|
4582
|
+
userID,
|
|
4583
|
+
productID,
|
|
4584
|
+
projectName,
|
|
4585
|
+
projectLogo,
|
|
4586
|
+
projectLogoDark,
|
|
4587
|
+
groups,
|
|
4588
|
+
isManaging,
|
|
4589
|
+
texts,
|
|
4590
|
+
showQRCode,
|
|
4591
|
+
showPhoneInput,
|
|
4592
|
+
hiddenGroupIds,
|
|
4593
|
+
className
|
|
4594
|
+
}) {
|
|
4595
|
+
return /* @__PURE__ */ jsx31(RpcProvider, { children: /* @__PURE__ */ jsx31(
|
|
4596
|
+
NotificationsComponentPublic,
|
|
4597
|
+
{
|
|
4598
|
+
slug,
|
|
4599
|
+
userID,
|
|
4600
|
+
productID,
|
|
4601
|
+
projectName,
|
|
4602
|
+
projectLogo,
|
|
4603
|
+
projectLogoDark,
|
|
4604
|
+
groups,
|
|
4605
|
+
isManaging,
|
|
4606
|
+
texts,
|
|
4607
|
+
showQRCode,
|
|
4608
|
+
showPhoneInput,
|
|
4609
|
+
hiddenGroupIds,
|
|
4610
|
+
className
|
|
4611
|
+
}
|
|
4612
|
+
) });
|
|
4576
4613
|
}
|
|
4577
4614
|
var NotificationsComponentPublic_default = Wrapper3;
|
|
4578
4615
|
export {
|