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

Commit

Permalink
payment bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
harshasomisetty committed Aug 20, 2023
1 parent 5a2d0f4 commit 7db0d96
Show file tree
Hide file tree
Showing 7 changed files with 105 additions and 55 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,18 @@ export const createLoyaltyResponse = async (merchant: Merchant): Promise<Loyalty
const products = await merchantService.getProductsByMerchant(merchant.id);
const tiers = await merchantService.getTiers(merchant.id);

let gasKeypair = await fetchGasKeypair();
let mint = await getPointsMint(gasKeypair.publicKey, new PublicKey(merchant.id));
let mint: string | null = null;
if (merchant.pointsBack) {
let gasKeypair = await fetchGasKeypair();
mint = (await getPointsMint(gasKeypair.publicKey, new PublicKey(merchant.id))).toString();
}

return {
loyaltyProgram: merchant.loyaltyProgram,
productStatus: merchant.productStatus,
points: {
pointsBack: merchant.pointsBack ? merchant.pointsBack : null,
pointsMint: merchant.pointsBack ? mint.toString() : null,
pointsMint: mint,
},
products: products,
tiers: tiers,
Expand Down
2 changes: 1 addition & 1 deletion apps/merchant-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"@radix-ui/react-switch": "^1.0.3",
"@radix-ui/react-tabs": "^1.0.4",
"@radix-ui/react-toast": "^1.1.4",
"@radix-ui/react-tooltip": "^1.0.5",
"@radix-ui/react-tooltip": "^1.0.6",
"@solana-mobile/wallet-adapter-mobile": "^2.0.0",
"@solana/wallet-adapter-base": "^0.9.22",
"@solana/wallet-adapter-react": "^0.15.32",
Expand Down
13 changes: 6 additions & 7 deletions apps/merchant-ui/src/components/DefaultLayoutNavigation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,12 @@ export function DefaultLayoutNavigation(props: Props) {
text="Refunds"
renderInRhs={<RefundCount refundCount={refundCount} />}
/>
{process.env.NEXT_PUBLIC_FEATURE_FLAG == 'true' && (
<DefaultLayoutNavigationLink
href="/loyalty"
icon={<AiOutlineCrown />}
text="Loyalty"
/>
)}
<DefaultLayoutNavigationLink
href="/loyalty"
icon={<AiOutlineCrown />}
text="Loyalty"
disabled={process.env.NEXT_PUBLIC_FEATURE_FLAG == 'true'}
/>
<DefaultLayoutNavigationLink href="/merchant" icon={<Store />} text="Merchant" />
<DefaultLayoutNavigationLink href="/support" icon={<Support />} text="Support" />
</div>
Expand Down
94 changes: 58 additions & 36 deletions apps/merchant-ui/src/components/DefaultLayoutNavigationLink.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from '@/components/ui/tooltip';
import * as NavigationMenu from '@radix-ui/react-navigation-menu';
import Link from 'next/link';
import { useRouter } from 'next/router';
Expand All @@ -10,51 +11,72 @@ interface Props {
icon: JSX.Element;
text: string;
renderInRhs?: JSX.Element;
disabled?: boolean;
}

export function DefaultLayoutNavigationLink(props: Props) {
export function DefaultLayoutNavigationLink({ disabled = false, ...props }: Props) {
const router = useRouter();
const isSelected = router.asPath.startsWith(props.href);

const handleOnClick = (e: React.MouseEvent) => {
if (disabled) {
e.preventDefault();
}
};

return (
<NavigationMenu.Item>
<NavigationMenu.Link asChild>
<Link
className={twMerge(
'gap-x-3',
'group',
'grid',
'items-center',
'px-3',
'py-2',
'rounded-md',
'transition-colors',
isSelected && 'bg-slate-50',
props.renderInRhs ? 'grid-cols-[24px,1fr,max-content]' : 'grid-cols-[24px,1fr]',
)}
href={props.href}
>
{cloneElement(props.icon, {
className: twMerge(
'fill-slate-400',
'h-6',
'transition-colors',
'w-6',
isSelected && 'fill-indigo-600',
props.icon.props.className,
),
})}
<div
className={twMerge(
'transition-all',
'group-hover:font-semibold',
isSelected && 'font-semibold',
<TooltipProvider>
<Tooltip>
<TooltipTrigger asChild>
<Link
className={twMerge(
'gap-x-3',
'group',
'grid',
'items-center',
'px-3',
'py-2',
'rounded-md',
'transition-colors',
isSelected && 'bg-slate-50',
disabled && 'text-gray-400 cursor-not-allowed', // Apply disabled styling
props.renderInRhs ? 'grid-cols-[24px,1fr,max-content]' : 'grid-cols-[24px,1fr]'
)}
href={props.href}
onClick={handleOnClick}
>
{cloneElement(props.icon, {
className: twMerge(
'fill-slate-400',
'h-6',
'transition-colors',
'w-6',
isSelected && 'fill-indigo-600',
disabled && 'fill-gray-400', // Apply disabled styling to icon
props.icon.props.className
),
})}
<div
className={twMerge(
'transition-all',
'group-hover:font-semibold',
isSelected && 'font-semibold'
)}
>
{props.text}
</div>
{props.renderInRhs && <div>{props.renderInRhs}</div>}
</Link>
</TooltipTrigger>
{disabled && (
<TooltipContent>
<p>Coming Soon</p>
</TooltipContent>
)}
>
{props.text}
</div>
{props.renderInRhs && <div>{props.renderInRhs}</div>}
</Link>
</Tooltip>
</TooltipProvider>
</NavigationMenu.Link>
</NavigationMenu.Item>
);
Expand Down
28 changes: 28 additions & 0 deletions apps/merchant-ui/src/components/ui/tooltip.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import * as TooltipPrimitive from '@radix-ui/react-tooltip';
import * as React from 'react';

import { cn } from '@/lib/utils';

const TooltipProvider = TooltipPrimitive.Provider;

const Tooltip = TooltipPrimitive.Root;

const TooltipTrigger = TooltipPrimitive.Trigger;

const TooltipContent = React.forwardRef<
React.ElementRef<typeof TooltipPrimitive.Content>,
React.ComponentPropsWithoutRef<typeof TooltipPrimitive.Content>
>(({ className, sideOffset = 4, ...props }, ref) => (
<TooltipPrimitive.Content
ref={ref}
sideOffset={sideOffset}
className={cn(
'z-50 overflow-hidden rounded-md border bg-popover bg-white px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2',
className
)}
{...props}
/>
));
TooltipContent.displayName = TooltipPrimitive.Content.displayName;

export { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger };
12 changes: 5 additions & 7 deletions apps/payment-ui/src/components/PayToLabel/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
getPaymentDetails,
getProductDetails,
} from '@/features/payment-details/paymentDetailsSlice';
import Image from 'next/image';
import { useEffect, useState } from 'react';
import { useSelector } from 'react-redux';
import { CartAmountDisplay, CartAmountLoading } from './CartAmountDisplay';
Expand Down Expand Up @@ -53,7 +54,6 @@ export const PayToLabel = () => {
}
}

const hasProductDetails = productDetails.length > 0;
const showTierDiscount =
loyaltyDetails?.loyaltyProgram === 'tiers' && customerTier && discount > 0 && customer.customerOwns;
const showTierUpgrade =
Expand All @@ -79,10 +79,8 @@ export const PayToLabel = () => {
return (
<div>
<div className="flex flex-col justify-between space-y-5">
{/* <PayToDisplay merchantName={paymentDetails.merchantDisplayName} /> */}
<PayToDisplay merchantName={'Merchant Store'} />
{/* <PayAmountTokensDisplay amount={calculateFinalAmount()} /> */}
<PayAmountTokensDisplay amount={420.69} />
<PayToDisplay merchantName={paymentDetails.merchantDisplayName} />
<PayAmountTokensDisplay amount={calculateFinalAmount()} />
{loyaltyDetails?.points.pointsBack && loyaltyDetails?.loyaltyProgram === 'points' && (
<div className="flex flex-row space-x-1">
<p className="">Points Back</p>
Expand All @@ -92,7 +90,7 @@ export const PayToLabel = () => {
</div>
)}

{/* {hasProductDetails && (
{productDetails.length > 0 && (
<div>
<p className="">NFT Rewards</p>
<div className="flex flex-row ">
Expand All @@ -111,7 +109,7 @@ export const PayToLabel = () => {
)}
</div>
</div>
)} */}
)}
</div>
<div className="flex flex-col w-full mt-2">
<div className="divider" />
Expand Down
2 changes: 1 addition & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5159,7 +5159,7 @@
"@radix-ui/react-use-layout-effect" "1.0.1"
"@radix-ui/react-visually-hidden" "1.0.3"

"@radix-ui/react-tooltip@^1.0.5":
"@radix-ui/react-tooltip@^1.0.6":
version "1.0.6"
resolved "https://registry.yarnpkg.com/@radix-ui/react-tooltip/-/react-tooltip-1.0.6.tgz#87a7786cd9f2b4de957ac645afae1575339c58b0"
integrity sha512-DmNFOiwEc2UDigsYj6clJENma58OelxD24O4IODoZ+3sQc3Zb+L8w1EP+y9laTuKCLAysPw4fD6/v0j4KNV8rg==
Expand Down

3 comments on commit 7db0d96

@vercel
Copy link

@vercel vercel bot commented on 7db0d96 Aug 20, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on 7db0d96 Aug 20, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on 7db0d96 Aug 20, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.