|
|
|
@ -1,12 +1,11 @@ |
|
|
|
|
|
|
|
import { Button } from '@/components/ui/button' |
|
|
|
|
|
|
|
import { useToast } from '@/hooks' |
|
|
|
import { formatAmount, getAmountFromInvoice } from '@/lib/lightning' |
|
|
|
import { formatAmount, getAmountFromInvoice } from '@/lib/lightning' |
|
|
|
import { cn } from '@/lib/utils' |
|
|
|
|
|
|
|
import { useNostr } from '@/providers/NostrProvider' |
|
|
|
import { useNostr } from '@/providers/NostrProvider' |
|
|
|
import { useToast } from '@/hooks' |
|
|
|
|
|
|
|
import { Loader, Zap } from 'lucide-react' |
|
|
|
|
|
|
|
import lightning from '@/services/lightning.service' |
|
|
|
import lightning from '@/services/lightning.service' |
|
|
|
|
|
|
|
import { Loader, Zap } from 'lucide-react' |
|
|
|
import { useMemo, useState } from 'react' |
|
|
|
import { useMemo, useState } from 'react' |
|
|
|
import { useTranslation } from 'react-i18next' |
|
|
|
import { useTranslation } from 'react-i18next' |
|
|
|
import { Button } from '@/components/ui/button' |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export function EmbeddedLNInvoice({ invoice }: { invoice: string }) { |
|
|
|
export function EmbeddedLNInvoice({ invoice }: { invoice: string }) { |
|
|
|
const { t } = useTranslation() |
|
|
|
const { t } = useTranslation() |
|
|
|
@ -47,37 +46,19 @@ export function EmbeddedLNInvoice({ invoice }: { invoice: string }) { |
|
|
|
|
|
|
|
|
|
|
|
return ( |
|
|
|
return ( |
|
|
|
<div |
|
|
|
<div |
|
|
|
className={cn( |
|
|
|
className="p-2 sm:p-3 border rounded-lg cursor-default flex flex-col gap-3 max-w-sm" |
|
|
|
'border rounded-lg p-4 bg-card text-card-foreground shadow-sm', |
|
|
|
|
|
|
|
'flex flex-col gap-3 my-2 max-w-sm' |
|
|
|
|
|
|
|
)} |
|
|
|
|
|
|
|
onClick={(e) => e.stopPropagation()} |
|
|
|
onClick={(e) => e.stopPropagation()} |
|
|
|
> |
|
|
|
> |
|
|
|
<div className="flex items-center gap-2"> |
|
|
|
<div className="flex items-center gap-2"> |
|
|
|
<Zap className="w-5 h-5 text-yellow-500" /> |
|
|
|
<Zap className="w-5 h-5 text-yellow-400" /> |
|
|
|
<h3 className="font-semibold text-sm">Lightning Invoice</h3> |
|
|
|
<div className="font-semibold text-sm">{t('Lightning Invoice')}</div> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
<div className="text-lg font-bold"> |
|
|
|
<div className="text-lg font-bold"> |
|
|
|
{formatAmount(amount)} |
|
|
|
{formatAmount(amount)} {t('sats')} |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
<Button
|
|
|
|
<Button onClick={handlePayClick}> |
|
|
|
className={cn( |
|
|
|
{paying && <Loader className="w-4 h-4 animate-spin" />} |
|
|
|
'w-full px-4 py-2 rounded-md font-medium text-sm', |
|
|
|
{t('Pay')} |
|
|
|
'bg-purple-600 hover:bg-purple-700 text-white', |
|
|
|
|
|
|
|
'disabled:opacity-50 disabled:cursor-not-allowed', |
|
|
|
|
|
|
|
'transition-colors duration-200', |
|
|
|
|
|
|
|
'flex items-center justify-center gap-2' |
|
|
|
|
|
|
|
)} |
|
|
|
|
|
|
|
onClick={handlePayClick} |
|
|
|
|
|
|
|
> |
|
|
|
|
|
|
|
{paying ? ( |
|
|
|
|
|
|
|
<> |
|
|
|
|
|
|
|
<Loader className="w-4 h-4 animate-spin" /> |
|
|
|
|
|
|
|
Paying... |
|
|
|
|
|
|
|
</> |
|
|
|
|
|
|
|
) : ( |
|
|
|
|
|
|
|
'Pay' |
|
|
|
|
|
|
|
)} |
|
|
|
|
|
|
|
</Button> |
|
|
|
</Button> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
) |
|
|
|
) |
|
|
|
|