fix the shit

This commit is contained in:
laynester 2022-12-13 04:19:22 -05:00
parent 306440c9de
commit 580d0a1d2d
2 changed files with 19 additions and 10 deletions

View File

@ -27,6 +27,9 @@
width: 80px; width: 80px;
height: 80px; height: 80px;
overflow: hidden; overflow: hidden;
display: flex;
justify-content: center;
align-items: center;
} }
.gift-color { .gift-color {
@ -89,7 +92,8 @@
.icon-hc-banner { .icon-hc-banner {
width: 68px; width: 68px;
height: 40px; height: 40px;
background: url("../../assets/images/catalog/hc_big.png") center no-repeat; background: url("../../assets/images/catalog/hc_big.png") center
no-repeat;
} }
} }
} }

View File

@ -36,30 +36,33 @@ export const CatalogGiftView: FC<{}> = props =>
setMessage(''); setMessage('');
setSelectedBoxIndex(0); setSelectedBoxIndex(0);
setSelectedRibbonIndex(0); setSelectedRibbonIndex(0);
if(colors.length) setSelectedColorId(colors[0].id); if(colors.length) setSelectedColorId(colors[0].id);
}, [ colors ]); }, [ colors ]);
const isBoxDefault = useMemo(() => const isBoxDefault = useMemo(() =>
{ {
return giftConfiguration ? (giftConfiguration.defaultStuffTypes.findIndex(s => (s === giftConfiguration.boxTypes[selectedBoxIndex])) > -1) : true; return giftConfiguration ? (giftConfiguration.defaultStuffTypes.findIndex(s => (s === giftConfiguration.boxTypes[selectedBoxIndex])) > -1) : false;
}, [ giftConfiguration, selectedBoxIndex ]); }, [ giftConfiguration, selectedBoxIndex ]);
const boxExtraData = useMemo(() => const boxExtraData = useMemo(() =>
{ {
if(!giftConfiguration) return ''; if (!giftConfiguration) return '';
return ((giftConfiguration.boxTypes[selectedBoxIndex] * 1000) + giftConfiguration.ribbonTypes[selectedRibbonIndex]).toString(); return ((giftConfiguration.boxTypes[selectedBoxIndex] * 1000) + giftConfiguration.ribbonTypes[selectedRibbonIndex]).toString();
}, [ giftConfiguration, selectedBoxIndex, selectedRibbonIndex ]); }, [ giftConfiguration, selectedBoxIndex, selectedRibbonIndex ]);
const isColorable = useMemo(() => const isColorable = useMemo(() =>
{ {
if(!giftConfiguration) return false; if (!giftConfiguration) return false;
if (isBoxDefault) return false;
const boxType = giftConfiguration.boxTypes[selectedBoxIndex]; const boxType = giftConfiguration.boxTypes[selectedBoxIndex];
return (boxType === 8 || (boxType >= 3 && boxType <= 6)) ? false : true; return (boxType === 8 || (boxType >= 3 && boxType <= 6)) ? false : true;
}, [ giftConfiguration, selectedBoxIndex ]); }, [ giftConfiguration, selectedBoxIndex, isBoxDefault ]);
const handleAction = useCallback((action: string) => const handleAction = useCallback((action: string) =>
{ {
@ -83,7 +86,7 @@ export const CatalogGiftView: FC<{}> = props =>
setReceiverNotFound(true); setReceiverNotFound(true);
return; return;
} }
SendMessageComposer(new PurchaseFromCatalogAsGiftComposer(pageId, offerId, extraData, receiverName, message, selectedColorId, selectedBoxIndex, selectedRibbonIndex, showMyFace)); SendMessageComposer(new PurchaseFromCatalogAsGiftComposer(pageId, offerId, extraData, receiverName, message, selectedColorId, selectedBoxIndex, selectedRibbonIndex, showMyFace));
return; return;
} }
@ -133,6 +136,8 @@ export const CatalogGiftView: FC<{}> = props =>
if(giftData.colors && giftData.colors.length > 0) newColors.push({ id: colorId, color: `#${ giftData.colors[0].toString(16) }` }); if(giftData.colors && giftData.colors.length > 0) newColors.push({ id: colorId, color: `#${ giftData.colors[0].toString(16) }` });
} }
giftConfiguration.boxTypes.push(giftConfiguration.defaultStuffTypes[Math.floor((Math.random() * giftConfiguration.defaultStuffTypes.length) - 1)]);
setMaxBoxIndex(giftConfiguration.boxTypes.length - 1); setMaxBoxIndex(giftConfiguration.boxTypes.length - 1);
setMaxRibbonIndex(giftConfiguration.ribbonTypes.length - 1); setMaxRibbonIndex(giftConfiguration.ribbonTypes.length - 1);
@ -145,7 +150,7 @@ export const CatalogGiftView: FC<{}> = props =>
if(!giftConfiguration || !giftConfiguration.isEnabled || !isVisible) return null; if(!giftConfiguration || !giftConfiguration.isEnabled || !isVisible) return null;
const boxName = 'catalog.gift_wrapping_new.box.' + (isBoxDefault ? 'default' : selectedBoxIndex); const boxName = 'catalog.gift_wrapping_new.box.' + (isBoxDefault ? 'default' : giftConfiguration.boxTypes[selectedBoxIndex]);
const ribbonName = `catalog.gift_wrapping_new.ribbon.${ selectedRibbonIndex }`; const ribbonName = `catalog.gift_wrapping_new.ribbon.${ selectedRibbonIndex }`;
const priceText = 'catalog.gift_wrapping_new.' + (isBoxDefault ? 'freeprice' : 'price'); const priceText = 'catalog.gift_wrapping_new.' + (isBoxDefault ? 'freeprice' : 'price');
@ -187,7 +192,7 @@ export const CatalogGiftView: FC<{}> = props =>
</Flex> </Flex>
</Column> </Column>
</Flex> </Flex>
<Flex alignItems="center" gap={ 2 }> <Flex alignItems="center" gap={ 2 } className={ isColorable ? '' : 'opacity-50 pointer-events-none' }>
<ButtonGroup> <ButtonGroup>
<Button variant="primary" onClick={ () => handleAction('prev_ribbon') }> <Button variant="primary" onClick={ () => handleAction('prev_ribbon') }>
<FontAwesomeIcon icon="chevron-left" /> <FontAwesomeIcon icon="chevron-left" />
@ -200,7 +205,7 @@ export const CatalogGiftView: FC<{}> = props =>
</Flex> </Flex>
</Column> </Column>
</Flex> </Flex>
<Column gap={ 1 }> <Column gap={ 1 } className={ isColorable ? '' : 'opacity-50 pointer-events-none' }>
<Text fontWeight="bold"> <Text fontWeight="bold">
{ LocalizeText('catalog.gift_wrapping.pick_color') } { LocalizeText('catalog.gift_wrapping.pick_color') }
</Text> </Text>