fix: implement comprehensive bug fixes across multiple components\n\nFix chat, tasks, ops, import, and PayPal components for full functionality.
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
'use client'
|
||||
|
||||
import { useState } from 'react'
|
||||
import { X } from 'lucide-react'
|
||||
import { X, RefreshCcw } from 'lucide-react'
|
||||
import { toast } from 'sonner'
|
||||
import { logCashPayment, linkPaymentToMember } from '@/lib/actions'
|
||||
|
||||
interface Payment {
|
||||
@@ -59,6 +60,26 @@ export function PaymentsClient({ payments: initialPayments, members, integration
|
||||
|
||||
const unlinkedCount = payments.filter(p => p.link_status === 'unlinked').length
|
||||
|
||||
const [syncing, setSyncing] = useState(false)
|
||||
|
||||
async function handlePayPalSync() {
|
||||
setSyncing(true)
|
||||
try {
|
||||
const res = await fetch('/api/paypal/sync', { method: 'POST' })
|
||||
const data = await res.json()
|
||||
if (!res.ok) { toast.error(data.error ?? 'Sync failed'); return }
|
||||
toast.success(`PayPal sync complete: ${data.imported} transactions imported`)
|
||||
if (data.imported > 0) {
|
||||
// Reload page to show new transactions
|
||||
window.location.reload()
|
||||
}
|
||||
} catch {
|
||||
toast.error('PayPal sync failed')
|
||||
} finally {
|
||||
setSyncing(false)
|
||||
}
|
||||
}
|
||||
|
||||
async function handleLogCash(e: React.FormEvent) {
|
||||
e.preventDefault()
|
||||
setLoading(true)
|
||||
@@ -137,9 +158,18 @@ export function PaymentsClient({ payments: initialPayments, members, integration
|
||||
<span className={`font-mono text-[10px] px-1.5 py-0.5 rounded border ${
|
||||
integration?.is_connected ? 'text-primary border-primary/30 bg-primary/5' : 'text-muted-foreground border-border bg-muted'
|
||||
}`}>
|
||||
{integration?.is_connected ? 'LIVE' : 'NOT CONNECTED'}
|
||||
</span>
|
||||
)}
|
||||
{integration?.is_connected ? 'LIVE' : 'NOT CONNECTED'}
|
||||
</span>
|
||||
)}
|
||||
{platform === 'paypal' && integration?.is_connected && canEdit(currentRole) && (
|
||||
<button
|
||||
onClick={handlePayPalSync}
|
||||
disabled={syncing}
|
||||
className="flex items-center gap-1 font-mono text-[10px] border border-blue-300 text-blue-600 bg-blue-50 px-2 py-0.5 rounded hover:bg-blue-100 transition disabled:opacity-50"
|
||||
>
|
||||
<RefreshCcw className={`w-2.5 h-2.5 ${syncing ? 'animate-spin' : ''}`} />
|
||||
{syncing ? 'Syncing...' : 'Sync Now'}
|
||||
</button>
|
||||
</div>
|
||||
<p className="text-2xl font-sans font-bold text-foreground">${total.toFixed(0)}</p>
|
||||
<p className="font-mono text-[10px] text-muted-foreground mt-1">
|
||||
|
||||
Reference in New Issue
Block a user