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
8df77e2d
Commit
8df77e2d
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 [
@kkaminski
]
parent
af5981b8
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
55 additions
and
27 deletions
+55
-27
AccountForm.tsx
src/components/AccountForm.tsx
+1
-1
Login.tsx
src/components/Login.tsx
+5
-7
AccountPage.tsx
src/pages/AccountPage.tsx
+8
-5
AuthPage.tsx
src/pages/AuthPage.tsx
+1
-1
OrderIndexPage.tsx
src/pages/OrderIndexPage.tsx
+6
-1
OrderShowPage.tsx
src/pages/OrderShowPage.tsx
+17
-0
GoogleAuthService.ts
src/services/GoogleAuthService.ts
+8
-0
OrderService.ts
src/services/OrderService.ts
+7
-11
index.ts
src/services/index.ts
+2
-1
No files found.
src/components/AccountForm.tsx
View file @
8df77e2d
import
React
from
'react'
const
AccountForm
=
()
=>
{
const
AccountForm
=
(
props
:
any
)
=>
{
return
(
<
div
>
<
h3
>
Account
</
h3
>
...
...
src/components/Login.tsx
View file @
8df77e2d
import
React
from
'react'
import
{
GoogleLogin
,
useGoogleLogin
}
from
'react-google-login'
;
import
{
GoogleLogin
}
from
'react-google-login'
;
const
Login
=
()
=>
{
const
storage
=
window
.
localStorage
;
const
loginSuccess
=
(
response
:
any
)
=>
{
console
.
log
(
response
);
const
{
email
,
familyName
:
lastName
,
givenName
:
firstName
}
=
response
.
profileObj
;
storage
.
setItem
(
"loggedIn"
,
"true"
);
storage
.
setItem
(
"userFirstName"
,
firstName
);
storage
.
setItem
(
"userLastName"
,
lastName
);
storage
.
setItem
(
"userEmail"
,
email
);
storage
.
setItem
(
"tokenId"
,
response
.
tokenId
);
const
apiUrl
=
"https://www.googleapis.com/oauth2/v3/tokeninfo?id_token="
+
response
.
tokenId
fetch
(
apiUrl
).
then
((
response
)
=>
response
.
json
()).
then
((
data
)
=>
{
console
.
log
(
data
)
})
console
.
log
(
"Log in succesful"
,
storage
);
}
...
...
src/pages/AccountPage.tsx
View file @
8df77e2d
import
React
,
{
useState
,
useEffect
}
from
'react'
import
{
useGoogleLogin
}
from
'react-google-login'
import
{
GoogleAuthService
}
from
'services'
import
{
AccountForm
}
from
'components'
const
AccountPage
=
()
=>
{
let
clientId
=
""
;
const
userInfo
=
useGoogleLogin
({
clientId
})
const
storage
=
window
.
localStorage
const
[
userInfo
,
setUserInfo
]
=
useState
();
GoogleAuthService
.
checkGoogleToken
(
storage
.
tokenId
).
then
((
data
)
=>
setUserInfo
(
data
))
return
(
<
div
>
<
AccountForm
/>
<
AccountForm
props=
{
userInfo
}
/>
</
div
>
)
}
...
...
src/pages/AuthPage.tsx
View file @
8df77e2d
...
...
@@ -6,4 +6,4 @@ const AuthPage = () => {
)
}
export
default
AuthPage
\ No newline at end of file
export
default
AuthPage
\ No newline at end of file
src/pages/OrderIndexPage.tsx
View file @
8df77e2d
...
...
@@ -5,7 +5,12 @@ import { Order } from 'Order';
import
{
useAllOrders
}
from
'hooks'
const
OrderIndexPage
=
()
=>
{
const
{
orders
}
=
useAllOrders
();
// const { orders } = useAllOrders();
let
[
orders
,
setOrders
]
=
useState
([]);
useEffect
(()
=>
{
OrderService
.
allOrders
().
then
((
data
)
=>
setOrders
(
data
));
},
[])
const
orderDetailsArr
=
orders
.
map
((
order
:
Order
,
idx
:
any
)
=>
{
return
<
tr
key=
{
idx
}
><
OrderDetails
...
...
src/pages/OrderShowPage.tsx
View file @
8df77e2d
import
{
useParams
}
from
'react-router-dom'
;
import
{
OrderShowDetails
}
from
'components'
;
import
{
Order
,
Item
}
from
'Order'
;
<
<<<<<<
HEAD
import
{
useOrder
}
from
'
hooks
'
const
OrderShowPage
=
()
=
>
{
const
{
id
}
=
useParams
<
any
>
();
const
{
order
}
=
useOrder
(
id
)
=======
import
{
OrderService
}
from
'services'
const
OrderShowPage
=
(
props
:
any
)
=>
{
const
location
=
props
.
match
.
params
.
id
;
const
apiUrl
=
'http://localhost:8080/api/orders/'
+
location
;
const
[
order
,
setOrder
]
=
useState
<
Order
>
();
const
[
items
,
setItems
]
=
useState
<
Item
[]
>
()
useEffect
(()
=>
{
OrderService
.
orderById
(
apiUrl
).
then
((
data
)
=>
{
setOrder
(
data
)
setItems
(
data
.
orderItems
);
})
},
[
apiUrl
])
>>>>>>>
[
AFP
-
87
]
:
construction
:
Working
on
Local
Storage
and
adding
google
info
[@
kkaminski
]
if
(
!
order
)
{
return
(<></>);
...
...
src/services/GoogleAuthService.ts
0 → 100644
View file @
8df77e2d
export
const
checkGoogleToken
=
(
tokenId
:
any
)
=>
{
const
apiUrl
=
"https://www.googleapis.com/oauth2/v3/tokeninfo?id_token="
+
tokenId
return
fetch
(
apiUrl
).
then
((
response
)
=>
response
.
json
())
}
export
default
{
checkGoogleToken
}
\ No newline at end of file
src/services/OrderService.ts
View file @
8df77e2d
import
orderList
from
'./mock-order-data'
import
{
Order
}
from
'Order'
;
export
const
allOrders
=
()
=>
new
Promise
<
Order
[]
>
((
res
,
rej
)
=>
{
setTimeout
(()
=>
{
res
(
orderList
)
},
2000
)
});
export
const
allOrders
=
()
=>
{
const
apiUrl
=
'http://localhost:8080/api/orders'
;
return
fetch
(
apiUrl
).
then
((
response
)
=>
response
.
json
())
}
export
const
orderById
=
(
id
:
string
)
=>
new
Promise
<
Order
>
((
res
,
rej
)
=>
{
setTimeout
(()
=>
{
const
orderData
=
orderList
.
filter
((
order
)
=>
{
return
order
.
id
===
id
;
})
res
(
orderData
[
0
])
},
2000
)
})
export
const
orderById
=
(
apiUrl
:
string
)
=>
{
return
fetch
(
apiUrl
).
then
((
response
)
=>
response
.
json
())
}
export
default
{
...
...
src/services/index.ts
View file @
8df77e2d
export
{
default
as
OrderService
}
from
'./OrderService'
\ No newline at end of file
export
{
default
as
OrderService
}
from
'./OrderService'
export
{
default
as
GoogleAuthService
}
from
'./GoogleAuthService'
\ No newline at end of file
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