| … | … | @@ -50,15 +50,24 @@ function formatPrice (cents) { |
| 50 | 50 | const signInBtn = document.getElementById('sign-in-btn') |
| 51 | 51 | if (signInBtn) { |
| 52 | 52 | signInBtn.addEventListener('click', async () => { |
| 53 | | if (typeof HyperBookingIdentity !== 'undefined' && HyperBookingIdentity.hasKeypair()) { |
| 54 | | showToast('Already signed in') |
| 55 | | return |
| 56 | | } |
| 57 | | if (typeof HyperBookingIdentity !== 'undefined') { |
| 53 | try { |
| 54 | if (typeof HyperBookingIdentity === 'undefined') { |
| 55 | showToast('Identity module not loaded', 'error') |
| 56 | return |
| 57 | } |
| 58 | if (HyperBookingIdentity.hasKeypair()) { |
| 59 | showToast('Already signed in') |
| 60 | return |
| 61 | } |
| 62 | signInBtn.textContent = 'Signing in...' |
| 58 | 63 | await HyperBookingIdentity.generate() |
| 59 | 64 | showToast('Identity created', 'success') |
| 60 | 65 | signInBtn.textContent = 'Signed In' |
| 61 | 66 | showDashboardLink() |
| 67 | } catch (err) { |
| 68 | showToast('Sign-in failed: ' + err.message, 'error') |
| 69 | signInBtn.textContent = 'Sign In' |
| 70 | console.error('[Sign-in error]', err) |
| 62 | 71 | } |
| 63 | 72 | }) |
| 64 | 73 | |