Skip to content

Commit c5a8cc2

Browse files
committed
refactor(fdd): move Auth.Page to pages level
#163
1 parent b4dc383 commit c5a8cc2

File tree

5 files changed

+8
-10
lines changed

5 files changed

+8
-10
lines changed

src/features/auth/firebase/auth-github.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ const isValidAuthContext = (ctx: any): ctx is AuthContext => {
1414

1515
/**
1616
* Авторизация Github OAuth через firebase
17+
* @remark Стоит использовать только на странице Авторизации!!!
1718
*/
1819
function authGithub() {
1920
const provider = new firebase.auth.GithubAuthProvider();

src/features/auth/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export { default as Page } from "./page";
21
export { default as User } from "./user";
32
export * from "./consts";
43
export * from "./hooks";
4+
export * from "./firebase";
Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,8 @@ import React from "react";
22
import { GithubFilled } from "@ant-design/icons";
33
import { Alert, Card } from "antd";
44
import { alert } from "shared/helpers";
5-
// !!! FIXME: это плохо( + loop imports
6-
// eslint-disable-next-line import/order
7-
import { useTitle } from "pages/helpers";
8-
import { authorizeGithub } from "../firebase";
9-
import { useAuth } from "../hooks";
5+
import { Auth } from "features";
6+
import { useTitle } from "../helpers";
107
import "./index.scss";
118

129
/**
@@ -17,15 +14,14 @@ import "./index.scss";
1714
* 1. Авторизация через Github (/authorize)
1815
* 2. Получение временного кода доступа
1916
* 3. Получение токена на основании OAuth данных и полученного кода
20-
* !!! FIXME: move to pages level?
2117
*/
2218
const AuthPage = () => {
2319
useTitle("Sign in to Github Client");
24-
const { login } = useAuth();
20+
const { login } = Auth.useAuth();
2521

2622
// TODO: add ability to specify redirect url
2723
const authorize = () => {
28-
authorizeGithub()
24+
Auth.authorizeGithub()
2925
.then(login)
3026
.catch((err: Error) => alert.error("Authorization error", err.message));
3127
};

src/pages/index.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ const HomePage = lazy(() => import("./home"));
66
const RepositoryPage = lazy(() => import("./repository"));
77
const UserPage = lazy(() => import("./user"));
88
const SearchPage = lazy(() => import("./search"));
9+
const AuthPage = lazy(() => import("./auth"));
910

1011
/**
1112
* Роутинг приложения
@@ -17,7 +18,7 @@ const Routing = () => {
1718
return (
1819
<Switch>
1920
<Route exact path={Auth.routes.main} component={HomePage} />
20-
<Route exact path={Auth.routes.login} component={Auth.Page} />
21+
<Route exact path={Auth.routes.login} component={AuthPage} />
2122
<Redirect to={Auth.routes.login} />
2223
</Switch>
2324
);

0 commit comments

Comments
 (0)