@akinon/pz-virtual-try-on 2.0.34-beta.0 → 2.0.34
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/CHANGELOG.md +4 -3
- package/README.md +96 -23
- package/package.json +3 -2
- package/src/data/endpoints.ts +50 -5
- package/src/hooks/use-virtual-try-on-async.ts +115 -43
- package/src/hooks/use-virtual-try-on.ts +49 -28
- package/src/index.ts +5 -0
- package/src/types/index.ts +48 -8
- package/src/utils/polling.ts +6 -3
- package/src/views/basket-async-modal.tsx +38 -0
- package/src/views/basket-virtual-try-on.tsx +107 -9
- package/src/views/main.tsx +63 -19
- package/src/views/virtual-try-on-multiple-modal.tsx +8 -2
- package/src/views/virtual-try-on-multiple-result-modal.tsx +36 -4
- package/src/views/virtual-try-on-product-selector.tsx +5 -1
- package/src/views/virtual-try-on-result-modal.tsx +40 -2
|
@@ -14,6 +14,7 @@ export interface VirtualTryOnProductSelectorProps {
|
|
|
14
14
|
onClose: () => void;
|
|
15
15
|
products: BasketProduct[];
|
|
16
16
|
maxSelection?: number;
|
|
17
|
+
disabledSkus?: string[];
|
|
17
18
|
onConfirm: (selectedProducts: BasketProduct[]) => void;
|
|
18
19
|
className?: string;
|
|
19
20
|
settings?: VirtualTryOnPluginSettings;
|
|
@@ -24,6 +25,7 @@ export function VirtualTryOnProductSelector({
|
|
|
24
25
|
onClose,
|
|
25
26
|
products,
|
|
26
27
|
maxSelection = 3,
|
|
28
|
+
disabledSkus = [],
|
|
27
29
|
onConfirm,
|
|
28
30
|
className,
|
|
29
31
|
settings
|
|
@@ -213,7 +215,9 @@ export function VirtualTryOnProductSelector({
|
|
|
213
215
|
>
|
|
214
216
|
{products.slice(0, 8).map((product) => {
|
|
215
217
|
const isSelected = selectedProducts.has(product.pk);
|
|
216
|
-
const isDisabled =
|
|
218
|
+
const isDisabled =
|
|
219
|
+
disabledSkus.includes(product.sku) ||
|
|
220
|
+
(!isSelected && selectedCount >= maxSelection);
|
|
217
221
|
const imageUrl =
|
|
218
222
|
product.productimage_set?.[0]?.image || '/placeholder.png';
|
|
219
223
|
|
|
@@ -107,6 +107,7 @@ export function VirtualTryOnResultModal({
|
|
|
107
107
|
} = activeHookData;
|
|
108
108
|
|
|
109
109
|
const error = (activeHookData as any).error;
|
|
110
|
+
const limitInfo = activeHookData.limitInfo;
|
|
110
111
|
|
|
111
112
|
const ResultModalComponent = settings?.customRenderers?.ResultModal;
|
|
112
113
|
|
|
@@ -407,7 +408,7 @@ export function VirtualTryOnResultModal({
|
|
|
407
408
|
imageUrl: tryOnResult.generated,
|
|
408
409
|
alt: 'Virtual try-on result',
|
|
409
410
|
className: twMerge(
|
|
410
|
-
'w-full
|
|
411
|
+
'w-full rounded-[4px]',
|
|
411
412
|
settings?.customStyles?.resultImage
|
|
412
413
|
)
|
|
413
414
|
}
|
|
@@ -417,7 +418,7 @@ export function VirtualTryOnResultModal({
|
|
|
417
418
|
src={tryOnResult.generated}
|
|
418
419
|
alt="Virtual try-on result"
|
|
419
420
|
className={twMerge(
|
|
420
|
-
'w-full
|
|
421
|
+
'w-full rounded-[4px]',
|
|
421
422
|
settings?.customStyles?.resultImage
|
|
422
423
|
)}
|
|
423
424
|
/>
|
|
@@ -516,6 +517,43 @@ export function VirtualTryOnResultModal({
|
|
|
516
517
|
</div>
|
|
517
518
|
</div>
|
|
518
519
|
|
|
520
|
+
{limitInfo?.tryon_limit !== undefined &&
|
|
521
|
+
(settings?.customRenderers?.render?.resultModal
|
|
522
|
+
?.renderUsageInfo ? (
|
|
523
|
+
settings.customRenderers.render.resultModal.renderUsageInfo(
|
|
524
|
+
{
|
|
525
|
+
used: limitInfo.used_count ?? 0,
|
|
526
|
+
limit: limitInfo.tryon_limit,
|
|
527
|
+
text: t('product.virtual_try_on.usage_info')
|
|
528
|
+
.replace(
|
|
529
|
+
'{{used}}',
|
|
530
|
+
String(limitInfo.used_count ?? 0)
|
|
531
|
+
)
|
|
532
|
+
.replace(
|
|
533
|
+
'{{limit}}',
|
|
534
|
+
String(limitInfo.tryon_limit)
|
|
535
|
+
)
|
|
536
|
+
}
|
|
537
|
+
)
|
|
538
|
+
) : (
|
|
539
|
+
<p
|
|
540
|
+
className={twMerge(
|
|
541
|
+
'text-xs text-gray-500 text-center pb-2',
|
|
542
|
+
settings?.customStyles?.resultModalUsageInfo
|
|
543
|
+
)}
|
|
544
|
+
>
|
|
545
|
+
{t('product.virtual_try_on.usage_info')
|
|
546
|
+
.replace(
|
|
547
|
+
'{{used}}',
|
|
548
|
+
String(limitInfo.used_count ?? 0)
|
|
549
|
+
)
|
|
550
|
+
.replace(
|
|
551
|
+
'{{limit}}',
|
|
552
|
+
String(limitInfo.tryon_limit)
|
|
553
|
+
)}
|
|
554
|
+
</p>
|
|
555
|
+
))}
|
|
556
|
+
|
|
519
557
|
<div
|
|
520
558
|
className={twMerge(
|
|
521
559
|
'lg:hidden px-4 pb-6 space-y-3',
|