@@ -21,11 +21,12 @@ import { getStellarExplorerTxUrl } from '@/lib/utils/explorer';
2121import { EmptyState } from '@/components/shared' ;
2222import { ErrorDisplay } from '@/components/shared' ;
2323import { useOfflineStore } from '@/lib/store/offlineStore' ;
24+ import { useAuthStore } from '@/lib/store/authStore' ;
2425import { SettlementConfirmation } from '@/components/settlement/SettlementConfirmation' ;
2526import { InvoiceDownloadButton , BatchInvoiceDownload } from '@/components/settlement/InvoiceGenerator' ;
2627import { StatCard } from '@/components/shared' ;
2728import { memo } from 'react' ;
28- import { useSettlements , type ApiSettlement } from '@/lib/api/hooks' ;
29+ import { useSettlements , useMerchantBankAccount , type ApiSettlement } from '@/lib/api/hooks' ;
2930
3031type Settlement = ApiSettlement ;
3132
@@ -70,6 +71,8 @@ const SettlementItem = memo(function SettlementItem({ settlement: s }: Settlemen
7071export default function SettlementPage ( ) {
7172 const { data : settlements , isLoading, error : fetchError , refetch } = useSettlements ( ) ;
7273 const [ settlementsError , setSettlementsError ] = useState ( false ) ;
74+ const { user } = useAuthStore ( ) ;
75+ const { data : bankAccount , isLoading : bankLoading } = useMerchantBankAccount ( user ?. id ) ;
7376 const isOnline = useOfflineStore ( ( s ) => s . isOnline ) ;
7477 const [ settlementOpen , setSettlementOpen ] = useState ( false ) ;
7578
@@ -184,20 +187,35 @@ export default function SettlementPage() {
184187 </ Card >
185188
186189 { /* Bank account config notice */ }
187- < Card className = "border border-primary/30 bg-primary/10" >
188- < CardContent className = "flex items-start gap-4 p-5" >
189- < AlertCircle className = "w-5 h-5 text-primary mt-0.5 flex-shrink-0" />
190- < div className = "flex-1" >
191- < p className = "text-sm font-semibold text-primary" > Bank account not configured</ p >
192- < p className = "text-xs text-primary mt-0.5" >
193- Add your Nigerian bank account in Settings to enable automatic settlements.
194- </ p >
195- </ div >
196- < Button variant = "ghost" className = "text-primary hover:bg-primary/20 rounded-xl text-xs h-8 px-3 flex-shrink-0" >
197- Go to Settings < ChevronRight className = "w-3 h-3 ml-1" />
198- </ Button >
199- </ CardContent >
200- </ Card >
190+ { ! bankLoading && ! bankAccount && (
191+ < Card className = "border border-primary/30 bg-primary/10" >
192+ < CardContent className = "flex items-start gap-4 p-5" >
193+ < AlertCircle className = "w-5 h-5 text-primary mt-0.5 flex-shrink-0" />
194+ < div className = "flex-1" >
195+ < p className = "text-sm font-semibold text-primary" > Bank account not configured</ p >
196+ < p className = "text-xs text-primary mt-0.5" >
197+ Add your Nigerian bank account in Settings to enable automatic settlements.
198+ </ p >
199+ </ div >
200+ < Button variant = "ghost" className = "text-primary hover:bg-primary/20 rounded-xl text-xs h-8 px-3 flex-shrink-0" >
201+ Go to Settings < ChevronRight className = "w-3 h-3 ml-1" />
202+ </ Button >
203+ </ CardContent >
204+ </ Card >
205+ ) }
206+ { ! bankLoading && bankAccount && (
207+ < Card className = "border border-success/30 bg-success/5" >
208+ < CardContent className = "flex items-start gap-4 p-5" >
209+ < CheckCircle2 className = "w-5 h-5 text-success mt-0.5 flex-shrink-0" />
210+ < div className = "flex-1" >
211+ < p className = "text-sm font-semibold text-success" > Bank account configured</ p >
212+ < p className = "text-xs text-muted-foreground mt-0.5" >
213+ { bankAccount . bankName } · { '\u2022' . repeat ( Math . max ( 0 , bankAccount . accountNumber . length - 4 ) ) } { bankAccount . accountNumber . slice ( - 4 ) }
214+ </ p >
215+ </ div >
216+ </ CardContent >
217+ </ Card >
218+ ) }
201219 </ div >
202220 ) ;
203221}
0 commit comments