@@ -4,7 +4,7 @@ import { Swipeable } from 'react-native-gesture-handler';
44import { Text } from 'react-native-paper' ;
55import { MaterialCommunityIcons } from '@expo/vector-icons' ;
66import Animated , { FadeInDown } from 'react-native-reanimated' ;
7- import type { ExpenseDto , GroupMemberSummaryDto } from '@fairshare/shared-types' ;
7+ import type { ExpenseDto , GroupMemberSummaryDto , GroupDto } from '@fairshare/shared-types' ;
88import { groupService } from '../services/group.service' ;
99import { expenseService } from '../services/expense.service' ;
1010import { realtimeService } from '../services/realtime.service' ;
@@ -35,6 +35,7 @@ export function GroupDetailScreen({
3535 const [ loading , setLoading ] = React . useState ( true ) ;
3636 const [ balances , setBalances ] = React . useState < Array < { id : string ; amountCents : string ; userId : string ; counterpartyUserId : string } > > ( [ ] ) ;
3737 const [ members , setMembers ] = React . useState < GroupMemberSummaryDto [ ] > ( [ ] ) ;
38+ const [ group , setGroup ] = React . useState < GroupDto | null > ( null ) ;
3839 const [ summary , setSummary ] = React . useState < {
3940 totalExpensesCents : string ;
4041 topSpenderUserId : string | null ;
@@ -52,15 +53,17 @@ export function GroupDetailScreen({
5253 const load = React . useCallback ( async ( ) => {
5354 startScreenLoad ( 'GroupDetail' ) ;
5455 try {
55- const [ expenseData , balanceData , memberData ] = await Promise . all ( [
56+ const [ expenseData , balanceData , memberData , groupData ] = await Promise . all ( [
5657 expenseService . list ( route . params . groupId ) ,
5758 groupService . balances ( route . params . groupId ) ,
5859 groupService . members ( route . params . groupId ) ,
60+ groupService . get ( route . params . groupId ) ,
5961 ] ) ;
6062 const summaryData = await groupService . summary ( route . params . groupId ) ;
6163 setExpenses ( route . params . groupId , expenseData . items ) ;
6264 setBalances ( balanceData ) ;
6365 setMembers ( memberData ) ;
66+ setGroup ( groupData ) ;
6467 setSummary ( {
6568 totalExpensesCents : summaryData . totalExpensesCents ,
6669 topSpenderUserId : summaryData . topSpenderUserId ,
@@ -135,6 +138,8 @@ export function GroupDetailScreen({
135138 const payer = memberById . get ( expense . payerId ) ;
136139 const participantCount = expense . splits ?. length ?? 0 ;
137140
141+ const symbol = group ?. currency === 'INR' ? '₹' : '$' ;
142+
138143 return (
139144 < Swipeable
140145 key = { expense . id }
@@ -149,7 +154,7 @@ export function GroupDetailScreen({
149154 >
150155 < ExpenseCard
151156 description = { expense . description }
152- amount = { `$${ ( Number ( expense . totalAmountCents ) / 100 ) . toFixed ( 2 ) } ` }
157+ amount = { `${ symbol } ${ ( Number ( expense . totalAmountCents ) / 100 ) . toFixed ( 2 ) } ` }
153158 payerName = { payer ?. name ?? 'Unknown' }
154159 payerInitials = { getInitials ( payer ?. name ?? 'U' ) }
155160 participantCount = { participantCount }
@@ -180,17 +185,21 @@ export function GroupDetailScreen({
180185 showsVerticalScrollIndicator = { false }
181186 >
182187 { /* Balance Summary */ }
183- { summary && (
188+ { summary && group && (
184189 < Animated . View entering = { FadeInDown . duration ( 400 ) } style = { styles . balanceSection } >
185190 < BalanceCard
186- title = "Total Spent "
187- amount = { `$${ ( Number ( summary . totalExpensesCents ) / 100 ) . toFixed ( 2 ) } ` }
191+ title = "Total Group Spending "
192+ amount = { `${ group . currency === 'INR' ? '₹' : '$' } ${ ( Number ( summary . totalExpensesCents ) / 100 ) . toFixed ( 2 ) } ` }
188193 icon = "cash-multiple"
189194 />
190195 < BalanceCard
191- title = "Your Balance"
192- amount = { `$${ Math . abs ( userBalance ) . toFixed ( 2 ) } ` }
193- subtitle = { userBalance > 0 ? 'You are owed' : userBalance < 0 ? 'You owe' : 'Settled up' }
196+ title = "Your Personal Balance"
197+ amount = { `${ group . currency === 'INR' ? '₹' : '$' } ${ Math . abs ( userBalance ) . toFixed ( 2 ) } ` }
198+ subtitle = {
199+ userBalance !== 0
200+ ? `${ userBalance > 0 ? 'You are owed' : 'You owe' } (${ ( ( Math . abs ( userBalance ) * 100 ) / ( Number ( summary . totalExpensesCents ) / 100 || 1 ) ) . toFixed ( 1 ) } % of total)`
201+ : 'Settled up'
202+ }
194203 variant = { userBalance > 0 ? 'success' : userBalance < 0 ? 'danger' : 'default' }
195204 icon = { userBalance >= 0 ? 'trending-up' : 'trending-down' }
196205 />
0 commit comments