@@ -137,27 +137,20 @@ const SplitEqualSection: React.FC = () => {
137137 const allSelected = participants . every ( ( p ) => p . splitShare !== 0 ) ;
138138
139139 return (
140- < div className = "mt-4 flex flex-col gap-6 px-2 relative " >
140+ < div className = "relative mt-4 flex flex-col gap-6 px-2" >
141141 < div className = "flex items-center" >
142- < div className = "mb-2 flex-grow flex justify-center" >
143- < div
144- className = { `${ canSplitScreenClosed ? 'text-gray-300' : 'text-red-500'
145- } `}
146- >
142+ < div className = "mb-2 flex flex-grow justify-center" >
143+ < div className = { `${ canSplitScreenClosed ? 'text-gray-300' : 'text-red-500' } ` } >
147144 { currency } { ( amount / totalParticipants ) . toFixed ( 2 ) } per person
148145 </ div >
149146 </ div >
150147 </ div >
151- < div className = "absolute top -0 right -0" >
148+ < div className = "absolute right -0 top -0" >
152149 < button
153- className = "flex items-center gap-1 border rounded-md py-0.5 px-2 whitespace-nowrap "
150+ className = "flex items-center gap-1 whitespace-nowrap rounded-md border px-2 py-0.5 "
154151 onClick = { selectAll }
155152 >
156- { allSelected ? (
157- < X className = "h-4 w-4" />
158- ) : (
159- < Check className = "h-4 w-4" />
160- ) }
153+ { allSelected ? < X className = "h-4 w-4" /> : < Check className = "h-4 w-4" /> }
161154 < span className = "text-sm" > All</ span >
162155 </ button >
163156 </ div >
@@ -243,7 +236,7 @@ const SplitByAmountSection: React.FC = () => {
243236 const [ splitShareValue , setSplitShareValue ] = useState (
244237 participants . reduce (
245238 ( acc , p ) => {
246- acc [ p . id ] = p . splitShare ?. toString ( ) ;
239+ acc [ p . id ] = p . splitShare ?. toString ( ) ?? '' ;
247240 return acc ;
248241 } ,
249242 { } as Record < string , string | undefined > ,
@@ -256,19 +249,20 @@ const SplitByAmountSection: React.FC = () => {
256249 addOrUpdateParticipant ( { ...p , splitShare : 0 } ) ;
257250 return ;
258251 }
259- addOrUpdateParticipant ( { ...p , splitShare : parseFloat ( value ) } ) ;
252+ const formattedValue = parseFloat ( parseFloat ( value ) . toFixed ( 2 ) ) ;
253+ addOrUpdateParticipant ( { ...p , splitShare : formattedValue } ) ;
260254 } ;
261255
262- const remainingPercentage =
263- amount - participants . reduce ( ( acc , p ) => acc + ( p . splitShare ?? 0 ) , 0 ) ;
256+ const totalSplitShare = participants . reduce ( ( acc , p ) => acc + ( p . splitShare ?? 0 ) , 0 ) ;
257+
258+ const remainingAmount = parseFloat ( ( amount - totalSplitShare ) . toFixed ( 2 ) ) ;
264259
265260 return (
266261 < div className = "mt-4 flex flex-col gap-6 px-2" >
267262 < div
268263 className = { `mb-2 text-center ${ canSplitScreenClosed ? 'text-gray-300' : 'text-red-500' } t` }
269264 >
270- { ' ' }
271- Remaining { currency } { remainingPercentage }
265+ Remaining { currency } { remainingAmount }
272266 </ div >
273267 { participants . map ( ( p ) => (
274268 < div key = { p . id } className = "flex justify-between" >
@@ -278,7 +272,6 @@ const SplitByAmountSection: React.FC = () => {
278272 </ div >
279273 < div className = "flex items-center gap-1" >
280274 < p className = "text-xs" > { currency } </ p >
281-
282275 < Input
283276 type = "number"
284277 value = { splitShareValue [ p . id ] }
0 commit comments