import React from 'react'; import { db } from '@/lib/db'; import { Wallet, ExternalLink, Clock, ArrowUpRight, Search } from 'lucide-react'; import { format } from 'date-fns'; import { tr } from 'date-fns/locale'; import { cookies } from 'next/headers'; import { redirect } from 'next/navigation'; import Link from 'next/link'; async function getMerchantPayouts(identifier: string) { const isUUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(identifier); let resolvedId = identifier; if (!isUUID) { const result = await db.query('SELECT id FROM merchants WHERE short_id = $1 LIMIT 1', [identifier]); const merchant = result.rows[0]; if (merchant) { resolvedId = merchant.id; } } try { const { rows } = await db.query(` SELECT * FROM payouts WHERE merchant_id = $1 ORDER BY created_at DESC `, [resolvedId]); return { payouts: rows, merchantId: resolvedId }; } catch (error) { console.error('Merchant payout history fetch error:', error); return { payouts: [], merchantId: resolvedId }; } } export default async function MerchantPayoutsPage(props: { params: Promise<{ id: string }>; }) { const resolvedParams = await props.params; const identifier = resolvedParams.id; const { payouts, merchantId } = await getMerchantPayouts(identifier); const cookieStore = await cookies(); if (!cookieStore.get(`merchant_auth_${merchantId}`)) { redirect(`/merchant/${identifier}/login`); } return (
Sistemden cüzdanınıza yapılan transfer geçmişi
Toplam Çekim
{payouts.length}
Son Çekim
{payouts.length > 0 ? format(new Date(payouts[0].created_at), 'dd MMM', { locale: tr }) : '-'}
Durum
Aktif
| Miktar & Varlık | Ağ (Network) | Hedef Adres | Tarih | Durum | Blockchain |
|---|---|---|---|---|---|
|
{Number(p.amount).toFixed(4)}
{p.currency}
|
{p.network} |
{p.destination_address.slice(0, 6)}...{p.destination_address.slice(-6)}
|
{format(new Date(p.created_at), 'dd MMM yyyy, HH:mm', { locale: tr })} | {p.status === 'succeeded' ? 'Başarılı' : 'Hatalı'} |
{p.tx_hash && p.tx_hash !== 'mock' ? (
GÖRÜNTÜLE
|
Henüz Ödeme Yapılmadı
Sistemimizden cüzdanınıza henüz bir kripto transferi gerçekleşmedi.