Skip to content
This repository was archived by the owner on Jan 7, 2025. It is now read-only.

Commit ebc071c

Browse files
speed updates
1 parent a460a68 commit ebc071c

File tree

3 files changed

+23
-17
lines changed

3 files changed

+23
-17
lines changed

apps/backend-serverless/src/services/business-logic/process-transaction.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export const processTransaction = async (
4242

4343
// TODO: If we're gonna time out, we should requeue this
4444
while (rpcTransaction == null) {
45-
await delay(1000);
45+
await delay(500);
4646
rpcTransaction = await fetchTransaction(signature);
4747
}
4848

apps/backend-serverless/src/utilities/clients/token-authenticate.utility.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export const withAuth = (cookies: string[] | undefined): MerchantAuthToken => {
4545
throw new UnauthorizedRequestError('Token has expired');
4646
}
4747
} else {
48-
if (useAuthMock !== null && useAuthMock !== undefined) {
48+
if (useAuthMock) {
4949
const payload = {
5050
id: useAuthMock,
5151
iat: Math.floor(Date.now() / 1000),

apps/payment-ui/src/components/PayToLabel/index.tsx

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -27,30 +27,36 @@ export const PayToLabel = () => {
2727
const [cart, setCart] = useState<number>(0);
2828
const [isLoading, setIsLoading] = useState(true);
2929

30-
const calculateDiscount = (cart: number, discountRate: number) => (discountRate * cart) / 100;
31-
3230
useEffect(() => {
33-
if (paymentDetails !== null) {
34-
let cart = Number(paymentDetails.usdcSize);
35-
setCart(cart);
36-
setIsLoading(false);
37-
}
38-
}, [paymentDetails]);
31+
if (paymentDetails) {
32+
console.log('in effect', paymentDetails, customerTier);
33+
let cartValue = Number(paymentDetails.usdcSize);
3934

40-
useEffect(() => {
41-
if (customerTier !== null && cart > 0) {
42-
setDiscount(calculateDiscount(cart, customerTier.discount));
35+
console.log('cart value', cartValue);
36+
setCart(cartValue);
37+
if (customerTier && cartValue > 0) {
38+
setDiscount((cartValue * customerTier.discount) / 100);
39+
console.log('discoutn', cartValue * customerTier.discount);
40+
}
41+
setIsLoading(false);
4342
}
44-
}, [customerTier, cart]);
43+
}, [paymentDetails, customerTier]);
4544

4645
function calculateFinalAmount(): number {
47-
if (!loyaltyDetails || !customer || !paymentDetails || !customerTier) {
48-
return 0;
46+
if (!paymentDetails) {
47+
return -1;
48+
}
49+
console.log('final stats', loyaltyDetails, customer, paymentDetails, customerTier);
50+
if (!loyaltyDetails || !customer || !customerTier) {
51+
console.log('no loyalty details', paymentDetails.usdcSize);
52+
return paymentDetails.usdcSize;
4953
}
5054

5155
if (loyaltyDetails?.loyaltyProgram === 'tiers' && customer.customerOwns) {
56+
console.log('cart - disc f, ', cart, discount);
5257
return cart - discount;
5358
} else {
59+
console.log('else', paymentDetails.usdcSize);
5460
return paymentDetails.usdcSize;
5561
}
5662
}
@@ -73,7 +79,7 @@ export const PayToLabel = () => {
7379
<div className="divider" />
7480
</div>
7581
<CartAmountLoading />
76-
<DiscountAmountLoading />
82+
{showTierDiscount && <DiscountAmountLoading />}
7783
<FeePriceDisplayLoading />
7884
</div>
7985
);

0 commit comments

Comments
 (0)