@anker-in/ui 0.3.0 → 0.3.1
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/demo-room.js +15 -4
- package/dist/demo-room.js.map +1 -1
- package/dist/demo-room.mjs +15 -4
- package/dist/demo-room.mjs.map +1 -1
- package/dist/index.d.mts +22 -8
- package/dist/index.d.ts +22 -8
- package/dist/index.js +104 -29
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +104 -29
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -864,12 +864,12 @@ function useBookingDesign(client, params, options) {
|
|
|
864
864
|
});
|
|
865
865
|
const enabled = options?.enabled !== false;
|
|
866
866
|
useEffect(() => {
|
|
867
|
-
if (!enabled || !params.booking_token) return;
|
|
867
|
+
if (!enabled || !params.booking_token && !(params.demoroom_code && params.session_id)) return;
|
|
868
868
|
let cancelled = false;
|
|
869
869
|
const fetchData = async () => {
|
|
870
870
|
setState((prev) => ({ ...prev, loading: true, error: null }));
|
|
871
871
|
try {
|
|
872
|
-
const data = await client.getBookingDesign(params
|
|
872
|
+
const data = await client.getBookingDesign(params);
|
|
873
873
|
if (!cancelled) {
|
|
874
874
|
setState({ data, loading: false, error: null });
|
|
875
875
|
}
|
|
@@ -887,7 +887,7 @@ function useBookingDesign(client, params, options) {
|
|
|
887
887
|
return () => {
|
|
888
888
|
cancelled = true;
|
|
889
889
|
};
|
|
890
|
-
}, [client, params.booking_token, enabled]);
|
|
890
|
+
}, [client, params.booking_token, params.demoroom_code, params.session_id, enabled]);
|
|
891
891
|
return state;
|
|
892
892
|
}
|
|
893
893
|
var AntdMobileIsolated = ({
|
|
@@ -1766,12 +1766,23 @@ var DemoRoomApiClient = class {
|
|
|
1766
1766
|
return response.booking;
|
|
1767
1767
|
}
|
|
1768
1768
|
/**
|
|
1769
|
-
* 查询 POD
|
|
1770
|
-
*
|
|
1769
|
+
* 查询 POD 作品信息
|
|
1770
|
+
* 模式1(优先):通过 booking_token 精确查询
|
|
1771
|
+
* 模式2:通过 demoroom_code + session_id 查询(MIR 跳回时预约尚未创建的场景)
|
|
1772
|
+
* @param params 查询参数
|
|
1771
1773
|
*/
|
|
1772
|
-
async getBookingDesign(
|
|
1774
|
+
async getBookingDesign(params) {
|
|
1773
1775
|
const searchParams = new URLSearchParams();
|
|
1774
|
-
|
|
1776
|
+
if (params.booking_token) {
|
|
1777
|
+
searchParams.append("booking_token", params.booking_token);
|
|
1778
|
+
} else {
|
|
1779
|
+
if (params.demoroom_code) {
|
|
1780
|
+
searchParams.append("demoroom_code", params.demoroom_code);
|
|
1781
|
+
}
|
|
1782
|
+
if (params.session_id) {
|
|
1783
|
+
searchParams.append("session_id", params.session_id);
|
|
1784
|
+
}
|
|
1785
|
+
}
|
|
1775
1786
|
return this.request(
|
|
1776
1787
|
`/api/v1/store/bookings/design?${searchParams.toString()}`
|
|
1777
1788
|
);
|
|
@@ -11404,6 +11415,7 @@ var DateTimePicker2 = ({
|
|
|
11404
11415
|
apiClient,
|
|
11405
11416
|
demoRoomCode,
|
|
11406
11417
|
demoRoom: demoRoomProp,
|
|
11418
|
+
demoRoomLoading,
|
|
11407
11419
|
token,
|
|
11408
11420
|
booking,
|
|
11409
11421
|
timezone: timezone5,
|
|
@@ -11432,11 +11444,12 @@ var DateTimePicker2 = ({
|
|
|
11432
11444
|
loading: editLoading,
|
|
11433
11445
|
error: editError
|
|
11434
11446
|
} = useEditBooking(apiClient);
|
|
11447
|
+
const isManagedByParent = demoRoomLoading !== void 0;
|
|
11435
11448
|
const { data: fetchedDemoRoom } = useDemoRoom(
|
|
11436
11449
|
apiClient,
|
|
11437
11450
|
demoRoomCode || "",
|
|
11438
11451
|
locale,
|
|
11439
|
-
{ enabled: !demoRoomProp && !!demoRoomCode }
|
|
11452
|
+
{ enabled: !isManagedByParent && !demoRoomProp && !!demoRoomCode }
|
|
11440
11453
|
);
|
|
11441
11454
|
const demoRoom = demoRoomProp ?? fetchedDemoRoom;
|
|
11442
11455
|
const isPodPurpose = selectedPurposeType === "pod";
|
|
@@ -12074,6 +12087,7 @@ var DemoRoomDetail2 = ({
|
|
|
12074
12087
|
demoRoomCode,
|
|
12075
12088
|
locale,
|
|
12076
12089
|
demoRoom: demoRoomProp,
|
|
12090
|
+
demoRoomLoading,
|
|
12077
12091
|
title: titleProp,
|
|
12078
12092
|
descriptions: descriptionsProp,
|
|
12079
12093
|
devices: devicesProp,
|
|
@@ -12089,7 +12103,8 @@ var DemoRoomDetail2 = ({
|
|
|
12089
12103
|
className,
|
|
12090
12104
|
...props
|
|
12091
12105
|
}) => {
|
|
12092
|
-
const
|
|
12106
|
+
const isManagedByParent = demoRoomLoading !== void 0;
|
|
12107
|
+
const shouldFetch = !isManagedByParent && !demoRoomProp && !!apiClient && !!demoRoomCode;
|
|
12093
12108
|
const {
|
|
12094
12109
|
data: fetchedDemoRoom,
|
|
12095
12110
|
loading,
|
|
@@ -12111,7 +12126,8 @@ var DemoRoomDetail2 = ({
|
|
|
12111
12126
|
}
|
|
12112
12127
|
return "#";
|
|
12113
12128
|
})();
|
|
12114
|
-
|
|
12129
|
+
const isLoading = isManagedByParent ? !!demoRoomLoading : loading && shouldFetch;
|
|
12130
|
+
if (isLoading) {
|
|
12115
12131
|
return /* @__PURE__ */ jsx("div", { className: cn("w-full pb-4", className), ...props, children: /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-8 items-start", children: [
|
|
12116
12132
|
/* @__PURE__ */ jsxs("div", { className: "space-y-6", children: [
|
|
12117
12133
|
/* @__PURE__ */ jsx("div", { className: "h-12 bg-gray-200 rounded animate-pulse" }),
|
|
@@ -12309,21 +12325,41 @@ var DemoRoomDetail2 = ({
|
|
|
12309
12325
|
DemoRoomDetail2.displayName = "DemoRoomDetail";
|
|
12310
12326
|
|
|
12311
12327
|
// src/components/BookingFormO2O/utils/buildMirUrl.ts
|
|
12328
|
+
var REDIRECT_URL_ALLOWED_PARAMS = ["code", "business_type", "token"];
|
|
12329
|
+
function sanitizeRedirectSource(source) {
|
|
12330
|
+
if (!source) return source;
|
|
12331
|
+
try {
|
|
12332
|
+
const parsed = new URL(source);
|
|
12333
|
+
const keptParams = new URLSearchParams();
|
|
12334
|
+
REDIRECT_URL_ALLOWED_PARAMS.forEach((key) => {
|
|
12335
|
+
const value = parsed.searchParams.get(key);
|
|
12336
|
+
if (value) keptParams.set(key, value);
|
|
12337
|
+
});
|
|
12338
|
+
parsed.search = keptParams.toString();
|
|
12339
|
+
return parsed.toString();
|
|
12340
|
+
} catch {
|
|
12341
|
+
return source;
|
|
12342
|
+
}
|
|
12343
|
+
}
|
|
12312
12344
|
function buildMirWelcomeUrl({
|
|
12313
12345
|
baseUrl,
|
|
12314
12346
|
language,
|
|
12315
12347
|
managerId,
|
|
12316
12348
|
credential,
|
|
12317
|
-
currentUrl
|
|
12349
|
+
currentUrl,
|
|
12350
|
+
managerIdParam = "email",
|
|
12351
|
+
credentialParam = "credential"
|
|
12318
12352
|
}) {
|
|
12319
12353
|
const url = new URL(baseUrl);
|
|
12320
12354
|
if (language) {
|
|
12321
12355
|
url.searchParams.set("language", language);
|
|
12322
12356
|
}
|
|
12323
12357
|
url.searchParams.set("countrycode", "US");
|
|
12324
|
-
url.searchParams.set(
|
|
12325
|
-
url.searchParams.set(
|
|
12326
|
-
const redirectSource =
|
|
12358
|
+
url.searchParams.set(managerIdParam, managerId);
|
|
12359
|
+
url.searchParams.set(credentialParam, credential);
|
|
12360
|
+
const redirectSource = sanitizeRedirectSource(
|
|
12361
|
+
currentUrl ?? (typeof window !== "undefined" ? window.location.href : "")
|
|
12362
|
+
);
|
|
12327
12363
|
url.searchParams.set("redirect_url", encodeURIComponent(redirectSource));
|
|
12328
12364
|
return url.toString();
|
|
12329
12365
|
}
|
|
@@ -12400,7 +12436,7 @@ var getPurposeLabel = (pageData) => {
|
|
|
12400
12436
|
return "What is your purpose of visit?";
|
|
12401
12437
|
};
|
|
12402
12438
|
var getPodContentDescription = (podContent) => podContent?.description || podContent?.subTitle;
|
|
12403
|
-
var getPodContentImage = (podContent) => podContent?.
|
|
12439
|
+
var getPodContentImage = (podContent) => podContent?.defaultImg;
|
|
12404
12440
|
var getPodContentButtonText = (podContent) => podContent?.buttonText || podContent?.btnText;
|
|
12405
12441
|
var BookingFormO2O = ({
|
|
12406
12442
|
layoutClassName,
|
|
@@ -12417,9 +12453,10 @@ var BookingFormO2O = ({
|
|
|
12417
12453
|
}) => {
|
|
12418
12454
|
const apiClient = useMemo(
|
|
12419
12455
|
() => createDemoRoomApi(apiConfig),
|
|
12420
|
-
|
|
12456
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
12457
|
+
[apiConfig.baseUrl, apiConfig.apiKey, apiConfig.locale]
|
|
12421
12458
|
);
|
|
12422
|
-
const { data: demoRoom } = useDemoRoom(
|
|
12459
|
+
const { data: demoRoom, loading: demoRoomLoading } = useDemoRoom(
|
|
12423
12460
|
apiClient,
|
|
12424
12461
|
demoRoomCode || "",
|
|
12425
12462
|
apiConfig.locale,
|
|
@@ -12460,17 +12497,49 @@ var BookingFormO2O = ({
|
|
|
12460
12497
|
}, [purposeOptions, selectedPurposeType]);
|
|
12461
12498
|
const selectedPodContent = selectedPurpose?.podContent;
|
|
12462
12499
|
const selectedPodDescription = getPodContentDescription(selectedPodContent);
|
|
12463
|
-
const
|
|
12500
|
+
const podDesignId = useMemo(() => getQueryParam("design_id"), []);
|
|
12501
|
+
const isPodDesignEditMode = !!podDesignId || !!booking?.design_project_id;
|
|
12502
|
+
const storeManagerIdFromUrl = useMemo(
|
|
12503
|
+
() => getQueryParam("store_manager_id"),
|
|
12504
|
+
[]
|
|
12505
|
+
);
|
|
12506
|
+
const mirSessionId = useMemo(() => getQueryParam("session_id"), []);
|
|
12507
|
+
const effectiveStoreManagerId = storeManagerIdFromUrl || demoRoom?.contact?.manager_id;
|
|
12508
|
+
const effectiveMirSessionId = mirSessionId || booking?.design_project_id;
|
|
12509
|
+
const { data: bookingDesign } = useBookingDesign(
|
|
12510
|
+
apiClient,
|
|
12511
|
+
{ demoroom_code: demoRoomCode, session_id: effectiveMirSessionId },
|
|
12512
|
+
{ enabled: !!demoRoomCode && !!effectiveMirSessionId }
|
|
12513
|
+
);
|
|
12514
|
+
const selectedPodButtonText = isPodDesignEditMode ? selectedPodContent?.btnEditText : getPodContentButtonText(selectedPodContent);
|
|
12464
12515
|
const selectedPodImage = getSafePageDataUrl(
|
|
12465
|
-
getPodContentImage(selectedPodContent)
|
|
12516
|
+
isPodDesignEditMode && bookingDesign?.thumb_url || getPodContentImage(selectedPodContent)
|
|
12466
12517
|
);
|
|
12467
|
-
const selectedPodButtonIcon = getSafePageDataUrl(
|
|
12468
|
-
|
|
12469
|
-
|
|
12470
|
-
const
|
|
12518
|
+
const selectedPodButtonIcon = getSafePageDataUrl(
|
|
12519
|
+
isPodDesignEditMode ? selectedPodContent?.btnEditIcon : selectedPodContent?.btnIcon
|
|
12520
|
+
);
|
|
12521
|
+
const managerId = demoRoom?.contact?.manager_hash;
|
|
12522
|
+
const isPodButtonDisabled = isPodDesignEditMode ? !effectiveStoreManagerId || !effectiveMirSessionId : !managerId;
|
|
12471
12523
|
const mirCredential = useMemo(() => crypto.randomUUID(), [demoRoomCode]);
|
|
12472
|
-
console.log(selectedPodContent);
|
|
12473
12524
|
const selectedPodButtonLink = useMemo(() => {
|
|
12525
|
+
if (isPodButtonDisabled) return void 0;
|
|
12526
|
+
if (isPodDesignEditMode) {
|
|
12527
|
+
const editBaseUrl = getSafePageDataUrl(
|
|
12528
|
+
selectedPodContent?.buttonEditLink
|
|
12529
|
+
);
|
|
12530
|
+
if (!editBaseUrl || !effectiveStoreManagerId || !effectiveMirSessionId) {
|
|
12531
|
+
return void 0;
|
|
12532
|
+
}
|
|
12533
|
+
return buildMirWelcomeUrl({
|
|
12534
|
+
baseUrl: editBaseUrl,
|
|
12535
|
+
language: apiConfig.locale,
|
|
12536
|
+
managerId: effectiveStoreManagerId,
|
|
12537
|
+
credential: effectiveMirSessionId,
|
|
12538
|
+
managerIdParam: "store_manager_id",
|
|
12539
|
+
credentialParam: "sessionid"
|
|
12540
|
+
});
|
|
12541
|
+
}
|
|
12542
|
+
if (!managerId) return void 0;
|
|
12474
12543
|
const baseUrl = getSafePageDataUrl(selectedPodContent?.buttonLink);
|
|
12475
12544
|
if (!baseUrl) return void 0;
|
|
12476
12545
|
return buildMirWelcomeUrl({
|
|
@@ -12484,7 +12553,10 @@ var BookingFormO2O = ({
|
|
|
12484
12553
|
apiConfig.locale,
|
|
12485
12554
|
managerId,
|
|
12486
12555
|
isPodButtonDisabled,
|
|
12487
|
-
mirCredential
|
|
12556
|
+
mirCredential,
|
|
12557
|
+
isPodDesignEditMode,
|
|
12558
|
+
effectiveStoreManagerId,
|
|
12559
|
+
effectiveMirSessionId
|
|
12488
12560
|
]);
|
|
12489
12561
|
const dateTimePickerPageData = useMemo(
|
|
12490
12562
|
() => ({
|
|
@@ -12501,6 +12573,7 @@ var BookingFormO2O = ({
|
|
|
12501
12573
|
apiClient,
|
|
12502
12574
|
demoRoomCode,
|
|
12503
12575
|
demoRoom,
|
|
12576
|
+
demoRoomLoading,
|
|
12504
12577
|
locale: apiConfig.locale,
|
|
12505
12578
|
pageData: pageData?.demoRoomDetail
|
|
12506
12579
|
}
|
|
@@ -12548,7 +12621,7 @@ var BookingFormO2O = ({
|
|
|
12548
12621
|
{
|
|
12549
12622
|
src: selectedPodImage,
|
|
12550
12623
|
alt: selectedPodContent.imageAlt || selectedPodContent.title || "",
|
|
12551
|
-
className: "mt-[12px] h-[
|
|
12624
|
+
className: "mt-[12px] h-[220px] rounded-[8px] object-cover l:h-auto"
|
|
12552
12625
|
}
|
|
12553
12626
|
),
|
|
12554
12627
|
!!selectedPodButtonText && /* @__PURE__ */ jsxs(
|
|
@@ -12556,13 +12629,14 @@ var BookingFormO2O = ({
|
|
|
12556
12629
|
{
|
|
12557
12630
|
href: selectedPodButtonLink || "#",
|
|
12558
12631
|
"aria-disabled": isPodButtonDisabled,
|
|
12559
|
-
tabIndex: void 0,
|
|
12632
|
+
tabIndex: isPodButtonDisabled ? -1 : void 0,
|
|
12560
12633
|
onClick: (event2) => {
|
|
12634
|
+
if (isPodButtonDisabled) event2.preventDefault();
|
|
12561
12635
|
},
|
|
12562
12636
|
rel: "noopener noreferrer",
|
|
12563
12637
|
className: cn(
|
|
12564
12638
|
"mt-[12px] inline-flex h-[42px] items-center justify-center gap-[6px] rounded-full bg-[#080A0F] px-[24px] text-[14px] font-bold text-white transition-colors hover:bg-[#2A2C32]",
|
|
12565
|
-
isPodButtonDisabled
|
|
12639
|
+
isPodButtonDisabled && "pointer-events-none cursor-not-allowed opacity-50"
|
|
12566
12640
|
),
|
|
12567
12641
|
children: [
|
|
12568
12642
|
selectedPodButtonIcon && /* @__PURE__ */ jsx(
|
|
@@ -12586,6 +12660,7 @@ var BookingFormO2O = ({
|
|
|
12586
12660
|
apiClient,
|
|
12587
12661
|
demoRoomCode,
|
|
12588
12662
|
demoRoom,
|
|
12663
|
+
demoRoomLoading,
|
|
12589
12664
|
token,
|
|
12590
12665
|
booking,
|
|
12591
12666
|
timezone: timezone5,
|
|
@@ -12723,7 +12798,7 @@ var BookingSuccessO2O = ({
|
|
|
12723
12798
|
const fetchBookingDesign = async () => {
|
|
12724
12799
|
try {
|
|
12725
12800
|
const apiClient = createDemoRoomApi(apiConfig);
|
|
12726
|
-
const design = await apiClient.getBookingDesign(token);
|
|
12801
|
+
const design = await apiClient.getBookingDesign({ booking_token: token });
|
|
12727
12802
|
setBookingDesign(design);
|
|
12728
12803
|
} catch (err) {
|
|
12729
12804
|
console.error("Failed to fetch booking design:", err);
|