Fix purchase error button

This commit is contained in:
Bill 2021-08-31 16:26:29 -04:00
parent 08c377e190
commit 5cb9c037cc
3 changed files with 12 additions and 0 deletions

View File

@ -51,12 +51,16 @@ export const CatalogMessageHandler: FC<CatalogMessageHandlerProps> = props =>
{ {
const parser = event.getParser(); const parser = event.getParser();
console.log(parser);
dispatchUiEvent(new CatalogPurchaseFailureEvent(parser.code)); dispatchUiEvent(new CatalogPurchaseFailureEvent(parser.code));
}, []); }, []);
const onCatalogPurchaseUnavailableEvent = useCallback((event: PurchaseNotAllowedMessageEvent) => const onCatalogPurchaseUnavailableEvent = useCallback((event: PurchaseNotAllowedMessageEvent) =>
{ {
const parser = event.getParser(); const parser = event.getParser();
console.log(parser);
}, []); }, []);
const onCatalogSoldOutEvent = useCallback((event: LimitedEditionSoldOutEvent) => const onCatalogSoldOutEvent = useCallback((event: LimitedEditionSoldOutEvent) =>

View File

@ -24,14 +24,19 @@ export const CatalogPurchaseButtonView: FC<CatalogPurchaseButtonViewProps> = pro
case CatalogEvent.SOLD_OUT: case CatalogEvent.SOLD_OUT:
setPurchaseState(CatalogPurchaseState.SOLD_OUT); setPurchaseState(CatalogPurchaseState.SOLD_OUT);
return; return;
case CatalogEvent.PURCHASE_FAILED:
setPurchaseState(CatalogPurchaseState.FAILED);
return;
} }
}, []); }, []);
useUiEvent(CatalogEvent.PURCHASE_SUCCESS, onCatalogEvent); useUiEvent(CatalogEvent.PURCHASE_SUCCESS, onCatalogEvent);
useUiEvent(CatalogEvent.SOLD_OUT, onCatalogEvent); useUiEvent(CatalogEvent.SOLD_OUT, onCatalogEvent);
useUiEvent(CatalogEvent.PURCHASE_FAILED, onCatalogEvent);
const purchase = useCallback(() => const purchase = useCallback(() =>
{ {
console.log(pageId, offer.offerId, extra, quantity);
SendMessageHook(new PurchaseFromCatalogComposer(pageId, offer.offerId, extra, quantity)); SendMessageHook(new PurchaseFromCatalogComposer(pageId, offer.offerId, extra, quantity));
}, [ pageId, offer, extra, quantity ]); }, [ pageId, offer, extra, quantity ]);
@ -94,6 +99,8 @@ export const CatalogPurchaseButtonView: FC<CatalogPurchaseButtonViewProps> = pro
return <button type="button" className={ 'btn btn-primary ' + className } disabled><LoadingSpinnerView /></button>; return <button type="button" className={ 'btn btn-primary ' + className } disabled><LoadingSpinnerView /></button>;
case CatalogPurchaseState.SOLD_OUT: case CatalogPurchaseState.SOLD_OUT:
return <button type="button" className={ 'btn btn-danger ' + className } disabled>{ LocalizeText('generic.failed') + ' - ' + LocalizeText('catalog.alert.limited_edition_sold_out.title') }</button>; return <button type="button" className={ 'btn btn-danger ' + className } disabled>{ LocalizeText('generic.failed') + ' - ' + LocalizeText('catalog.alert.limited_edition_sold_out.title') }</button>;
case CatalogPurchaseState.FAILED:
return <button type="button" className={ 'btn btn-danger ' + className } disabled>{ LocalizeText('generic.failed') }</button>;
case CatalogPurchaseState.NONE: case CatalogPurchaseState.NONE:
default: default:
return <button type="button" className={ 'btn btn-success ' + className } disabled={ disabled } onClick={ event => setPurchaseState(CatalogPurchaseState.CONFIRM) }>{ LocalizeText('buy') }</button> return <button type="button" className={ 'btn btn-success ' + className } disabled={ disabled } onClick={ event => setPurchaseState(CatalogPurchaseState.CONFIRM) }>{ LocalizeText('buy') }</button>

View File

@ -20,4 +20,5 @@ export class CatalogPurchaseState
public static NO_CREDITS = 3; public static NO_CREDITS = 3;
public static NO_POINTS = 4; public static NO_POINTS = 4;
public static SOLD_OUT = 5; public static SOLD_OUT = 5;
public static FAILED = 6;
} }