@@ -49,6 +49,7 @@ import { TopUpModal } from "../stream-creation/TopUpModal";
4949import { CancelConfirmModal } from "../stream-creation/CancelConfirmModal" ;
5050import { StreamDetailsModal } from "./StreamDetailsModal" ;
5151import { Button } from "../ui/Button" ;
52+ import LiveCounter from "@/components/Livecounter" ;
5253
5354// ─── Types ────────────────────────────────────────────────────────────────────
5455
@@ -475,6 +476,40 @@ export function DashboardView({ session, onDisconnect }: DashboardViewProps) {
475476 const [ snapshot , setSnapshot ] = React . useState < DashboardSnapshot | null > ( null ) ;
476477 const [ isSnapshotLoading , setIsSnapshotLoading ] = React . useState ( true ) ;
477478 const [ snapshotError , setSnapshotError ] = React . useState < string | null > ( null ) ;
479+ const [ pausedStreamsData , setPausedStreamsData ] = React . useState < Stream [ ] > ( [ ] ) ;
480+ const [ isPausedLoading , setIsPausedLoading ] = React . useState ( false ) ;
481+
482+ React . useEffect ( ( ) => {
483+ if ( activeTab === "paused" ) {
484+ setIsPausedLoading ( true ) ;
485+ const baseUrl = process . env . NEXT_PUBLIC_API_URL || "http://localhost:3001" ;
486+ const endpoints = [
487+ `${ baseUrl } /v1/streams?status=paused&sender=${ session . publicKey } ` ,
488+ `${ baseUrl } /v1/streams?status=paused&recipient=${ session . publicKey } `
489+ ] ;
490+ Promise . all ( endpoints . map ( ep => fetch ( ep ) . then ( res => res . ok ? res . json ( ) : [ ] ) ) )
491+ . then ( ( [ outPaused , inPaused ] ) => {
492+ const allPaused = [ ...outPaused , ...inPaused ] . map ( ( s : any ) => ( {
493+ id : s . streamId ?. toString ( ) || s . id ,
494+ recipient : s . recipient || s . sender ,
495+ amount : s . depositedAmount ? parseFloat ( s . depositedAmount ) / 1e7 : s . amount ,
496+ token : "TOKEN" ,
497+ status : "Paused" ,
498+ deposited : s . depositedAmount ? parseFloat ( s . depositedAmount ) / 1e7 : s . deposited ,
499+ withdrawn : s . withdrawnAmount ? parseFloat ( s . withdrawnAmount ) / 1e7 : s . withdrawn ,
500+ date : s . startTime ? new Date ( s . startTime * 1000 ) . toISOString ( ) . split ( "T" ) [ 0 ] : s . date ,
501+ ratePerSecond : s . ratePerSecond ? parseFloat ( s . ratePerSecond ) / 1e7 : s . ratePerSecond ,
502+ lastUpdateTime : s . lastUpdateTime ,
503+ isActive : false ,
504+ isPaused : true ,
505+ pausedAt : s . pausedAt
506+ } ) ) ;
507+ setPausedStreamsData ( allPaused ) ;
508+ } )
509+ . catch ( console . error )
510+ . finally ( ( ) => setIsPausedLoading ( false ) ) ;
511+ }
512+ } , [ activeTab , session . publicKey ] ) ;
478513
479514 const safeLoadTemplates = ( ) : StreamTemplate [ ] => {
480515 try {
@@ -798,10 +833,13 @@ export function DashboardView({ session, onDisconnect }: DashboardViewProps) {
798833
799834 // ── Paused ────────────────────────────────────────────────────────────
800835 if ( activeTab === "paused" ) {
801- const pausedStreams = [
836+ const pausedStreams = pausedStreamsData . length > 0 ? pausedStreamsData : [
802837 ...snapshot ! . outgoingStreams . filter ( ( s ) => s . status === "Paused" ) ,
803838 ...snapshot ! . incomingStreams . filter ( ( s ) => s . status === "Paused" ) ,
804839 ] ;
840+ if ( isPausedLoading ) {
841+ return < div className = "mt-8 text-center text-slate-400" > Loading paused streams...</ div > ;
842+ }
805843 if ( pausedStreams . length === 0 ) {
806844 return (
807845 < div className = "glass-card p-12 rounded-3xl border-slate-800 text-center text-slate-400 mt-8" >
@@ -822,14 +860,15 @@ export function DashboardView({ session, onDisconnect }: DashboardViewProps) {
822860 </ thead >
823861 < tbody >
824862 { pausedStreams . map ( ( s ) => (
825- < tr key = { s . id } >
863+ < tr key = { s . id } className = "grayscale opacity-75" >
826864 < td > #{ s . id } </ td >
827865 < td className = "font-mono text-xs" > { s . recipient } </ td >
828866 < td > { s . token } </ td >
829- < td >
867+ < td className = "flex items-center gap-2" >
830868 < span className = "px-2 py-1 rounded-full bg-yellow-500/10 text-yellow-500 text-xs font-bold" >
831869 Paused
832870 </ span >
871+ < LiveCounter initial = { 0 } isPaused = { ( s as any ) . isPaused || true } pausedAt = { ( s as any ) . pausedAt } />
833872 </ td >
834873 </ tr >
835874 ) ) }
0 commit comments