@@ -72,18 +72,27 @@ class RepeatButton extends Component {
7272 < FormControl
7373 componentClass = "select"
7474 value = { repeat . from }
75- onChange = { event => setRepeat ( {
76- ...repeat ,
77- from : parseInt ( event . target . value , 10 ) ,
78- to : parseInt ( event . target . value , 10 ) + 3
79- } ) }
75+ onChange = { ( event ) => {
76+ let to = parseInt ( event . target . value , 10 ) + 3 ;
77+ to = to < surah . ayat ? to : surah . ayat ;
78+ setRepeat ( {
79+ ...repeat ,
80+ from : parseInt ( event . target . value , 10 ) ,
81+ to
82+ } ) ;
83+ } }
8084 >
8185 {
82- array . map ( ( ayah , index ) => (
83- < option key = { index } value = { index + 1 } >
84- { index + 1 }
85- </ option >
86- ) )
86+ array . reduce ( ( options , ayah , index ) => {
87+ if ( index + 1 < surah . ayat ) { // Exclude last verse
88+ options . push (
89+ < option key = { index } value = { index + 1 } >
90+ { index + 1 }
91+ </ option >
92+ ) ;
93+ }
94+ return options ;
95+ } , [ ] )
8796 }
8897 </ FormControl >
8998 </ li >
@@ -100,11 +109,16 @@ class RepeatButton extends Component {
100109 onChange = { event => setRepeat ( { ...repeat , to : parseInt ( event . target . value , 10 ) } ) }
101110 >
102111 {
103- array . map ( ( ayah , index ) => (
104- < option key = { index } value = { repeat . from ? index + 1 + repeat . from : index + 1 } >
105- { repeat . from ? index + 1 + repeat . from : index + 1 }
106- </ option >
107- ) )
112+ array . reduce ( ( options , ayah , index ) => {
113+ if ( ( repeat . from ? repeat . from : 1 ) < index + 1 && index + 1 <= surah . ayat ) {
114+ options . push (
115+ < option key = { index } value = { index + 1 } >
116+ { index + 1 }
117+ </ option >
118+ ) ;
119+ }
120+ return options ;
121+ } , [ ] )
108122 }
109123 </ FormControl >
110124 </ li >
0 commit comments