openreplay/spot/entrypoints/popup/Login.tsx
Delirium e66423dcf4
Spot network refactoring (#2617)
* start refactoring network

* separate network module, refactor spot network capture

Signed-off-by: nick-delirium <nikita@openreplay.com>

* some console refactoring, display network results in ui

* detect gql error param

* fix proxy ignore file, fix network tracking, fix tab tracking

* some code quality improvements...

* handle graphql in network lib (.2 ver), update tracker to use last version of lib

* remove debug logs, change request type to gql (if its gql!) in lib, display gql in ui

---------

Signed-off-by: nick-delirium <nikita@openreplay.com>
2024-09-30 09:47:27 +02:00

59 lines
1.4 KiB
TypeScript

function Login() {
const onOpenLoginPage = async () => {
const { settings } = await chrome.storage.local.get("settings");
return openLoginPage(settings.ingestPoint);
};
const onOpenSignupPage = async () => {
const { settings } = await chrome.storage.local.get("settings");
return openSignupPage(settings.ingestPoint);
};
return (
<div class={"flex flex-row gap-2"}>
<button
onClick={onOpenLoginPage}
name={"Login"}
class="btn btn-primary text-white shadow-sm text-lg w-2/4 "
>
Login
</button>
<button
onClick={onOpenSignupPage}
name={"Create Account"}
class="btn btn-primary btn-outline bg-white shadow-sm text-lg w-2/4 "
>
Create Account
</button>
</div>
);
}
function getLink(url: string) {
let str = url;
if (str.endsWith("/")) {
str = str.slice(0, -1);
}
if (str.includes("api.openreplay.com")) {
str = str.replace("api.openreplay.com", "app.openreplay.com");
}
return str;
}
function openSignupPage(instanceUrl: string) {
const signupUrl = `${getLink(instanceUrl)}/signup?spotCallback=true`;
chrome.tabs.create({
url: signupUrl,
active: true,
});
}
function openLoginPage(instanceUrl: string) {
const loginUrl = `${getLink(instanceUrl)}/login?spotCallback=true`;
chrome.tabs.create({
url: loginUrl,
active: true,
});
}
export default Login;