2023-12-15 13:10:45 +01:00
@ extends ( 'layouts.ninja' )
@ section ( 'meta_title' , ctrans ( 'texts.new_bank_account' ))
@ push ( 'head' )
< link href = " https://unpkg.com/nordigen-bank-ui@1.5.2/package/src/selector.min.css " rel = " stylesheet " />
@ endpush
@ section ( 'body' )
< div id = " institution-content-wrapper " ></ div >
@ endsection
@ push ( 'footer' )
< script type = 'text/javascript' src = 'https://unpkg.com/nordigen-bank-ui@1.5.2/package/src/selector.min.js' ></ script >
< script >
// Pass your redirect link after user has been authorized in institution
const config = {
// Redirect URL that is being used when modal is being closed.
redirectUrl : " { { $redirectUrl }} " || new URL ( " " , window . location . origin ) . href ,
// Text that will be displayed on the left side under the logo. Text is limited to 100 characters, and rest will be truncated. @turbo124 replace with a translated version like ctrans()
2023-12-15 14:45:52 +01:00
text : " { { ( $account ?? false) && ! $account->isPaid () ? 'Invoice Ninja' : (isset( $company ) && !is_null( $company ) ? $company->name : 'Invoice Ninja') }} { { ctrans('texts.nordigen_handler_subtitle', [], $lang ?? 'en') }} " ,
2023-12-15 13:10:45 +01:00
// Logo URL that will be shown below the modal form.
logoUrl : " { { ( $account ?? false) && ! $account->isPaid () ? asset('images/invoiceninja-black-logo-2.png') : (isset( $company ) && !is_null( $company ) ? $company->present ()->logo() : asset('images/invoiceninja-black-logo-2.png')) }} " ,
// Will display country list with corresponding institutions. When `countryFilter` is set to `false`, only list of institutions will be shown.
countryFilter : false ,
// style configs
styles : {
// Primary
// Link to google font
fontFamily : new URL ( " assets/fonts/Roboto-Regular.ttf " , window . location . origin ) . href ,
fontSize : '15' ,
backgroundColor : '#F2F2F2' ,
textColor : '#222' ,
headingColor : '#222' ,
linkColor : '#8d9090' ,
// Modal
modalTextColor : '#1B2021' ,
modalBackgroundColor : '#fff' ,
// Button
buttonColor : '#3A53EE' ,
buttonTextColor : '#fff'
}
};
const failedReason = " { { $failed_reason ?? '' }} " . trim ();
new institutionSelector ( @ json ( $institutions ? ? []), 'institution-modal-content' , config );
if ( ! failedReason ) {
const institutionList = Array . from ( document . querySelectorAll ( '.ob-list-institution > a' ));
institutionList . forEach (( institution ) => {
institution . addEventListener ( 'click' , ( e ) => {
e . preventDefault ()
const institutionId = institution . getAttribute ( 'data-institution' );
const url = new URL ( window . location . href );
url . searchParams . set ( 'institution_id' , institutionId );
window . location . href = url . href ;
});
});
} else {
document . getElementsByClassName ( " institution-search-container " )[ 0 ] . remove ();
document . getElementsByClassName ( " institution-container " )[ 0 ] . remove ();
const heading = document . querySelectorAll ( 'h2' )[ 0 ];
const wrapper = document . getElementById ( " institution-modal-content " );
const contents = document . createElement ( " div " );
contents . id = " failed-container " ;
contents . className = " mt-2 " ;
contents . style [ " font-size " ] = " 80% " ;
contents . style [ " opacity " ] = " 80% " ;
let restartFlow = false ; // return, restart, refresh
2023-12-15 14:45:52 +01:00
heading . innerHTML = " { { ctrans('texts.nordigen_handler_error_heading_unknown', [], $lang ?? 'en') }} " ;
contents . innerHTML = " { { ctrans('texts.nordigen_handler_error_contents_unknown', [], $lang ?? 'en') }} " + failedReason ;
2023-12-15 13:10:45 +01:00
switch ( failedReason ) {
// Connect Screen Errors
case " token-invalid " :
2023-12-15 14:45:52 +01:00
heading . innerHTML = " { { ctrans('texts.nordigen_handler_error_heading_token_invalid', [], $lang ?? 'en') }} " ;
contents . innerHTML = " { { ctrans('texts.nordigen_handler_error_contents_token_invalid', [], $lang ?? 'en') }} " ;
2023-12-15 13:10:45 +01:00
break ;
case " account-config-invalid " :
2023-12-15 14:45:52 +01:00
heading . innerHTML = " { { ctrans('texts.nordigen_handler_error_heading_account_config_invalid', [], $lang ?? 'en') }} " ;
contents . innerHTML = " { { ctrans('texts.nordigen_handler_error_contents_account_config_invalid', [], $lang ?? 'en') }} " ;
2023-12-15 13:10:45 +01:00
break ;
case " not-available " :
2023-12-15 14:45:52 +01:00
heading . innerHTML = " { { ctrans('texts.nordigen_handler_error_heading_not_available', [], $lang ?? 'en') }} " ;
contents . innerHTML = " { { ctrans('texts.nordigen_handler_error_contents_not_available', [], $lang ?? 'en') }} " ;
2023-12-15 13:10:45 +01:00
break ;
case " institution-invalid " :
restartFlow = true ;
2023-12-15 14:45:52 +01:00
heading . innerHTML = " { { ctrans('texts.nordigen_handler_error_heading_institution_invalid', [], $lang ?? 'en') }} " ;
contents . innerHTML = " { { ctrans('texts.nordigen_handler_error_contents_institution_invalid', [], $lang ?? 'en') }} " ;
2023-12-15 13:10:45 +01:00
break ;
// Confirm Screen Errors
case " ref-invalid " :
2023-12-15 14:45:52 +01:00
heading . innerHTML = " { { ctrans('texts.nordigen_handler_error_heading_ref_invalid', [], $lang ?? 'en') }} " ;
contents . innerHTML = " { { ctrans('texts.nordigen_handler_error_contents_ref_invalid', [], $lang ?? 'en') }} " ;
2023-12-15 13:10:45 +01:00
break ;
case " requisition-not-found " :
2023-12-15 14:45:52 +01:00
heading . innerHTML = " { { ctrans('texts.nordigen_handler_error_heading_not_found', [], $lang ?? 'en') }} " ;
contents . innerHTML = " { { ctrans('texts.nordigen_handler_error_contents_not_found', [], $lang ?? 'en') }} " ;
2023-12-15 13:10:45 +01:00
break ;
case " requisition-invalid-status " :
2023-12-15 14:54:17 +01:00
heading . innerHTML = " { { ctrans('texts.nordigen_handler_error_heading_requisition_invalid_status', [], $lang ?? 'en') }} " ;
2023-12-15 14:45:52 +01:00
contents . innerHTML = " { { ctrans('texts.nordigen_handler_error_contents_requisition_invalid_status', [], $lang ?? 'en') }} " ;
2023-12-15 13:10:45 +01:00
break ;
case " requisition-no-accounts " :
2023-12-15 14:45:52 +01:00
heading . innerHTML = " { { ctrans('texts.nordigen_handler_error_heading_requisition_no_accounts', [], $lang ?? 'en') }} " ;
contents . innerHTML = " { { ctrans('texts.nordigen_handler_error_contents_requisition_no_accounts', [], $lang ?? 'en') }} " ;
2023-12-15 13:10:45 +01:00
break ;
case " unknown " :
break ;
default :
console . warn ( 'Invalid or missing failed_reason code: ' + failedReason );
break ;
}
wrapper . appendChild ( contents );
const restartUrl = new URL ( window . location . pathname , window . location . origin ); // no searchParams
const returnButton = document . createElement ( 'div' );
returnButton . className = " mt-4 " ;
2023-12-15 14:45:52 +01:00
returnButton . innerHTML = `<a class="button button-primary bg-blue-600 my-4" href="${restartFlow ? restartUrl.href : config.redirectUrl}">${restartFlow ? "{{ ctrans('texts.nordigen_handler_restart', [], $lang ?? 'en') }}" : "{{ ctrans('texts.nordigen_handler_return', [], $lang ?? 'en') }}"}</a>`
wrapper . ald ( returnButton );
2023-12-15 13:10:45 +01:00
}
</ script >
@ endpush