feat: Rewrite Front End cloud and posthog hooks using TypeScript (no-changelog) (#5491)

This commit is contained in:
Alex Grozav
2023-11-13 15:10:42 +02:00
committed by GitHub
parent 3dfabc37d8
commit a262c450f7
41 changed files with 1439 additions and 131 deletions

View File

@@ -0,0 +1,15 @@
export function addAutoLoginToAdminPanelButton() {
const adminPanelHost = new URL(window.location.href).host.split('.').slice(1).join('.');
document.body?.addEventListener('click', async (e) => {
if (!e.target || !(e.target instanceof Element)) return;
if (e.target.getAttribute('id') !== 'admin' && !e.target.closest('#admin')) return;
e.preventDefault();
const restPath = window.REST_ENDPOINT ?? 'rest';
const response = await fetch(`/${restPath}/cloud/proxy/login/code`);
const { code } = await response.json();
window.location.href = `https://${adminPanelHost}/login?code=${code}`;
});
}