133 lines
4.1 KiB
JavaScript
133 lines
4.1 KiB
JavaScript
import * as React from 'react';
|
|
import {Linking, Platform} from 'react-native';
|
|
import {ActionSheet} from 'native-base';
|
|
import REQUEST from './api/';
|
|
import { openComposer } from 'react-native-email-link';
|
|
|
|
export const ContactOptions = () => {
|
|
let options = [
|
|
{text: 'Call Customer Service', icon: 'call-outline', execute: async () => {
|
|
|
|
await REQUEST("contact_us", "get", {}, {}, {}, async (res) => {
|
|
if(res.status == 1 && res.data){
|
|
let url = Platform.OS == 'ios' ? 'telprompt:' : 'tel:'
|
|
Linking.canOpenURL(url).then(supported => {
|
|
if (!supported) {
|
|
console.log('Cant handle url')
|
|
alert("Call Not Supported")
|
|
} else {
|
|
return Linking.openURL(`${url}${res.data.contact_number_mobile}`)
|
|
}
|
|
}).catch(err => {
|
|
console.error('An error occurred', err)
|
|
})
|
|
}else{
|
|
console.log(res.message, res.data)
|
|
}
|
|
}, function(error){
|
|
console.log(error)
|
|
})
|
|
|
|
|
|
}},
|
|
{text: 'Email Customer Service', icon: 'mail-outline', execute: async () => {
|
|
|
|
await REQUEST("contact_us", "get", {}, {}, {}, async (res) => {
|
|
if(res.status == 1 && res.data){
|
|
|
|
openComposer({
|
|
to: res.data.contact_email_address_mobile,
|
|
subject: `CN`,
|
|
body: ''
|
|
})
|
|
|
|
}else{
|
|
console.log(res.message, res.data)
|
|
}
|
|
}, function(error){
|
|
console.log(error)
|
|
})
|
|
}},
|
|
{text: 'Cancel', execute: () => ActionSheet.hide()}
|
|
]
|
|
|
|
ActionSheet.show(
|
|
{
|
|
options: options,
|
|
title: "Select an option",
|
|
destructiveButtonIndex: 2,
|
|
cancelButtonIndex: 2
|
|
},
|
|
buttonIndex => {
|
|
options[buttonIndex].execute()
|
|
}
|
|
)
|
|
|
|
}
|
|
|
|
export const ContactOptionsWithParams = (params) => {
|
|
let options = [
|
|
{text: 'Call Customer Service', icon: 'call-outline', execute: async () => {
|
|
|
|
await REQUEST("contact_us", "get", {}, {}, {}, async (res) => {
|
|
if(res.status == 1 && res.data){
|
|
let url = Platform.OS == 'ios' ? 'telprompt:' : 'tel:'
|
|
Linking.canOpenURL(url).then(supported => {
|
|
if (!supported) {
|
|
console.log('Cant handle url')
|
|
alert("Call Not Supported")
|
|
} else {
|
|
return Linking.openURL(`${url}${res.data.contact_number_mobile}`)
|
|
}
|
|
}).catch(err => {
|
|
console.error('An error occurred', err)
|
|
})
|
|
}else{
|
|
console.log(res.message, res.data)
|
|
}
|
|
}, function(error){
|
|
console.log(error)
|
|
})
|
|
|
|
|
|
}},
|
|
{text: 'Email Customer Service', icon: 'mail-outline', execute: async () => {
|
|
|
|
await REQUEST("contact_us", "get", {}, {}, {}, async (res) => {
|
|
if(res.status == 1 && res.data){
|
|
|
|
openComposer({
|
|
to: res.data.contact_email_address_mobile,
|
|
subject: `Mobile App Feedback: ${(params == undefined && params.cardnumber == undefined) ? "" : "CN"+params.cardnumber}`,
|
|
body: ''
|
|
})
|
|
|
|
}else{
|
|
console.log(res.message, res.data)
|
|
}
|
|
}, function(error){
|
|
console.log(error)
|
|
})
|
|
|
|
}},
|
|
|
|
{text: 'Cancel', execute: () => ActionSheet.hide()}
|
|
]
|
|
|
|
ActionSheet.show(
|
|
{
|
|
options: options,
|
|
title: "Select an option",
|
|
destructiveButtonIndex: 2,
|
|
cancelButtonIndex: 2
|
|
},
|
|
buttonIndex => {
|
|
options[buttonIndex].execute()
|
|
}
|
|
)
|
|
|
|
}
|
|
|
|
export default {
|
|
|
|
} |