Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
order-management-react
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Ascend
order-management-react
Commits
2676d821
Commit
2676d821
authored
May 06, 2021
by
Kevin Kaminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[AFP-87]
🚧
Working on Local Storage and adding google info
parent
f124ab85
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
50 additions
and
21 deletions
+50
-21
index.tsx
src/index.tsx
+3
-0
AccountPage.tsx
src/pages/AccountPage.tsx
+0
-12
AuthPage.tsx
src/pages/AuthPage.tsx
+47
-9
No files found.
src/index.tsx
View file @
2676d821
...
...
@@ -4,6 +4,9 @@ import './index.css';
import
App
from
'./App'
;
import
reportWebVitals
from
'./reportWebVitals'
;
const
storage
=
window
.
localStorage
;
storage
.
setItem
(
"loggedIn"
,
"false"
);
ReactDOM
.
render
(
<
React
.
StrictMode
>
<
App
/>
...
...
src/pages/AccountPage.tsx
View file @
2676d821
...
...
@@ -2,20 +2,8 @@ import React, { useState, useEffect } from 'react'
import
{
AccountForm
}
from
'components'
const
AccountPage
=
()
=>
{
// const [appState, setAppState] = useState(0);
// useEffect(() => {
// const apiUrl = 'http://localhost:8080/api/orders';
// fetch(apiUrl).then((response) => response.json())
// .then((data) => console.log('This is your data', data));
// }, [appState])
// const tester = ()=> {
// setAppState(appState + 1);
// }
return
(
<
div
>
{
/* <button onClick={tester}>{appState}</button> */
}
<
AccountForm
/>
</
div
>
)
...
...
src/pages/AuthPage.tsx
View file @
2676d821
import
React
from
'react'
import
{
LoginForm
}
from
'components'
;
import
{
GoogleLogin
}
from
'react-google-login'
;
import
{
GoogleLogin
,
GoogleLogout
}
from
'react-google-login'
;
const
AuthPage
=
()
=>
{
const
storage
=
window
.
localStorage
;
const
responseGoogle
=
(
response
:
any
)
=>
{
//
console.log(response)
console
.
log
(
response
)
// console.log(response.profileObj);
// console.log(response.tokenObj);
if
(
"error"
in
response
)
{
storage
.
setItem
(
"loggedIn"
,
"false"
)
}
else
{
const
{
email
,
familyName
:
lastName
,
givenName
:
firstName
,
googleId
,
imageUrl
}
=
response
.
profileObj
;
const
googleAuthInfo
=
{
email
,
firstName
,
lastName
,
googleId
,
imageUrl
}
storage
.
setItem
(
"loggedIn"
,
"true"
);
storage
.
setItem
(
"googleAuthInfo"
,
JSON
.
stringify
(
googleAuthInfo
));
return
(
googleAuthInfo
);
}
}
const
loginSuccess
=
(
response
:
any
)
=>
{
console
.
log
(
response
)
const
{
email
,
familyName
:
lastName
,
givenName
:
firstName
,
googleId
,
imageUrl
}
=
response
.
profileObj
;
return
({
email
,
firstName
,
lastName
,
googleId
,
imageUrl
})
const
googleAuthInfo
=
{
email
,
firstName
,
lastName
,
googleId
,
imageUrl
}
storage
.
setItem
(
"loggedIn"
,
"true"
);
storage
.
setItem
(
"googleAuthInfo"
,
JSON
.
stringify
(
googleAuthInfo
));
return
(
googleAuthInfo
);
}
const
loginFailure
=
(
response
:
any
)
=>
{
console
.
log
(
response
);
storage
.
setItem
(
"loggedIn"
,
"false"
)
}
const
logout
=
(
response
:
any
)
=>
{
console
.
log
(
response
)
storage
.
clear
();
}
return
(
...
...
@@ -27,6 +59,12 @@ const AuthPage = () => {
onFailure=
{
responseGoogle
}
cookiePolicy=
{
'single_host_origin'
}
/>
{
/* <GoogleLogout
clientId="658977310896-knrl3gka66fldh83dao2rhgbblmd4un9.apps.googleusercontent.com"
buttonText="Logout"
onLogoutSuccess={logout}
onFailure={logout}
/> */
}
</
div
>
)
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment