56 lines
1.9 KiB
JavaScript
56 lines
1.9 KiB
JavaScript
import React from 'react'
|
|
import {Platform, Alert} from 'react-native'
|
|
import DB from '../../components/storage/';
|
|
import REQUEST from '../../components/api/';
|
|
|
|
const ActivateCard = async (body) => {
|
|
await REQUEST("activateCard", "post", {}, {}, body, async (res) => {
|
|
setloading(false)
|
|
if(res.status == 1){
|
|
let mobileNumberValidation = await SendOtp(res.data)
|
|
if(mobileNumberValidation.status == 1){
|
|
let sessiondata = {
|
|
birthdate: Theme.formatter.DT4API(birthdate || ""),
|
|
card_number: card.card_number,
|
|
lcard_uuid: res.data.lcard_uuid,
|
|
mobile_number: res.data.mobile_number
|
|
}
|
|
res.data.target = "enroll"
|
|
res.data.callback = () => {
|
|
DB.setsession(sessiondata, function(ses){
|
|
}, function(error){
|
|
console.log(error)
|
|
})
|
|
}
|
|
res.data.catcher = (res) => {
|
|
if(res.status == 0){
|
|
setTimeout(() => {
|
|
seterrors({mobile: [res.message]})
|
|
alert(res.message)
|
|
}, 300)
|
|
}
|
|
}
|
|
navigation.navigation.navigate("EnrollOtp", res.data)
|
|
}
|
|
|
|
}else if(res.status == 0 && Object.keys(res.data).length == 0){
|
|
Platform.OS == 'ios' ? setTimeout(() => {
|
|
Alert.alert("Information", '\n' + res.message)
|
|
}, 300) :
|
|
Alert.alert("Information", '\n' + res.message)
|
|
seterrors(null)
|
|
}else{
|
|
setTimeout(() => {
|
|
alert(JSON.stringify(res.message))
|
|
}, 300)
|
|
seterrors(res.data)
|
|
}
|
|
}, function(err){
|
|
setloading(false)
|
|
Alert.alert("Information", '\n' + err.message)
|
|
}, "Card", "Activate")
|
|
}
|
|
|
|
export default {
|
|
ActivateCard
|
|
} |