@@ -33,7 +33,7 @@ export const SplitTypeSection: React.FC = () => {
3333 const splitScreenOpen = useAddExpenseStore ( ( s ) => s . splitScreenOpen ) ;
3434 const splitShares = useAddExpenseStore ( ( s ) => s . splitShares ) ;
3535
36- const { setPaidBy , setSplitScreenOpen } = useAddExpenseStore ( ( s ) => s . actions ) ;
36+ const { setSplitScreenOpen } = useAddExpenseStore ( ( s ) => s . actions ) ;
3737
3838 return (
3939 < div className = "flex items-center justify-center text-[16px] text-gray-400 sm:mt-4" >
@@ -52,17 +52,11 @@ export const SplitTypeSection: React.FC = () => {
5252 >
5353 < div className = "flex flex-col gap-6 overflow-auto" >
5454 { participants . map ( ( participant ) => (
55- < DrawerClose
55+ < PayerRow
5656 key = { participant . id }
57- className = "flex items-center justify-between px-2"
58- onClick = { ( ) => setPaidBy ( participant ) }
59- >
60- < div className = "flex items-center gap-1" >
61- < EntityAvatar entity = { participant } size = { 30 } />
62- < p className = "ml-4" > { displayName ( participant , currentUser ?. id ) } </ p >
63- </ div >
64- { participant . id === paidBy ?. id ? < Check className = "h-6 w-6 text-cyan-500" /> : null }
65- </ DrawerClose >
57+ p = { participant }
58+ isPaying = { participant . id === paidBy ?. id }
59+ />
6660 ) ) }
6761 </ div >
6862 </ AppDrawer >
@@ -78,7 +72,7 @@ export const SplitTypeSection: React.FC = () => {
7872 ) }
7973 className = "h-[85vh] lg:h-[70vh]"
8074 shouldCloseOnAction
81- dismissible = { false }
75+ dismissible = { canSplitScreenClosed }
8276 actionTitle = { t ( 'ui.actions.save' , { ns : 'common' } ) }
8377 actionDisabled = { ! canSplitScreenClosed }
8478 open = { splitScreenOpen }
@@ -90,6 +84,24 @@ export const SplitTypeSection: React.FC = () => {
9084 ) ;
9185} ;
9286
87+ const PayerRow = ( { p, isPaying } : { p : Participant ; isPaying : boolean } ) => {
88+ const { displayName } = useTranslationWithUtils ( ) ;
89+ const currentUser = useAddExpenseStore ( ( s ) => s . currentUser ) ;
90+ const { setPaidBy } = useAddExpenseStore ( ( s ) => s . actions ) ;
91+
92+ const onClick = useCallback ( ( ) => setPaidBy ( p ) , [ p , setPaidBy ] ) ;
93+
94+ return (
95+ < DrawerClose className = "flex items-center justify-between px-2" onClick = { onClick } >
96+ < div className = "flex items-center gap-1" >
97+ < EntityAvatar entity = { p } size = { 30 } />
98+ < p className = "ml-4" > { displayName ( p , currentUser ?. id ) } </ p >
99+ </ div >
100+ { isPaying ? < Check className = "h-6 w-6 text-cyan-500" /> : null }
101+ </ DrawerClose >
102+ ) ;
103+ } ;
104+
93105const SplitExpenseForm : React . FC = ( ) => {
94106 const { t } = useTranslation ( 'expense_details' ) ;
95107 const splitType = useAddExpenseStore ( ( s ) => s . splitType ) ;
0 commit comments