Commit 7ad84561 by Giang Tran

ghep api

parent a98562a5
import React, {useState, useEffect} from 'react';
import {View, Text, StyleSheet} from 'react-native';
import {View, Text, StyleSheet, Platform} from 'react-native';
import R from '../../assets/R';
import AppText from '../../components/AppText';
import TextMulti from '../../components/Input/TextMulti';
......@@ -8,9 +8,28 @@ import {connect} from 'react-redux';
import HeaderBack from '../../components/Header/HeaderBack';
import {getFontXD, HEIGHTXD, WIDTHXD} from '../../Config/Functions';
import {TouchableOpacity} from 'react-native-gesture-handler';
import {showLoading, hideLoading} from '../../actions/loadingAction';
import {showAlert, TYPE} from '../../components/DropdownAlert';
import {sendRequest} from '../../apis/Functions/General';
import {useNavigation} from '@react-navigation/native';
const ServiceCustomerView = (props) => {
const naviation = useNavigation();
const [content, setContent] = useState('');
const onClickSend = async () => {
props.showLoading();
const res = await sendRequest({content, platform: Platform.OS});
props.hideLoading();
if (res.data.code == 200) {
naviation.goBack();
showAlert(TYPE.SUCCESS, I18n.t('Notification'), res.data.message);
} else {
showAlert(TYPE.ERROR, I18n.t('Notification'), res.data.message);
}
};
const {
name,
email,
......@@ -85,7 +104,7 @@ const ServiceCustomerView = (props) => {
alignItems: 'center',
marginBottom: 20,
}}>
<TouchableOpacity style={styles.btn}>
<TouchableOpacity onPress={onClickSend} style={styles.btn}>
<AppText style={styles.txtBtn} i18nKey={'Send'} />
</TouchableOpacity>
</View>
......@@ -135,4 +154,6 @@ const mapStateToProps = (state) => {
user: state.userReducer,
};
};
export default connect(mapStateToProps, {})(ServiceCustomerView);
export default connect(mapStateToProps, {showLoading, hideLoading})(
ServiceCustomerView,
);
......@@ -11,3 +11,7 @@ export const sendFeedBack = async (body) =>
PostFormData(url.urlFeedback, body)
.then((res) => res)
.catch((err) => err);
export const sendRequest = async (body) =>
PostData(url.urlSendRequest, body)
.then((res) => res)
.catch((err) => err);
......@@ -52,4 +52,5 @@ export default {
urlUploadImage: root + 'api/v1/uploads/upload-image',
urlFeedback: root + 'api/v1/customers/send-feedback',
urlSendRequest: root + 'api/v1/customers/send-request',
};
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment