- {
- loading ?
- //
-
Loading
- :
- <>
- {
- permanentCode ?
- <>
-
Copy the following code on the Telegram chat
-
-
- {permanentCode}
-
-
- >
- :
-
-
There has been an error getting the code. Please try again later.
-
- }
- >
- }
-
- )
-}
-
-export default Auth
\ No newline at end of file
diff --git a/src/Pages/Auth/Auth.jsx b/src/Pages/Auth/Auth.jsx
new file mode 100644
index 0000000..07b34fa
--- /dev/null
+++ b/src/Pages/Auth/Auth.jsx
@@ -0,0 +1,103 @@
+import React, {useState} from "react"
+import axios from 'axios'
+
+import Loading from "../../components/Loading/Loading"
+
+import authImage from './auth_copy.svg'
+
+import './auth-style.css'
+import Notification from "../../components/Notification/Notification"
+
+function Auth() {
+
+ const [loading, setLoading] = useState(true)
+ const [permanentCode, setPermanentCode] = useState(false)
+ const [notification, setNotification] = useState(false)
+
+ const getPermanentCode = () => {
+
+ const temporalCode = new URLSearchParams(window.location.search).get("code")
+
+ if (!temporalCode) {
+ setPermanentCode("empty")
+ setLoading(false)
+ return
+ }
+
+ let requestUrl
+
+ if (process.env.REACT_APP_ENV_MODE === "production") {
+ requestUrl = "http://localhost:5050/api/v1/auth"
+ } else {
+ requestUrl = "https://telegram-to-notion-backend.herokuapp.com/api/v1/auth"
+ }
+
+ axios({
+ method: "POST",
+ url: requestUrl,
+ headers: {'Content-Type': 'application/json'},
+ data: {code: temporalCode}
+ })
+ .then(res => {
+ console.log(res)
+ setPermanentCode(res ? res.data : null)
+ })
+ .catch(err => {
+ console.log(err.response)
+ setPermanentCode(false)
+ })
+ .finally(() => {
+ setLoading(false)
+ })
+ }
+ React.useEffect(() => {
+ getPermanentCode()
+ }, [])
+
+
+ return (
+
+ {
+ loading ?
+
+ :
+ <>
+ {
+ permanentCode && permanentCode !== "empty" ?
+ <>
+
Copy the following code on Telegram chat
+
+

+
{
+ navigator.clipboard.writeText(permanentCode)
+ setNotification("Text copied to clipboard!")
+ }}
+ >
+ {permanentCode}
+
+
+ >
+ :
+ <>
+ {
+ permanentCode === "empty" ?
+
+
There is no temporal code. Please try again later.
+
+ :
+
+
There has been an error getting the code. Please try again later.
+
+ }
+ >
+ }
+ >
+ }
+
+
+ )
+}
+
+export default Auth
\ No newline at end of file
diff --git a/src/Pages/Auth/auth-style.css b/src/Pages/Auth/auth-style.css
new file mode 100644
index 0000000..9a46685
--- /dev/null
+++ b/src/Pages/Auth/auth-style.css
@@ -0,0 +1,27 @@
+.auth {
+ padding: 1vh 3vw;
+}
+.auth h2, .auth h3 {
+ margin-top: 5vh;
+}
+.auth .success {
+ display: flex;
+ align-items: center;
+ background-color: #ffebcd;
+ padding: 5vh 2vw;
+ margin-top: 5vh;
+ border-radius: 20px;
+}
+.auth .success img {
+ width: 75px;
+ height: 75px;
+ margin-right: 3vw;
+}
+.auth .success .code-selection {
+ -webkit-user-select: all;
+ -moz-user-select: all;
+ user-select: all;
+ overflow-wrap: anywhere;
+ color: rgb(73, 70, 50);
+ font-size: 1.2em;
+}/*# sourceMappingURL=auth-style.css.map */
\ No newline at end of file
diff --git a/src/Pages/Auth/auth-style.css.map b/src/Pages/Auth/auth-style.css.map
new file mode 100644
index 0000000..3fd769f
--- /dev/null
+++ b/src/Pages/Auth/auth-style.css.map
@@ -0,0 +1 @@
+{"version":3,"sources":["auth-style.scss","auth-style.css"],"names":[],"mappings":"AAAA;EACI,gBAAA;ACCJ;ADCI;EACI,eAAA;ACCR;ADEI;EAEI,aAAA;EACA,mBAAA;EAEA,yBAAA;EAEA,gBAAA;EAEA,eAAA;EAEA,mBAAA;ACLR;ADOQ;EACI,WAAA;EACA,YAAA;EAEA,iBAAA;ACNZ;ADSQ;EACI,wBAAA;KAAA,qBAAA;UAAA,gBAAA;EACA,uBAAA;EAEA,sBAAA;EACA,gBAAA;ACRZ","file":"auth-style.css"}
\ No newline at end of file
diff --git a/src/Pages/Auth/auth-style.scss b/src/Pages/Auth/auth-style.scss
new file mode 100644
index 0000000..21915ad
--- /dev/null
+++ b/src/Pages/Auth/auth-style.scss
@@ -0,0 +1,37 @@
+.auth {
+ padding: 1vh 3vw;
+
+ h2, h3 {
+ margin-top: 5vh;
+ }
+
+ .success {
+
+ display: flex;
+ align-items: center;
+
+ background-color: #ffebcd;
+
+ padding: 5vh 2vw;
+
+ margin-top: 5vh;
+
+ border-radius: 20px;
+
+ img {
+ width: 75px;
+ height: 75px;
+
+ margin-right: 3vw;
+ }
+
+ .code-selection {
+ user-select: all;
+ overflow-wrap: anywhere;
+
+ color: rgb(73, 70, 50);
+ font-size: 1.2em;
+
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Pages/Auth/auth_copy.svg b/src/Pages/Auth/auth_copy.svg
new file mode 100644
index 0000000..2eb127c
--- /dev/null
+++ b/src/Pages/Auth/auth_copy.svg
@@ -0,0 +1 @@
+