Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
N
new_excelso
Project
Project
Details
Activity
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
Prasetya Saputra
new_excelso
Commits
c5e4746d
Commit
c5e4746d
authored
May 29, 2020
by
Wahyu Adjie Prasetyo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add paymen code
parent
092b5b01
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
271 additions
and
43 deletions
+271
-43
Auth.js
view/Auth.js
+16
-0
PaymentCode.js
view/PaymentCode.js
+151
-0
UseBalance.js
view/UseBalance.js
+104
-43
No files found.
view/Auth.js
View file @
c5e4746d
...
...
@@ -54,6 +54,7 @@ import WelcomeReg from './WelcomeReg';
import
WelcomeLog
from
'./WelcomeLog'
;
import
RatingOrder
from
'./RatingOrder'
;
import
UseBalance
from
'./UseBalance'
;
import
PaymentCode
from
'./PaymentCode'
;
enableScreens
();
...
...
@@ -451,6 +452,21 @@ class Auth extends React.Component {
},
title
:
'USE BALANCE'
}}
/
>
<
Stack
.
Screen
name
=
"PaymentCode"
component
=
{
PaymentCode
}
options
=
{{
headerStyle
:
{
backgroundColor
:
'#CFB368'
},
headerTitleContainerStyle
:
{
alignContent
:
'center'
},
headerTitleAlign
:
'center'
,
headerTintColor
:
'#fff'
,
headerTitleStyle
:
{
alignSelf
:
'center'
,
fontFamily
:
'Gotham-Black'
,
fontSize
:
20
,
color
:
'white'
,
textAlign
:
'center'
},
title
:
'PAYMENT CODE'
}}
/
>
<
/
>
)
...
...
view/PaymentCode.js
0 → 100644
View file @
c5e4746d
import
React
from
'react'
;
import
{
View
,
Text
,
TextInput
,
StyleSheet
,
Button
,
Alert
,
TouchableOpacity
,
Image
}
from
'react-native'
;
import
{
connect
}
from
'react-redux'
;
import
Axios
from
'axios'
;
import
ActionType
from
'../redux/globalActionType'
;
import
Spinner
from
'react-native-loading-spinner-overlay'
;
class
PaymentCode
extends
React
.
Component
{
constructor
(
props
)
{
super
(
props
);
this
.
state
=
{
current_balance
:
''
,
kaspro_point
:
''
,
redeem_balance
:
''
,
redeem_point
:
''
,
}
}
componentDidMount
()
{
this
.
_getProfile
()
}
_getProfile
()
{
let
params
=
{
session_id
:
this
.
props
.
session_id
}
Axios
.
post
(
'https://excelsocrm.ravintoladev.com/crm/v2/member/get_profile'
,
params
).
then
(
res
=>
{
console
.
log
(
'ini res '
+
JSON
.
stringify
(
res
.
data
))
const
dataCard
=
res
.
data
let
balance
=
dataCard
.
kaspro_balance
let
point
=
dataCard
.
kaspro_point
this
.
setState
({
current_balance
:
balance
,
kaspro_point
:
point
,
})
}).
catch
(
error
=>
{
// console.log('ini error ' + error)
})
}
redeem
()
{
if
(
this
.
state
.
redeem_balance
>
this
.
state
.
current_balance
)
{
Alert
.
alert
(
''
,
'Maaf Balance tidak cukup'
)
}
else
if
(
this
.
state
.
redeem_point
>
this
.
state
.
kaspro_point
)
{
Alert
.
alert
(
''
,
'Maaf Point tidak cukup'
)
}
else
{
let
params
=
{
session_id
:
this
.
props
.
session_id
,
pin
:
123456
,
balance
:
this
.
state
.
current_balance
,
point
:
this
.
state
.
kaspro_point
}
Axios
.
post
(
'http://excelsocrm.ravintoladev.com/crm/v2/point/redeem'
,
params
).
then
(
res
=>
{
Alert
.
alert
(
''
,
'Sukses Redeem'
)
}).
catch
(
error
=>
{
let
response
=
error
.
response
.
data
;
Alert
.
alert
(
response
.
msg
);
})
}
}
render
()
{
return
(
<
View
style
=
{
styles
.
container
}
>
<
View
style
=
{{
flex
:
3
}}
>
<
View
style
=
{{
flex
:
1
,
marginRight
:
30
,
marginLeft
:
30
,
top
:
50
}}
>
<
View
style
=
{{
height
:
150
,
justifyContent
:
'center'
,
alignContent
:
'center'
}}
>
<
View
style
=
{{
borderColor
:
'#838383'
,
height
:
1
,
borderWidth
:
1
,
marginLeft
:
20
,
marginRight
:
20
}}
><
/View
>
<
/View
>
<
Text
style
=
{{
fontFamily
:
'Gotham-Black'
,
color
:
'#CFB368'
,
fontSize
:
20
,
textAlign
:
'center'
,
margin
:
3
}}
>
Current
Balance
<
/Text
>
<
TextInput
style
=
{{
height
:
40
,
borderWidth
:
1
,
padding
:
5
,
margin
:
10
,
borderRadius
:
10
,
borderColor
:
'grey'
,
fontFamily
:
'Gotham-Black'
,
textAlign
:
'center'
,
color
:
'grey'
,
fontWeight
:
'bold'
,
fontSize
:
20
}}
onChangeText
=
{(
redeem_point
)
=>
this
.
setState
({
redeem_point
})}
autoCapitalize
=
"none"
keyboardType
=
'numeric'
>
IDR
.{
this
.
state
.
kaspro_point
}
<
/TextInput
>
<
TouchableOpacity
style
=
{{
height
:
100
}}
onPress
=
{()
=>
this
.
redeem
()}
>
<
View
style
=
{{
backgroundColor
:
'#CFB368'
,
height
:
40
,
top
:
20
,
borderRadius
:
10
,
marginRight
:
50
,
marginLeft
:
50
}}
>
<
Text
style
=
{{
alignSelf
:
'center'
,
top
:
10
,
color
:
'white'
,
fontFamily
:
'Gotham-Black'
,
fontSize
:
20
}}
>
REDEEM
<
/Text
>
<
/View
>
<
/TouchableOpacity
>
<
/View
>
<
/View
>
<
/View
>
)
}
}
const
styles
=
StyleSheet
.
create
({
container
:
{
flex
:
1
,
backgroundColor
:
'#ffff'
},
header
:
{
flex
:
0.5
,
margin
:
10
,
},
form
:
{
flex
:
3
,
top
:
40
,
margin
:
10
,
marginTop
:
0
,
},
field_email
:
{
flexDirection
:
'row'
},
button
:
{
height
:
40
,
margin
:
10
,
},
logo
:
{
alignSelf
:
'flex-start'
,
marginTop
:
50
,
width
:
290
,
height
:
290
,
bottom
:
145
,
},
v_logo
:
{
flex
:
2
,
flexDirection
:
'column-reverse'
,
alignContent
:
'flex-start'
,
}
})
const
mapStateToProps
=
(
state
)
=>
{
return
{
session_id
:
state
.
session_id
,
language
:
state
.
language
,
pageEmailConfirmation
:
state
.
pageEmailConfirmation
}
}
export
default
connect
(
mapStateToProps
)(
PaymentCode
);
view/UseBalance.js
View file @
c5e4746d
import
React
from
'react'
;
import
{
View
,
Text
,
TextInput
,
StyleSheet
,
Button
,
Alert
,
TouchableOpacity
,
Image
}
from
'react-native'
;
import
{
View
,
Text
,
TextInput
,
StyleSheet
,
Button
,
Alert
,
TouchableOpacity
,
Image
,
Modal
}
from
'react-native'
;
import
{
connect
}
from
'react-redux'
;
import
Axios
from
'axios'
;
import
ActionType
from
'../redux/globalActionType'
;
...
...
@@ -10,13 +10,16 @@ class UseBalance extends React.Component {
constructor
(
props
)
{
super
(
props
);
this
.
state
=
{
current_balance
:
''
,
redeem
:
''
,
current_balance
:
0
,
kaspro_point
:
0
,
redeem_balance
:
0
,
redeem_point
:
0
,
modalVisible
:
false
,
}
}
componentDidMount
(){
componentDidMount
()
{
this
.
_getProfile
()
}
_getProfile
()
{
...
...
@@ -28,21 +31,16 @@ class UseBalance extends React.Component {
console
.
log
(
'ini res '
+
JSON
.
stringify
(
res
.
data
))
const
dataCard
=
res
.
data
let
balance
=
dataCard
.
kaspro_balance
let
expired
=
dataCard
.
expire_date
let
c_renew_until
=
dataCard
.
expire_date
var
date_string
=
c_renew_until
var
date_arr
=
date_string
.
split
(
'-'
);
var
date
=
new
Date
(
date_arr
[
0
],
date_arr
[
1
],
date_arr
[
2
]);
let
balance
=
dataCard
.
kaspro_balance
.
replace
(
','
,
''
)
let
point
=
dataCard
.
kaspro_point
.
replace
(
','
,
''
)
let
balances
=
parseFloat
(
balance
);
let
points
=
parseFloat
(
point
);
date
.
setFullYear
(
date
.
getFullYear
()
+
1
);
let
date_nextyear_string
=
date
.
getFullYear
()
+
"-"
+
date
.
getMonth
()
+
"-"
+
date
.
getDate
()
this
.
setState
({
current_balance
:
balance
,
expired
:
expired
,
renew_until
:
date_nextyear_string
current_balance
:
balances
,
kaspro_point
:
points
})
...
...
@@ -52,42 +50,93 @@ class UseBalance extends React.Component {
}
redeem
(){
let
params
=
{
session_id
:
this
.
props
.
session_id
,
pin
:
123456
,
balance
:
5000
,
point
:
5000
}
modal
()
{
this
.
setState
({
modalVisible
:
true
})
}
console
.
log
(
"INI PARAMS : "
+
JSON
.
stringify
(
params
))
redeem
()
{
if
(
this
.
state
.
redeem_balance
>
this
.
state
.
current_balance
)
{
Alert
.
alert
(
''
,
'Maaf Balance tidak cukup'
)
}
else
if
(
this
.
state
.
redeem_point
>
this
.
state
.
kaspro_point
)
{
Alert
.
alert
(
''
,
'Maaf Point tidak cukup'
)
}
else
{
let
params
=
{
session_id
:
this
.
props
.
session_id
,
pin
:
''
,
balance
:
this
.
state
.
redeem_balance
,
point
:
this
.
state
.
redeem_point
}
Axios
.
post
(
'http://excelsocrm.ravintoladev.com/crm/v2/point/redeem'
,
params
).
then
(
res
=>
{
console
.
log
(
'sukses'
)
}).
catch
(
error
=>
{
Axios
.
post
(
'https://excelsocrm.ravintoladev.com/crm/v2/point/redeem'
,
params
).
then
(
res
=>
{
Alert
.
alert
(
''
,
'Sukses Redeem'
)
}).
catch
(
error
=>
{
let
response
=
error
.
response
.
data
if
(
response
.
code
===
"EMPTY_PIN"
)
{
this
.
modal
()
}
else
{
let
response
=
error
.
response
.
data
;
Alert
.
alert
(
response
.
msg
);
})
}
Alert
.
alert
(
''
,
response
.
msg
);
}
})
}
}
render
()
{
return
(
<
View
style
=
{
styles
.
container
}
>
<
Modal
animationType
=
"slide"
transparent
=
{
true
}
visible
=
{
this
.
state
.
modalVisible
}
onRequestClose
=
{()
=>
{
this
.
setState
({
modalVisible
:
false
})
}}
>
<
View
style
=
{
styles
.
centerViewModal
}
>
<
View
style
=
{
styles
.
modalView
}
>
<
Text
style
=
{{
fontSize
:
12
,
color
:
'#CFB368'
,
fontFamily
:
'Gotham-Black'
}}
>
Reason
<
/Text
>
<
View
style
=
{{
margin
:
10
}}
>
<
TextInput
style
=
{
styles
.
textInput
}
onChangeText
=
{(
reason
)
=>
this
.
setState
({
reason
})}
value
=
{
this
.
state
.
reason
}
textAlign
=
'center'
/>
<
/View
>
<
View
>
<
/View
>
<
View
style
=
{{
margin
:
5
}}
>
<
TouchableOpacity
style
=
{{
marginBottom
:
10
}}
onPress
=
{()
=>
this
.
handleOrderCancel
()}
>
<
View
style
=
{
styles
.
button2
}
>
<
Text
style
=
{{
color
:
'white'
,
fontWeight
:
'bold'
,
fontSize
:
16
}}
>
Cancel
<
/Text
>
<
/View
>
<
/TouchableOpacity
>
<
TouchableOpacity
onPress
=
{()
=>
this
.
handleBack
()}
>
<
View
style
=
{
styles
.
button2
}
>
<
Text
style
=
{{
color
:
'white'
,
fontWeight
:
'bold'
,
fontSize
:
16
}}
>
Back
<
/Text
>
<
/View
>
<
/TouchableOpacity
>
<
/View
>
<
/View
>
<
/View
>
<
/Modal
>
<
View
style
=
{{
flex
:
3
}}
>
<
View
style
=
{{
flex
:
1
,
marginRight
:
30
,
marginLeft
:
30
,
top
:
50
}}
>
<
Text
style
=
{{
fontFamily
:
'Gotham-Black'
,
color
:
'#CFB368'
,
fontSize
:
20
,
textAlign
:
'center'
,
margin
:
3
}}
>
Current
Balance
<
/Text
>
<
TextInput
style
=
{{
height
:
40
,
borderWidth
:
1
,
padding
:
5
,
margin
:
10
,
borderRadius
:
10
,
borderColor
:
'grey'
,
fontFamily
:
'Gotham-Black'
,
textAlign
:
'center'
,
color
:
'grey'
,
fontWeight
:
'bold'
,
fontSize
:
20
}}
onChangeText
=
{(
current_balance
)
=>
this
.
setState
({
current
_balance
})}
keyboardType
=
'
email-address'
>
IDR
.
{
this
.
state
.
current_balance
}
<
/TextInput
>
<
Text
style
=
{{
fontFamily
:
'Gotham-Black'
,
color
:
'#CFB368'
,
fontSize
:
20
,
textAlign
:
'center'
,
margin
:
3
}}
>
Point
<
/Text
>
onChangeText
=
{(
redeem_balance
)
=>
this
.
setState
({
redeem
_balance
})}
keyboardType
=
'
numeric'
>
{
this
.
state
.
current_balance
}
<
/TextInput
>
<
Text
style
=
{{
fontFamily
:
'Gotham-Black'
,
color
:
'#CFB368'
,
fontSize
:
20
,
textAlign
:
'center'
,
margin
:
3
}}
>
Redeem
<
/Text
>
<
TextInput
style
=
{{
height
:
40
,
borderWidth
:
1
,
padding
:
5
,
margin
:
10
,
borderRadius
:
10
,
borderColor
:
'grey'
,
fontFamily
:
'Gotham-Black'
,
textAlign
:
'center'
,
color
:
'grey'
,
fontWeight
:
'bold'
,
fontSize
:
20
}}
onChangeText
=
{(
redeem
)
=>
this
.
setState
({
redeem
})}
onChangeText
=
{(
redeem
_point
)
=>
this
.
setState
({
redeem_point
})}
autoCapitalize
=
"none"
keyboardType
=
'numeric'
>
IDR
.
<
/TextInput
>
<
TouchableOpacity
style
=
{{
height
:
100
}}
onPress
=
{()
=>
this
.
redeem
()}
>
keyboardType
=
'numeric'
>
{
this
.
state
.
kaspro_point
}
<
/TextInput
>
<
TouchableOpacity
style
=
{{
height
:
100
}}
onPress
=
{()
=>
this
.
redeem
()}
>
<
View
style
=
{{
backgroundColor
:
'#CFB368'
,
height
:
40
,
top
:
20
,
borderRadius
:
10
,
marginRight
:
50
,
marginLeft
:
50
}}
>
<
Text
style
=
{{
alignSelf
:
'center'
,
top
:
10
,
color
:
'white'
,
fontFamily
:
'Gotham-Black'
,
fontSize
:
20
}}
>
REDEEM
<
/Text
>
<
/View
>
...
...
@@ -139,8 +188,20 @@ const styles = StyleSheet.create({
flex
:
2
,
flexDirection
:
'column-reverse'
,
alignContent
:
'flex-start'
,
}
},
centerViewModal
:
{
flex
:
1
,
justifyContent
:
"center"
,
alignItems
:
"center"
,
},
modalView
:
{
backgroundColor
:
"white"
,
borderRadius
:
10
,
borderWidth
:
1
,
borderColor
:
'grey'
,
padding
:
20
,
alignItems
:
"center"
,
},
})
const
mapStateToProps
=
(
state
)
=>
{
...
...
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