diff --git a/.gitignore b/.gitignore index 9ce5739..7b65aa4 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,10 @@ +# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. + node_modules package-lock.json -.env# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. +.env # dependencies /node_modules @@ -24,4 +26,4 @@ package-lock.json npm-debug.log* yarn-debug.log* -yarn-error.log* +yarn-error.log* \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..3f77cd8 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,22 @@ +{ + "workbench.colorCustomizations": { + "activityBar.activeBackground": "#3399ff", + "activityBar.activeBorder": "#bf0060", + "activityBar.background": "#3399ff", + "activityBar.foreground": "#15202b", + "activityBar.inactiveForeground": "#15202b99", + "activityBarBadge.background": "#bf0060", + "activityBarBadge.foreground": "#e7e7e7", + "sash.hoverBorder": "#3399ff", + "statusBar.background": "#007fff", + "statusBar.foreground": "#e7e7e7", + "statusBarItem.hoverBackground": "#3399ff", + "statusBarItem.remoteBackground": "#007fff", + "statusBarItem.remoteForeground": "#e7e7e7", + "titleBar.activeBackground": "#007fff", + "titleBar.activeForeground": "#e7e7e7", + "titleBar.inactiveBackground": "#007fff99", + "titleBar.inactiveForeground": "#e7e7e799" + }, + "peacock.color": "#007fff" +} \ No newline at end of file diff --git a/package.json b/package.json index 6327f03..06ac388 100644 --- a/package.json +++ b/package.json @@ -6,6 +6,7 @@ "@testing-library/jest-dom": "^5.16.4", "@testing-library/react": "^13.0.1", "@testing-library/user-event": "^13.5.0", + "axios": "^0.26.1", "react": "^18.0.0", "react-dom": "^18.0.0", "react-router-dom": "^6.3.0", diff --git a/public/_redirects b/public/_redirects new file mode 100644 index 0000000..f824337 --- /dev/null +++ b/public/_redirects @@ -0,0 +1 @@ +/* /index.html 200 \ No newline at end of file diff --git a/src/App.jsx b/src/App.jsx index 197e417..c92d77a 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -1,8 +1,7 @@ import { BrowserRouter as Router, Routes, - Route, - Link + Route } from "react-router-dom"; import Header from './components/Header/Header' diff --git a/src/Pages/Auth.jsx b/src/Pages/Auth.jsx index a6059a2..60be372 100644 --- a/src/Pages/Auth.jsx +++ b/src/Pages/Auth.jsx @@ -1,7 +1,81 @@ +import React, {useState} from "react" +import axios from 'axios' + function Auth() { + + const [loading, setLoading] = useState(true) + const [permanentCode, setPermanentCode] = useState(false) + + React.useEffect(() => { + + async function getPermanentCode() { + + const temporalCode = new URLSearchParams(window.location.search).get("code") + console.log(temporalCode); + + if (!temporalCode) { + console.log("No temporal code") + return + } + + let requestUrl + + if (process.env.REACT_APP_ENV_MODE === "production") { + requestUrl = "https://telegram-to-notion-backend.herokuapp.com/api/v1/auth" + } else { + requestUrl = "http://localhost:5050/api/v1/auth" + } + + axios({ + method: "POST", + url: requestUrl, + headers: { + code: temporalCode, + } + }) + .then(res => { + console.log(res) + setPermanentCode(res ? res.data : null) + }) + .catch(err => { + console.log(err.response) + setPermanentCode(false) + }) + .finally(() => { + setLoading(false) + }) + + } + + getPermanentCode() + }) + return (
+ {permanentCode}
+
+