@@ -8,6 +8,9 @@ import ForegroundStrategy from './SEBankIDSameDeviceButton/Foreground';
88import ReloadStrategy from './SEBankIDSameDeviceButton/Reload' ;
99
1010import { autoHydratedState , type Links } from './SEBankIDSameDeviceButton/shared' ;
11+ import { AuthButtonGroupContext } from './AuthButtonGroup' ;
12+ import classNames from 'classnames' ;
13+ import { Spinner } from './Spinner/Spinner' ;
1114
1215interface Props {
1316 className : string ;
@@ -78,6 +81,8 @@ async function fetchComplete(completeUrl: string) {
7881}
7982export default function SEBankIDSameDeviceButton ( props : Props ) {
8083 const { loginHint } = useContext ( CriiptoVerifyContext ) ;
84+ const group = useContext ( AuthButtonGroupContext ) ;
85+
8186 const rawUserAgent = typeof navigator !== 'undefined' ? navigator . userAgent : props . userAgent ;
8287 const strategy = useMemo (
8388 ( ) => determineStrategy ( rawUserAgent , loginHint ) ,
@@ -100,6 +105,8 @@ export default function SEBankIDSameDeviceButton(props: Props) {
100105 } = useContext ( CriiptoVerifyContext ) ;
101106 const redirectUri = props . redirectUri || defaultRedirectURi ;
102107
108+ const disabled = group . disabled || initiated ;
109+
103110 const reset = ( ) => {
104111 setPKCE ( undefined ) ;
105112 setLinks ( null ) ;
@@ -211,12 +218,14 @@ export default function SEBankIDSameDeviceButton(props: Props) {
211218
212219 // Track when the button is clicked to stop refreshing URL
213220 const handleInitiate = ( ) => {
221+ group . setDisabled ( true ) ;
214222 handleLog ( 'Initiated' ) ;
215223 setInitiated ( true ) ;
216224 setError ( null ) ;
217225 } ;
218226
219227 const handleError = async ( error : string ) => {
228+ group . setDisabled ( false ) ;
220229 setInitiated ( false ) ;
221230 setError ( error ) ;
222231
@@ -236,13 +245,13 @@ export default function SEBankIDSameDeviceButton(props: Props) {
236245
237246 const element = href ? (
238247 < a
239- className = { ` ${ props . className } ${ initiated ? 'criipto-eid-btn--disabled' : '' } ` }
248+ className = { classNames ( props . className , { 'criipto-eid-btn--disabled' : disabled } ) }
240249 href = { href }
241250 onClick = { handleInitiate }
242251 >
243252 { initiated ? (
244253 < div className = "criipto-eid-logo" >
245- < div className = "criipto-eid-loader" > </ div >
254+ < Spinner / >
246255 </ div >
247256 ) : (
248257 props . logo
0 commit comments