Skip to content

Commit

Permalink
fix: redirect to login
Browse files Browse the repository at this point in the history
  • Loading branch information
xsteadybcgo committed Sep 2, 2021
1 parent bce8e6c commit 7af988e
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 41 deletions.
2 changes: 1 addition & 1 deletion src/pages/Header/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ const Header: React.FC = () => {
setLoginModalVisible(true)
}
}}
to="/dashboard/summary"
to="/dashboard"
activeStyle={{
color: '#14B071',
}}
Expand Down
4 changes: 3 additions & 1 deletion src/pages/Projects/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -242,9 +242,11 @@
}

.request-section .api > .api-info > .title {
font-weight: 700;
font-weight: bolder;
color: #3f3f3f;
padding-bottom: 8px;
font-size: 13px;
font-family: WorkSans, WorkSans-Bold;
}

.request-section .api > .api-info > .value {
Expand Down
76 changes: 38 additions & 38 deletions src/shared/components/LoginModal/index.tsx
Original file line number Diff line number Diff line change
@@ -1,63 +1,63 @@
import React, { useCallback, useEffect, useState } from "react";
import { useTranslation } from "react-i18next";
import { apiLogin } from "../../../core/data/api";
import { APIError } from "../../../core/types/classes/error";
import { API_DOMAIN } from "../../../config/origin";
import "./index.css";
import { createPlainModal } from "../plain-modal";
import { useApi } from "../../../core/hooks/useApi";
import GithubLogo from "../../../assets/github-login.svg";
import GithubWhite from "../../../assets/github-white.svg";
import { useHistory } from "react-router";
import React, { useCallback, useEffect, useState } from 'react'
import { useTranslation } from 'react-i18next'
import { apiLogin } from '../../../core/data/api'
import { APIError } from '../../../core/types/classes/error'
import { API_DOMAIN } from '../../../config/origin'
import './index.css'
import { createPlainModal } from '../plain-modal'
import { useApi } from '../../../core/hooks/useApi'
import GithubLogo from '../../../assets/github-login.svg'
import GithubWhite from '../../../assets/github-white.svg'
import { useHistory } from 'react-router'

const _LoginModal: React.FC<{ isModalVisible: boolean; onModalClose(): void }> =
({ isModalVisible }) => {
const history = useHistory();
const { setUser, setIsLoggged } = useApi();
const { t } = useTranslation();
const [hover, setIsHoverd] = useState<boolean>(false);
const history = useHistory()
const { setUser, setIsLoggged } = useApi()
const { t } = useTranslation()
const [hover, setIsHoverd] = useState<boolean>(false)

const loginInit = useCallback(
() =>
apiLogin()
.then((_user) => {
setIsLoggged(true);
setUser(_user);
localStorage.setItem("user", JSON.stringify(_user));
history.push("/dashboard/projects");
return true;
setIsLoggged(true)
setUser(_user)
localStorage.setItem('user', JSON.stringify(_user))
history.push('/dashboard/summary')
return true
})
.catch((err: APIError) => {
setIsLoggged(false);
return false;
setIsLoggged(false)
return false
}),
[setIsLoggged, setUser, history]
);
)

const openWindow = () => window.open(`${API_DOMAIN}/auth/github`);
const openWindow = () => window.open(`${API_DOMAIN}/auth/github`)

useEffect(() => {
if (!isModalVisible) {
return;
return
}
loginInit();
loginInit()

const repeater = setInterval(async () => {
const result = await loginInit();
const result = await loginInit()
if (result === true) {
clearInterval(repeater);
clearInterval(repeater)
}
}, 2000);
}, 2000)

return () => {
clearInterval(repeater);
};
}, [isModalVisible, loginInit]);
clearInterval(repeater)
}
}, [isModalVisible, loginInit])

return (
<div className="login-modal">
<div className="login-modal-body">
<div className="login-text">{t("sign.Connect to Polkadot now")}</div>
<div className="login-text">{t('sign.Connect to Polkadot now')}</div>
<div className="login-github">
<button
className="login-modal-btn"
Expand All @@ -68,14 +68,14 @@ const _LoginModal: React.FC<{ isModalVisible: boolean; onModalClose(): void }> =
<img
src={hover ? GithubWhite : GithubLogo}
alt=""
style={{ marginRight: "16px" }}
style={{ marginRight: '16px' }}
/>
{t("sign.Github quick Login")}
{t('sign.Github quick Login')}
</button>
</div>
</div>
</div>
);
};
)
}

export const LoginModal = createPlainModal(_LoginModal, 480);
export const LoginModal = createPlainModal(_LoginModal, 480)
2 changes: 1 addition & 1 deletion src/shared/components/OverviewCard/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
align-items: flex-start;
justify-content: flex-start;
line-height: 16px;
font-size: 12px;
font-size: 13px;
}

.summary-card > .data {
Expand Down

0 comments on commit 7af988e

Please sign in to comment.