Commit 4a64ed70 by Giang Tran

update newfeed api

parent b9b6a73c
......@@ -242,6 +242,13 @@ export const getTimeDDMM = (time) => {
let t1 = new Date(moment(time, 'DD/MM/YYYY').format('MM/DD/YYYY')).getTime();
return t1;
};
export const converStringToDate = (time) => {
let t1 = new Date(moment(time, 'YYYY-MM-DD').format('MM/DD/YYYY')).getTime();
const strDate = convertDate(t1);
return strDate;
};
export const sortDataByTime = (data) => {
data.sort((a, b) => {
let t1 = moment(a.time, 'DD-MM-YYYY').format('MM/YYYY');
......
......@@ -60,7 +60,7 @@ const PacketCQG = (props) => {
return (
<View style={{flex: 1}}>
<HeaderBack title={'Mở tài khoản CQG'} />
<ScrollView showsVerticalScrollIndicator={true}>
<ScrollView showsVerticalScrollIndicator={false}>
<View style={styles.container}>
<Text style={styles.txtNote}>
Lưu ý:Phí được tính theo tháng và mc giá này được áp dng đến hết
......
......@@ -25,7 +25,6 @@ const AccountVerificationView = (props) => {
activeTintColor: '#1473E6',
labelStyle: {fontSize: getFontXD(36)},
style: {backgroundColor: 'white'},
scrollEnabled: true,
}}>
<Tab.Screen
name="GeneralInfor"
......@@ -37,11 +36,11 @@ const AccountVerificationView = (props) => {
component={Profile}
options={{tabBarLabel: 'Hồ sơ'}}
/>
<Tab.Screen
{/* <Tab.Screen
name="BankInfor"
component={BankInfor}
options={{tabBarLabel: 'Ngân hàng'}}
/>
/> */}
</Tab.Navigator>
</View>
);
......
......@@ -11,14 +11,18 @@ import {
Platform,
Dimensions,
} from 'react-native';
import Button from '../../../components/Button';
import PickerImgUni from '../../../components/Picker/PickerImgUni';
import R from '../../../assets/R';
import TextField from '../../../components/Input/TextField';
import {connect} from 'react-redux';
import {showLoading, hideLoading} from '../../../actions/loadingAction';
import {
checkFormatArray,
getFontXD,
convertTime,
} from '../../../Config/Functions';
import {verifyAccountApi} from '../../../apis/Functions/users';
import PickerDate from '../../../components/Picker/PickerDate';
import PickerItem from '../../../components/Picker/PickerItem';
const {width} = Dimensions.get('window');
......@@ -42,45 +46,110 @@ const Profile = (props) => {
const [urlFont, setUrlFont] = useState('');
const [urlBack, setUrlBack] = useState('');
const [urlSign, setUrlSign] = useState('');
const [cmnd, setCMND] = useState('');
const [date_range, setDate_range] = useState(new Date());
// const [cmnd, setCMND] = useState('');
// const [date_range, setDate_range] = useState(new Date());
const [type, setType] = useState();
const onNextPress = () => {
const createFormData = (identity_after, identity_before, sign_img, body) => {
const data = new FormData();
data.append('identity_after', {
name: 'identity_after.jpg',
type: 'image/jpg',
uri:
Platform.OS === 'android'
? identity_after
: identity_after.replace('file://', ''),
});
data.append('identity_before', {
name: 'identity_before.jpg',
type: 'image/jpg',
uri:
Platform.OS === 'android'
? identity_before
: identity_before.replace('file://', ''),
});
data.append('sign_image', {
name: 'sign_img.jpg',
type: 'image/jpg',
uri:
Platform.OS === 'android' ? sign_img : sign_img.replace('file://', ''),
});
Object.keys(body).forEach((key) => {
data.append(key, body[key]);
});
return data;
};
const onPress = async () => {
const titles = [
'loại thẻ',
'số thẻ',
'ảnh CNND mặt trước',
'ảnh CMND mặt sau',
'ảnh chữ ký',
];
const index = checkFormatArray([type, cmnd, urlFont, urlBack, urlSign]);
const index = checkFormatArray([type, urlFont, urlBack, urlSign]);
if (index === true) {
props.navigation.navigate('BankInfor', {
body: {
cmnd,
const data = createFormData(urlFont, urlBack, urlSign, {
card_type: type.value,
date_range: convertTime(date_range),
uid: props.user.uid,
...props.route.params,
},
img: {
urlFont,
urlBack,
urlSign,
},
});
props.showLoading();
const res = await verifyAccountApi(data);
props.hideLoading();
if (res.data.code == 200) {
setTimeout(() => {
Alert.alert('Thông báo!', res.data.message);
}, 500);
} else {
Alert.alert('Vui lòng thêm ' + titles[index]);
setTimeout(() => {
Alert.alert('Thông báo!', res.data.message);
}, 500);
}
} else {
Alert.alert('Vui lòng điền ' + titles[index]);
}
};
// const onNextPress = () => {
// const titles = [
// 'loại thẻ',
// 'số thẻ',
// 'ảnh CNND mặt trước',
// 'ảnh CMND mặt sau',
// 'ảnh chữ ký',
// ];
// const index = checkFormatArray([urlFont, urlBack, urlSign]);
// if (index === true) {
// props.navigation.navigate('BankInfor', {
// body: {
// cmnd,
// card_type: type.value,
// date_range: convertTime(date_range),
// ...props.route.params,
// },
// img: {
// urlFont,
// urlBack,
// urlSign,
// },
// });
// } else {
// Alert.alert('Vui lòng thêm ' + titles[index]);
// }
// };
return (
<KeyboardAvoidingView
behavior={Platform.Os === 'ios' ? 'padding' : 'height'}
style={{flex: 1}}
keyboardVerticalOffset={-50}>
<ScrollView showsVerticalScrollIndicator={false}>
<ScrollView style={{flex: 1}} showsVerticalScrollIndicator={false}>
<View
style={{
flex: 1,
......@@ -101,7 +170,7 @@ const Profile = (props) => {
setType(items);
}}
/>
{/*
<TextField
isNumber={true}
title={'Số thẻ'}
......@@ -111,12 +180,13 @@ const Profile = (props) => {
value={date_range}
onValueChange={(val) => setDate_range(val)}
title={'Ngày cấp'}
/>
/> */}
<View
style={{
flexDirection: 'row',
justifyContent: 'space-between',
flexWrap: 'wrap',
flex: 1,
}}>
<PickerImgUni
onSelectImg={(path) => setUrlFont(path)}
......@@ -131,19 +201,20 @@ const Profile = (props) => {
title={'Ảnh chữ ký'}
/>
</View>
<TouchableOpacity onPress={onNextPress} style={styles.btnNext}>
<Image
style={{width: 30, height: 30}}
source={R.images.iconRight1}
/>
</TouchableOpacity>
</View>
</ScrollView>
<View style={styles.btnSend}>
<Button title={'Xác minh'} onClick={onPress} />
</View>
</KeyboardAvoidingView>
);
};
const styles = StyleSheet.create({
btnSend: {
width: '100%',
marginBottom: 30,
},
btnNext: {
borderRadius: 30,
backgroundColor: '#1473E6',
......@@ -164,4 +235,9 @@ const styles = StyleSheet.create({
},
});
export default Profile;
const mapStateToProps = (state) => {
return {
user: state.userReducer,
};
};
export default connect(mapStateToProps, {showLoading, hideLoading})(Profile);
......@@ -81,8 +81,6 @@ const Login = (props) => {
}
};
return (
<View
style={{
......
......@@ -13,18 +13,20 @@ import {
Platform,
} from 'react-native';
import R from '../../../../assets/R';
const dataTest = [
{
value: '1',
name: '2020',
},
{
value: '2',
name: '2021',
},
import RadioForm, {
RadioButton,
RadioButtonInput,
RadioButtonLabel,
} from 'react-native-simple-radio-button';
import PickerDate from '../../../../components/Picker/PickerDate';
import TextMulti from '../../../../components/Input/TextMulti';
import {connect} from 'react-redux';
import {showLoading, hideLoading} from '../../../../actions/loadingAction';
import {converStringToDate} from '../../../../Config/Functions';
var radio_props = [
{label: 'Nam', value: 0},
{label: 'Nữ', value: 1},
];
const {width} = Dimensions.get('window');
import TextField from '../../../../components/Input/TextField';
......@@ -35,6 +37,7 @@ import Icon from 'react-native-vector-icons/Ionicons';
const GeneralInfor = (props) => {
const [Select, setSelect] = useState('ABC');
const [bank, setBank] = useState();
const [account, setAccount] = useState();
return (
<KeyboardAvoidingView
......@@ -44,15 +47,21 @@ const GeneralInfor = (props) => {
<ScrollView style={{flex: 1}} showsVerticalScrollIndicator={false}>
<View style={styles.container}>
<TextField
value={props.user.fullname}
title={'Họ và tên'}
onChangeText={(val) => console.log(val)}
/>
<TextField
title={'Điện thoại'}
value={props.user.phone}
onChangeText={(val) => console.log(val)}
/>
<TextField title={'Email'} onChangeText={(val) => console.log(val)} />
<TextField
title={'Email'}
value={props.user.email}
onChangeText={(val) => console.log(val)}
/>
{/*
<TextInput
style={styles.customTxt}
......@@ -60,49 +69,34 @@ const GeneralInfor = (props) => {
placeholder="0000"
/> */}
<Text style={styles.txtTitle}>Gii tính</Text>
<RadioForm
radio_props={radio_props}
labelStyle={{fontSize: getFontXD(42)}}
formHorizontal={true}
style={styles.row}
initial={0}
onPress={(value) => {
setAccount({value: value});
}}
/>
<View style={styles.status}>
<View
style={{
flexDirection: 'row',
justifyContent: 'center',
alignItems: 'center',
}}>
<View style={styles.customAdd}>
<Text style={{fontSize: getFontXD(42), color: '#929292'}}>
+
</Text>
</View>
<Text style={styles.txtTitle}>Trng thái</Text>
</View>
<Text style={{color: '#4FCD8D', fontSize: getFontXD(42)}}>
Đã xác minh
</Text>
</View>
<View
style={{
borderTopWidth: 1,
borderTopColor: '#DBDBDB',
marginTop: 20,
paddingTop: 10,
}}>
<TextField
title={'Số tài khoản ngân hàng'}
onChangeText={(val) => console.log(val)}
placeHolder="Nhập số tài khoản ngân hàng"
<PickerDate
value={converStringToDate(props.user.birthday)}
title={'Ngày sinh'}
/>
<Text style={styles.txtTitle}>Tên ngân hàng</Text>
<PickerItem
width={width - 20}
data={dataTest}
onValueChange={(value, items) => {
setBank(items);
}}
/>
<TextMulti value={props.user.address} title={'Địa chỉ'} />
</View>
</ScrollView>
<View style={styles.footer}>
<TouchableOpacity
onPress={() => console.log('Hello')}
......@@ -110,8 +104,6 @@ const GeneralInfor = (props) => {
<Text style={styles.txtBtn}>Cp nht</Text>
</TouchableOpacity>
</View>
</View>
</ScrollView>
</KeyboardAvoidingView>
);
};
......@@ -146,18 +138,18 @@ const styles = StyleSheet.create({
status: {
flexDirection: 'row',
justifyContent: 'space-between',
marginTop: 10,
marginVertical: 10,
alignItems: 'center',
},
footer: {
justifyContent: 'center',
alignItems: 'center',
marginTop: 30,
marginBottom: 30,
},
btn: {
width: WIDTHXD(521),
height: HEIGHTXD(120),
borderRadius: 15,
borderRadius: 10,
backgroundColor: '#1C6AF6',
justifyContent: 'center',
alignItems: 'center',
......@@ -181,6 +173,20 @@ const styles = StyleSheet.create({
paddingTop: 5,
},
row: {
height: HEIGHTXD(109),
width: '100%',
justifyContent: 'space-between',
marginVertical: 5,
width: 250,
},
});
export default GeneralInfor;
const mapStateToProps = (state) => {
return {
user: state.userReducer,
};
};
export default connect(mapStateToProps, {showLoading, hideLoading})(
GeneralInfor,
);
......@@ -12,85 +12,94 @@ import {
import R from '../../../assets/R';
import {getFontXD} from '../../../Config/Functions';
import Item from './item';
import {getListNew} from '../../../apis/Functions/NewFeed';
const fillers = [
{
id: '1',
title: 'Ngoại hối',
},
{
id: '2',
title: 'Cổ phiếu',
},
{
id: '3',
title: 'Hàng hoá',
},
{
id: '4',
title: 'Chỉ số',
},
];
import {getListNew, getListCategoryNew} from '../../../apis/Functions/NewFeed';
const NewFeed = (props) => {
const [selected, setSelected] = useState(1);
const [selected, setSelected] = useState('');
const [page, setPage] = useState(1);
const [data, setData] = useState([]);
const [tottalPage, setTotalPage] = useState(1);
const [isRefresh, setisRefresh] = useState(false);
const [fillters, setFillters] = useState([]);
const getCategory = async () => {
const res = await getListCategoryNew({
keyword: '',
platform: Platform.OS,
page_size: 20,
page_index: 1,
});
if ((res.data.code = 200 && res.data.data)) {
setFillters(res.data.data);
console.log(res.data.data);
} else {
Alert.alert('Thông báo!', res.data.message);
}
};
useEffect(() => {
getData();
getCategory();
}, []);
useEffect(() => {
getData();
}, [selected]);
const getData = async () => {
setisRefresh(true);
setPage(1);
const res = await getListNew({
keyword: '',
category_id: '',
category_id: selected,
platform: Platform.OS,
page_size: 10,
page_index: page,
page_index: 1,
});
if ((res.data.code = 200 && res.data.data)) {
setData(res.data.data);
setTotalPage(res.data.meta.pages);
} else {
Alert.alert('Thông báo!', res.data.message);
}
setisRefresh(false);
};
const onRefresh = () => {
console.log('On Refersh');
getData();
};
const onLoadMore = () => {
console.log('Load more');
if (page < tottalPage) getDataLoadMore();
};
// const getDataLoadMore=async ()=>{
// setisRefresh(true)
// const res=await GetListNotification({keyword:txtSearch,page_index:page+1,page_size:8,platform:Platform.OS})
// setPage(page+1)
// if(res.data.code==200){
// setData(data.concat(res.data.data))
// }
// setisRefresh(false)
// }
// const onLoadMore=()=>{
// if(page<tottalPage)
// getDataLoadMore()
const getDataLoadMore = async () => {
setisRefresh(true);
const res = await getListNew({
keyword: '',
category_id: '',
platform: Platform.OS,
page_size: 10,
page_index: page + 1,
});
setPage(page + 1);
// }
if (res.data.code == 200) {
setData(data.concat(res.data.data));
}
setisRefresh(false);
};
return (
<View style={{flex: 1, backgroundColor: 'white'}}>
<View style={styles.fillterView}>
<ScrollView horizontal showsHorizontalScrollIndicator={false}>
{fillers.map((e) => (
{fillters.map((e) => (
<TouchableOpacity
onPress={() => setSelected(e.id)}
onPress={() => {
console.log(e.id);
setSelected(e.id);
}}
key={e.id}
style={[
styles.item,
......@@ -101,7 +110,7 @@ const NewFeed = (props) => {
styles.txt,
e.id == selected ? {color: '#1C6AF6'} : {},
]}>
{e.title}
{e.name}
</Text>
</TouchableOpacity>
))}
......
......@@ -6,3 +6,8 @@ export const getListNew = async (body) =>
GetData(url.urlGetListNew, body)
.then((res) => res)
.catch((err) => err);
export const getListCategoryNew = async (body) =>
GetData(url.urlGetCategoryNew, body)
.then((res) => res)
.catch((err) => err);
......@@ -10,4 +10,5 @@ export default {
urlVerifyAccount: root + 'api/v1/customers/verify-account',
urlGetListNew: root + '/api/v1/news/posts',
urlGetCategoryNew: root + 'api/v1/news/categories',
};
......@@ -104,10 +104,9 @@ const renderLabel = (status) => {
const HeaderHome = (props) => {
const navigate = useNavigation();
console.log(props.user.status);
const copyToClipboard = () => {
Alert.alert('Đã sao chép!');
Alert.alert('Đã sao chép link giới thiệu!');
Clipboard.setString(props.user.sponsor_url);
};
......@@ -211,7 +210,7 @@ const styles = StyleSheet.create({
},
containerTop: {
backgroundColor: 'white',
height: HEIGHTXD(856),
height: 290,
width: '90%',
borderRadius: 10,
shadowColor: '#000',
......
......@@ -15,7 +15,6 @@ import {
} from 'react-native';
import R from '../../assets/R';
import {getFontXD, HEIGHT, WIDTHXD} from '../../Config/Functions';
import LinearGradient from 'react-native-linear-gradient';
import {connect} from 'react-redux';
import {HEIGHTXD} from '../../Config/Functions';
import Modal from 'react-native-modal';
......
......@@ -4,7 +4,7 @@ import {HEIGHTXD, WIDTHXD, getFontXD} from '../../Config/Functions';
import R from '../../assets/R';
const TextField = (props) => {
const {title, onChangeText, maxLength} = props;
const {title, onChangeText, maxLength, value} = props;
return (
<View style={{marginVertical: 5}}>
......@@ -18,6 +18,7 @@ const TextField = (props) => {
</Text>
<TextInput
maxLength={maxLength}
value={value}
onChangeText={(val) => onChangeText(val)}
multiline={true}
numberOfLines={3}
......
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