Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
students
shopping-mall
Commits
90177d68
Commit
90177d68
authored
Feb 03, 2021
by
Kim, Subin
Browse files
최종
parent
581c62c4
Changes
4
Hide whitespace changes
Inline
Side-by-side
client/src/Components/ListCard.js
View file @
90177d68
...
...
@@ -54,12 +54,12 @@ function ListCard(props) {
<
Col
sm
=
{
3
}
xs
=
{
5
}
className
=
'
p-1
'
><
li
>
주문날짜
:
<
/li></
Col
>
<
Col
sm
=
{
8
}
xs
=
{
6
}
className
=
'
p-1
'
><
strong
>
{
e
.
createdAt
.
substring
(
0
,
10
)}
<
/strong></
Col
>
<
Col
sm
=
{
3
}
xs
=
{
5
}
className
=
'
p-1
'
><
li
>
결제정보
:
<
/li></
Col
>
{
/*
<Col sm={3} xs={5} className='p-1'><li>결제정보 :</li></Col>
<Col sm={8} xs={6} className='p-1'><strong>{e.paymentWay}</strong>{e.paymentWay == 'Remittance' ? (
<>
<br /><strong>{e.paymentInfo.bank} / ~ {e.paymentInfo.deadline}</strong>
</>
)
:
''
}
<
/Col
>
) : ''}</Col>
*/
}
<
/Row
>
<
/Col
>
<
/Card.Text
>
...
...
client/src/Pages/Payment.js
View file @
90177d68
import
React
,
{
useState
,
useEffect
,
useRef
}
from
'
react
'
;
import
{
Redirect
,
Link
,
useHistory
}
from
'
react-router-dom
'
;
import
React
,
{
useState
,
useEffect
}
from
'
react
'
;
import
{
useHistory
}
from
'
react-router-dom
'
;
import
DaumPostcode
from
"
react-daum-postcode
"
;
import
ListCard
from
'
../Components/ListCard
'
;
import
axios
from
'
axios
'
;
...
...
@@ -7,20 +7,18 @@ import { isAuthenticated } from '../utils/auth';
import
catchErrors
from
'
../utils/catchErrors
'
;
import
{
Container
,
Row
,
Col
,
Button
,
Form
}
from
'
react-bootstrap
'
;
function
Payment
(
{
match
,
location
}
)
{
function
Payment
()
{
const
[
cart
,
setCart
]
=
useState
([])
const
[
order
,
setOrder
]
=
useState
({
products
:
[]
})
const
[
userData
,
setUserData
]
=
useState
({})
const
[
error
,
setError
]
=
useState
()
const
[
post
,
setPost
]
=
useState
([])
const
[
redirect
,
setRedirect
]
=
useState
(
null
)
const
[
address
,
setAddress
]
=
useState
(
""
)
const
[
finalPrice
,
setFinalPrice
]
=
useState
(
0
)
const
[
paymentWay
,
setPaymentWay
]
=
useState
([])
const
[
completeState
,
setCompleteState
]
=
useState
(
false
)
const
user
=
isAuthenticated
()
let
history
=
useHistory
();
const
preCart
=
[]
useEffect
(()
=>
{
getUser
()
...
...
@@ -79,7 +77,7 @@ function Payment({ match, location }) {
function
handleReceiverInfo
(
e
)
{
const
{
name
,
value
}
=
e
.
target
console
.
log
(
name
,
value
)
console
.
log
(
name
,
value
)
setOrder
({
...
order
,
receiverInfo
:
{
...
order
.
receiverInfo
,
[
name
]:
value
}
})
}
...
...
@@ -170,59 +168,59 @@ function Payment({ match, location }) {
order
.
products
.
map
((
el
)
=>
{
cartIds
.
push
(
el
.
_id
)
})
//
try {
//
setError('')
//
const response = await axios.post(`/api/order/addorder`, {
//
userId: user,
//
...order,
//
paymentWay: completeState,
//
total: finalPrice + 2500
//
})
//
const response2 = await axios.post(`/api/cart/deletecart2`, {
//
userId: user,
//
cartId: cartIds
//
})
//
const response3 = await axios.post(`/api/product/pluspurchase`, {
//
products: order.products
//
})
//
if (completeState === "kakaopay") {
//
let itemNames = ""
//
if (cart.length > 1) {
//
itemNames = cart[0].productId.pro_name + ' 외 ' + String(cart.length - 1) + '개'
//
} else {
//
itemNames = cart[0].productId.pro_name
//
}
//
setError('')
//
const response = await fetch('/api/kakaopay/test/single', {
//
method: "POST",
//
headers: {
//
'Content-type': 'application/json'
//
},
//
body: JSON.stringify({
//
cid: 'TC0ONETIME',
//
partner_order_id: 'partner_order_id',
//
partner_user_id: user,
//
item_name: itemNames,
//
quantity: cart.length,
//
total_amount: finalPrice + 2500,
//
vat_amount: 200,
//
tax_free_amount: 0,
//
approval_url: 'http://localhost:3000/paymentcompleted',
//
fail_url: 'http://localhost:3000/shoppingcart',
//
cancel_url: 'http://localhost:3000/shoppingcart',
//
})
//
})
//
const data = await response.json()
//
window.location.href = data.redirect_url
//
} else {
//
alert("주문이 완료되었습니다.")
//
history.push('/paymentcompleted')
//
}
//
} catch (error) {
//
catchErrors(error, setError)
//
alert("주문에 실패하셨습니다. 다시 확인해주세요.")
//
window.location.reload()
//
}
try
{
setError
(
''
)
const
response
=
await
axios
.
post
(
`/api/order/addorder`
,
{
userId
:
user
,
...
order
,
paymentWay
:
completeState
,
total
:
finalPrice
+
2500
})
const
response2
=
await
axios
.
post
(
`/api/cart/deletecart2`
,
{
userId
:
user
,
cartId
:
cartIds
})
const
response3
=
await
axios
.
post
(
`/api/product/pluspurchase`
,
{
products
:
order
.
products
})
if
(
completeState
===
"
kakaopay
"
)
{
let
itemNames
=
""
if
(
cart
.
length
>
1
)
{
itemNames
=
cart
[
0
].
productId
.
pro_name
+
'
외
'
+
String
(
cart
.
length
-
1
)
+
'
개
'
}
else
{
itemNames
=
cart
[
0
].
productId
.
pro_name
}
setError
(
''
)
const
response
=
await
fetch
(
'
/api/kakaopay/test/single
'
,
{
method
:
"
POST
"
,
headers
:
{
'
Content-type
'
:
'
application/json
'
},
body
:
JSON
.
stringify
({
cid
:
'
TC0ONETIME
'
,
partner_order_id
:
'
partner_order_id
'
,
partner_user_id
:
user
,
item_name
:
itemNames
,
quantity
:
cart
.
length
,
total_amount
:
finalPrice
+
2500
,
vat_amount
:
200
,
tax_free_amount
:
0
,
approval_url
:
'
http://localhost:3000/paymentcompleted
'
,
fail_url
:
'
http://localhost:3000/shoppingcart
'
,
cancel_url
:
'
http://localhost:3000/shoppingcart
'
,
})
})
const
data
=
await
response
.
json
()
window
.
location
.
href
=
data
.
redirect_url
}
else
{
alert
(
"
주문이 완료되었습니다.
"
)
history
.
push
(
'
/paymentcompleted
'
)
}
}
catch
(
error
)
{
catchErrors
(
error
,
setError
)
alert
(
"
주문에 실패하셨습니다. 다시 확인해주세요.
"
)
window
.
location
.
reload
()
}
}
if
(
error
)
{
...
...
@@ -232,7 +230,7 @@ function Payment({ match, location }) {
return
(
<
Container
className
=
"
mb-5
"
>
{
console
.
log
(
"
order=
"
,
order
)}
{
console
.
log
(
"
order=
"
,
order
)}
<
h3
className
=
"
my-5 font-weight-bold text-center
"
>
주문
/
결제
<
/h3
>
<
div
>
<
h5
className
=
"
font-weight-bold py-3 border-top border-bottom text-center
"
style
=
{{
background
:
'
#F7F3F3
'
}}
>
주문자
정보
<
/h5
>
...
...
data/제작물/2020-21_winter_연구_발표회_간행물.hwp
0 → 100644
View file @
90177d68
File added
data/제작물/2020_winter_연구_발표회_게시물.pptx
0 → 100644
View file @
90177d68
File added
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