@@ -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 {
@@ -804,10 +839,13 @@ export function DashboardView({ session, onDisconnect }: DashboardViewProps) {
804839
805840 // ── Paused ────────────────────────────────────────────────────────────
806841 if ( activeTab === "paused" ) {
807- const pausedStreams = [
842+ const pausedStreams = pausedStreamsData . length > 0 ? pausedStreamsData : [
808843 ...snapshot ! . outgoingStreams . filter ( ( s ) => s . status === "Paused" ) ,
809844 ...snapshot ! . incomingStreams . filter ( ( s ) => s . status === "Paused" ) ,
810845 ] ;
846+ if ( isPausedLoading ) {
847+ return < div className = "mt-8 text-center text-slate-400" > Loading paused streams...</ div > ;
848+ }
811849 if ( pausedStreams . length === 0 ) {
812850 return (
813851 < div className = "glass-card p-12 rounded-3xl border-slate-800 text-center text-slate-400 mt-8" >
@@ -828,14 +866,15 @@ export function DashboardView({ session, onDisconnect }: DashboardViewProps) {
828866 </ thead >
829867 < tbody >
830868 { pausedStreams . map ( ( s ) => (
831- < tr key = { s . id } >
869+ < tr key = { s . id } className = "grayscale opacity-75" >
832870 < td > #{ s . id } </ td >
833871 < td className = "font-mono text-xs" > { s . recipient } </ td >
834872 < td > { s . token } </ td >
835- < td >
873+ < td className = "flex items-center gap-2" >
836874 < span className = "px-2 py-1 rounded-full bg-yellow-500/10 text-yellow-500 text-xs font-bold" >
837875 Paused
838876 </ span >
877+ < LiveCounter initial = { 0 } isPaused = { ( s as any ) . isPaused || true } pausedAt = { ( s as any ) . pausedAt } />
839878 </ td >
840879 </ tr >
841880 ) ) }
0 commit comments