import "./fonts/fonts.scss" import "./styling.scss"; import "./oauth.scss"; import { render } from 'preact'; import 'preact/devtools'; import type { OAuthPageParams } from '../src/Webhooks'; const root = document.getElementsByTagName('main')[0]; const ServiceToName: Record = { github: 'GitHub', gitlab: 'GitLab', default: '' } function RenderOAuth() { const params = new URLSearchParams(window.location.search); const service = (params.get('service') as OAuthPageParams['service']) ?? 'default'; const error = (params.get('error') as OAuthPageParams['error']); const errcode = (params.get('errcode') as OAuthPageParams['errcode']); const oauthKind = (params.get('oauth-kind') as OAuthPageParams['oauth-kind']) ?? 'account'; const result = (params.get('result') as OAuthPageParams['result']); const serviceName = ServiceToName[service]; if (result === 'error') { return <>

Could not connect your { serviceName } {oauthKind} to Hookshot.

{errcode} {error}

; } else if (result === 'pending') { return <>

Your connection to { serviceName } {oauthKind} is pending.

The owner may need to approve this.

; } else if (result === 'success') { return <>

Your { serviceName } {oauthKind} has been connected.

You may close this window.

; } return <>

Your connection to { serviceName } {oauthKind} is {result}.

This is an unknown state, you may need to contact your systems administrator.

; } if (root) { render(, root); }