@@ -77,6 +77,7 @@ function Login(props: LoginProps) {
7777 const [ canShowMore , setCanShowMore ] = useState ( false ) ;
7878 const [ visibleRow , setVisibleRow ] = useState < rowType [ ] > ( [ ] ) ;
7979 const [ otherRow , setOtherRow ] = useState < rowType [ ] > ( [ ] ) ;
80+ const [ mainOptionsRow , setMainOptionsRow ] = useState < rowType [ ] > ( [ ] ) ;
8081 const [ isPasswordLessCtaClicked , setIsPasswordLessCtaClicked ] = useState ( false ) ;
8182 const [ showOtpFlow , setShowOtpFlow ] = useState ( false ) ;
8283 const [ authConnection , setAuthConnection ] = useState < AUTH_CONNECTION_TYPE | undefined > ( undefined ) ;
@@ -100,6 +101,7 @@ function Login(props: LoginProps) {
100101
101102 const visibleRows : rowType [ ] = [ ] ;
102103 const otherRows : rowType [ ] = [ ] ;
104+ const mainOptionsRows : rowType [ ] = [ ] ;
103105
104106 const loginMethodsOrder = ( socialLoginsConfig . loginMethodsOrder || [ ] ) . reduce (
105107 ( acc , method , index ) => {
@@ -140,51 +142,43 @@ function Login(props: LoginProps) {
140142 const order = index + 1 ;
141143
142144 const isPrimaryBtn = socialLoginsConfig ?. uiConfig ?. primaryButton === "socialLogin" && order === 1 ;
145+ const isMainOption = connectorConfig . mainOption ;
143146
144147 const loginOptionLength = loginOptions . length ;
145148 const moreThanFour = loginOptionLength >= 4 ;
146149
147150 const lengthCheck = moreThanFour ? order > 0 && order <= loginOptionLength : order > 0 && order < 4 ;
148151
149- if ( lengthCheck ) {
150- visibleRows . push ( {
151- method,
152- isDark,
153- isPrimaryBtn,
154- name,
155- connector : socialLoginsConfig . connector ,
156- loginParams : {
157- authConnection : connectorConfig . authConnection || ( method as AUTH_CONNECTION_TYPE ) ,
158- authConnectionId : connectorConfig . authConnectionId ,
159- groupedAuthConnectionId : connectorConfig . groupedAuthConnectionId ,
160- extraLoginOptions : connectorConfig . extraLoginOptions ,
161- name,
162- login_hint : "" ,
163- } ,
164- order,
165- } ) ;
166- }
167-
168- otherRows . push ( {
152+ const rows = {
153+ description : connectorConfig . description || "" ,
169154 method,
170155 isDark,
171156 isPrimaryBtn,
172157 name : name === "Twitter" ? "X" : name ,
173158 connector : socialLoginsConfig . connector ,
174159 loginParams : {
175- authConnection : method as AUTH_CONNECTION_TYPE ,
160+ authConnection : connectorConfig . authConnection || ( method as AUTH_CONNECTION_TYPE ) ,
176161 authConnectionId : connectorConfig . authConnectionId ,
177162 groupedAuthConnectionId : connectorConfig . groupedAuthConnectionId ,
178163 extraLoginOptions : connectorConfig . extraLoginOptions ,
179164 name,
180165 login_hint : "" ,
181166 } ,
182167 order,
183- } ) ;
168+ } ;
169+
170+ if ( isMainOption ) {
171+ mainOptionsRows . push ( rows ) ;
172+ } else if ( lengthCheck ) {
173+ visibleRows . push ( rows ) ;
174+ }
175+
176+ otherRows . push ( rows ) ;
184177 } ) ;
185178
186179 setVisibleRow ( visibleRows ) ;
187180 setOtherRow ( otherRows ) ;
181+ setMainOptionsRow ( mainOptionsRows ) ;
188182 setCanShowMore ( maxOptions . length > 4 ) ; // Update the state based on the condition
189183 } , [ socialLoginsConfig , isDark , buttonRadius ] ) ;
190184
@@ -432,6 +426,7 @@ function Login(props: LoginProps) {
432426 isDark = { isDark }
433427 visibleRow = { visibleRow }
434428 canShowMore = { canShowMore }
429+ mainOptionsRow = { mainOptionsRow }
435430 handleSocialLoginClick = { handleSocialLoginClick }
436431 socialLoginsConfig = { socialLoginsConfig }
437432 handleExpandSocialLogins = { handleSocialLoginExpand }
0 commit comments