48 lines
1.5 KiB
TypeScript
48 lines
1.5 KiB
TypeScript
// Metro module 11910 (f11911).
|
|
import { useCallback } from "react";
|
|
import { claimPremiumCollectiblesProduct, fetchCollectiblesPurchases } from "../CollectiblesActionCreators";
|
|
import ActionSheetActionCreators from "../../action_sheet/native/ActionSheetActionCreators";
|
|
import ProductPurchaseSuccessActionCreators from "./ProductPurchaseSuccessActionCreators";
|
|
import ToastActionCreators from "../../toast/native/ToastActionCreators";
|
|
import { intl, t } from "../../../intl/index.native";
|
|
export function useHandleClaim({ product }) {
|
|
return {
|
|
handleClaim: useCallback(async () => {
|
|
let c27208_3 = 0;
|
|
L10: {
|
|
try {
|
|
c27208_3 = 1;
|
|
await claimPremiumCollectiblesProduct(product.skuId);
|
|
ActionSheetActionCreators.hideActionSheet();
|
|
ProductPurchaseSuccessActionCreators.open({
|
|
product,
|
|
useCategoryImage: true
|
|
});
|
|
fetchCollectiblesPurchases();
|
|
c27208_3 = 0;
|
|
} catch ($e) {
|
|
let r7 = $e;
|
|
if (c27208_3 !== 0) {
|
|
while (true) {
|
|
try {
|
|
c27208_3 = 0;
|
|
ToastActionCreators.open({
|
|
key: "collectible shop claim error",
|
|
content: intl.string(t.CKsXk3)
|
|
});
|
|
break L10;
|
|
} catch ($e) {
|
|
r7 = $e;
|
|
if (c27208_3 === 0) {
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
throw r7;
|
|
}
|
|
}
|
|
}, [product])
|
|
};
|
|
}
|