Commit 7db51518 authored by khanhkiras98's avatar khanhkiras98

fix UI invoice

parent b54ee956
...@@ -3,24 +3,26 @@ import { StyleSheet } from "react-native"; ...@@ -3,24 +3,26 @@ import { StyleSheet } from "react-native";
const styles = StyleSheet.create({ const styles = StyleSheet.create({
inputLogin: { container: {
flexDirection: "row", flexDirection: 'row',
height: 40, padding: 10,
alignItems: "center",
borderBottomColor: '#FFFFFF',
borderBottomWidth: 0.5,
}, },
inputText: { image: {
paddingLeft: 5, width: 60,
paddingBottom: 8, height: 60,
width: '100%',
}, },
validateText: { infoContainer: {
color: 'red', marginLeft: 10,
fontSize: 11, justifyContent: 'space-between',
marginLeft: 0, padding: 5,
alignItems: "center",
}, },
textName: {
fontSize: 16,
fontWeight: 'bold'
},
textInfo: {
fontSize: 16,
}
}); });
export default styles; export default styles;
\ No newline at end of file
...@@ -4,19 +4,22 @@ import { View, Text, Image, TextInput } from 'react-native'; ...@@ -4,19 +4,22 @@ import { View, Text, Image, TextInput } from 'react-native';
import styles from './index.style' import styles from './index.style'
type Props = { type Props = {
drg_drug_cd: string, drg_drug_name: string, price: number, quantity: number image_url:string, drg_drug_cd: string, drg_drug_name: string, price: number, quantity: number
} }
const ItemCartProduct = (props: Props) => { const ItemCartProduct = (props: Props) => {
return ( return (
<View> <View style={styles.container}>
<Text> <Image style={styles.image} source={{ uri: props.image_url }} />
{`${props.drg_drug_cd} - ${props.drg_drug_name}`} <View style={styles.infoContainer}>
</Text> <Text style={styles.textName}>
<Text> {`${props.drg_drug_cd} - ${props.drg_drug_name}`}
{`Giá: ${props.price} - Số lượng: ${props.quantity} - Tổng: ${props.price*props.quantity}VNĐ`} </Text>
</Text> <Text style={styles.textInfo}>
{`Giá: ${props.price} - Số lượng: ${props.quantity} - Tổng: ${props.price*props.quantity} VNĐ`}
</Text>
</View>
</View> </View>
); );
}; };
......
...@@ -8,6 +8,7 @@ export type Product = { ...@@ -8,6 +8,7 @@ export type Product = {
drg_drug_name: string, drg_drug_name: string,
drug_id: number, drug_id: number,
drug_unit_id: number, drug_unit_id: number,
dosage: string
inv_id: number, inv_id: number,
lot: string, lot: string,
price: number, price: number,
......
...@@ -20,6 +20,7 @@ import axios from "axios"; ...@@ -20,6 +20,7 @@ import axios from "axios";
import config from "../../configs" import config from "../../configs"
import ItemCartProduct from '../../components/ItemCartProduct'; import ItemCartProduct from '../../components/ItemCartProduct';
import { RootState } from '../../redux/reducers'; import { RootState } from '../../redux/reducers';
import { Product } from '../../model/cart';
const App = () => { const App = () => {
const navigation = useNavigation() const navigation = useNavigation()
...@@ -54,19 +55,19 @@ const App = () => { ...@@ -54,19 +55,19 @@ const App = () => {
> >
<Image style={styles.iconAdd} <Image style={styles.iconAdd}
source={require('../../assets/icon/iconHome/icon-cart-2.jpg')} /> source={require('../../assets/icon/iconHome/icon-cart-2.jpg')} />
<Text style={styles.textAdd}>Đơn hàng của bạn chưa có</Text> <Text style={styles.textAdd}>Thêm sản phẩm vào</Text>
<Text style={styles.textAdd}>sản phẩm nào</Text> <Text style={styles.textAdd}>hóa đơn</Text>
</TouchableOpacity> </TouchableOpacity>
) )
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
const products = useSelector((state) => state.product) const products = useSelector((state: RootState) => state.product.data)
console.log('///////////////////////////////////////////////////////////////////////////////\n', products) console.log('///////////////////////////////////////////////////////////////////////////////\n', products)
const [product, setProduct] = useState(products) const [product, setProduct] = useState(products)
useEffect(() => { useEffect(() => {
setProduct(products); setProduct(products);
}, [products]); }, [products]);
//---------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------
const cartProducts = useSelector((state:RootState) => state.cart.products) const cartProducts = useSelector((state: RootState) => state.cart.products)
console.log('CART: ', cartProducts) console.log('CART: ', cartProducts)
const sumCart = (product: Array<Data>) => { const sumCart = (product: Array<Data>) => {
let sum = 0 let sum = 0
...@@ -81,10 +82,11 @@ const App = () => { ...@@ -81,10 +82,11 @@ const App = () => {
// const totalAmount = sumCart(cartProducts) // const totalAmount = sumCart(cartProducts)
// console.log('TONG: CART', totalAmount) // console.log('TONG: CART', totalAmount)
const _renderCart = (product: Data) => { const _renderCart = (product: Product) => {
return ( return (
<View > <View >
<ItemCartProduct <ItemCartProduct
image_url='https://image.voso.vn/users/vosoimage/images/71752bbe24f2fe10ffb321ae2387c03b?t%5B0%5D=maxSize%3Awidth%3D256%2Cheight%3D256&t%5B1%5D=compress%3Alevel%3D100&accessToken=0c6bdd26523088c81ced410395f2bce36f325d046a00861c8da30e46ee79a8f8'
drg_drug_cd={product.drg_drug_cd} drg_drug_cd={product.drg_drug_cd}
drg_drug_name={product.drg_drug_name} drg_drug_name={product.drg_drug_name}
price={product.price} price={product.price}
...@@ -93,6 +95,18 @@ const App = () => { ...@@ -93,6 +95,18 @@ const App = () => {
</View> </View>
) )
} }
const ItemSeparatorView = () => {
return (
// Flat List Item Separator ______________________________________________
<View
style={{
height: 1,
width: '100%',
backgroundColor: '#C8C8C8',
}}
/>
);
};
//---------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------
const [amount, setAmount] = useState(35264) const [amount, setAmount] = useState(35264)
const [amountPaid, setAmountPaid] = useState('0') const [amountPaid, setAmountPaid] = useState('0')
...@@ -135,7 +149,7 @@ const App = () => { ...@@ -135,7 +149,7 @@ const App = () => {
//---------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------
const token = useSelector((state:RootState) => state.auth.token); const token = useSelector((state: RootState) => state.auth.token);
console.log('BillToken: ', token) console.log('BillToken: ', token)
const submit = () => { const submit = () => {
console.log('Sending....') console.log('Sending....')
...@@ -149,30 +163,30 @@ const App = () => { ...@@ -149,30 +163,30 @@ const App = () => {
'issue_datetime': "2021-07-05T15:45:16+07:00", 'pay_method': "CS", 'pay_reference': "\"\"", 'status': 2, 'vat': 10, 'issue_datetime': "2021-07-05T15:45:16+07:00", 'pay_method': "CS", 'pay_reference': "\"\"", 'status': 2, 'vat': 10,
//-------------------- //--------------------
'amount': amount, 'amount': amount,
'amount_paid': amount*1.1, 'amount_paid': amount * 1.1,
'amount_vat': amount*0.1, 'amount_vat': amount * 0.1,
'current_pay': 40000, 'current_pay': 40000,
'note': note, 'note': note,
} }
const newProduct = { // const newProduct = {
base_quantity: 1, // base_quantity: 1,
discount: 0, // discount: 0,
discount_type: "VNĐ", // discount_type: "VNĐ",
discount_unit: 0, // discount_unit: 0,
dosage: cartProducts.dosage, // dosage: products.dosage,
drg_drug_cd: cartProducts.drg_drug_cd, // drg_drug_cd: cartProducts.drg_drug_cd,
drg_drug_name: cartProducts.drg_drug_name, // drg_drug_name: cartProducts.drg_drug_name,
drug_id: cartProducts.drug_id, // drug_id: cartProducts.drug_id,
drug_unit_id: cartProducts.drug_unit_id, // drug_unit_id: cartProducts.drug_unit_id,
import_price: 0, // import_price: 0,
inv_id: cartProducts.inv_id, // inv_id: cartProducts.inv_id,
lot: cartProducts.lot, // lot: cartProducts.lot,
price: cartProducts.price, // price: cartProducts.price,
promotion_flg: 0, // promotion_flg: 0,
quantity: 2, // quantity: 2,
unit_id: 14, // unit_id: 14,
unit_name: "Viên" // unit_name: "Viên"
} // }
console.log('function', cartProducts) console.log('function', cartProducts)
const body = { const body = {
'invoice': invoice, 'invoice': invoice,
...@@ -242,8 +256,9 @@ const App = () => { ...@@ -242,8 +256,9 @@ const App = () => {
{_renderButtonAdd()} {_renderButtonAdd()}
<FlatList <FlatList
data={cartProducts} data={cartProducts}
ItemSeparatorComponent={ItemSeparatorView}
renderItem={({ item }) => _renderCart(item)} renderItem={({ item }) => _renderCart(item)}
keyExtractor={(item) => item} // keyExtractor={(item) => item}
/> />
{_renderBillDate()} {_renderBillDate()}
{_renderCustomerInfo()} {_renderCustomerInfo()}
......
...@@ -86,6 +86,7 @@ const App = () => { ...@@ -86,6 +86,7 @@ const App = () => {
drg_drug_name: product.drg_drug_name, drg_drug_name: product.drg_drug_name,
drug_id: product.drug_id, drug_id: product.drug_id,
drug_unit_id: product.drug_unit_id, drug_unit_id: product.drug_unit_id,
dosage: product.dosage,
inv_id: product.inv_id, inv_id: product.inv_id,
lot: product.lot, lot: product.lot,
price: product.price, price: product.price,
......
...@@ -1137,7 +1137,7 @@ ...@@ -1137,7 +1137,7 @@
"@react-navigation/core@^5.15.3": "@react-navigation/core@^5.15.3":
version "5.15.3" version "5.15.3"
resolved "https://registry.npmjs.org/@react-navigation/core/-/core-5.15.3.tgz" resolved "https://registry.yarnpkg.com/@react-navigation/core/-/core-5.15.3.tgz#dce7090bf3ea0d302993d742c706825e495b812e"
integrity sha512-3ZdyDInh8qg1kygCNkmh9lFgpDf29lTvPsaMe2mm/qvmxLKSgttWBz07P2fc181aV9jTdgQpzYfWZ5KWT036zw== integrity sha512-3ZdyDInh8qg1kygCNkmh9lFgpDf29lTvPsaMe2mm/qvmxLKSgttWBz07P2fc181aV9jTdgQpzYfWZ5KWT036zw==
dependencies: dependencies:
"@react-navigation/routers" "^5.7.2" "@react-navigation/routers" "^5.7.2"
......
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