Mejoras en pedidos

master
Freddy Heredia 2 years ago
parent f81b0a9914
commit 070680add8

@ -1,4 +1,5 @@
{
"java.compile.nullAnalysis.mode": "automatic",
"eslint.enable": false
"eslint.enable": false,
"java.configuration.updateBuildConfiguration": "automatic"
}

@ -168,3 +168,4 @@ dependencies {
}
apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)
apply from: file("../../node_modules/react-native-vector-icons/fonts.gradle")

21
package-lock.json generated

@ -28,6 +28,7 @@
"react-native-gesture-handler": "^2.9.0",
"react-native-keyboard-aware-scroll-view": "^0.9.5",
"react-native-linear-gradient": "^2.6.2",
"react-native-numeric-input": "^1.9.1",
"react-native-safe-area-context": "^4.5.0",
"react-native-screens": "^3.20.0",
"react-native-select-dropdown": "^3.3.4",
@ -14061,6 +14062,26 @@
"react-native": "*"
}
},
"node_modules/react-native-numeric-input": {
"version": "1.9.1",
"resolved": "https://registry.npmjs.org/react-native-numeric-input/-/react-native-numeric-input-1.9.1.tgz",
"integrity": "sha512-uJiMjundXHiBcBLHgSqbfSjLdBM+4OBgLJLSsYG5/+XST5XWufsU8eZaEsn1miOkhjj2B7WgshjNX2Qm+4n3kw==",
"dependencies": {
"prop-types": "^15.6.1",
"react-native-pixel-perfect": "^1.0.1"
},
"peerDependencies": {
"react-native-vector-icons": "^9.*"
}
},
"node_modules/react-native-pixel-perfect": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/react-native-pixel-perfect/-/react-native-pixel-perfect-1.0.2.tgz",
"integrity": "sha512-0IvYCNkxuQbQC9q4tI+C3i6o38nbx916p7gBRBWuPxDhKBCuTkVV3VukcfW6vtjRlwQm6kwQcF9OtI+yUBt+YA==",
"peerDependencies": {
"react-native": "*"
}
},
"node_modules/react-native-safe-area-context": {
"version": "4.5.0",
"resolved": "https://registry.npmjs.org/react-native-safe-area-context/-/react-native-safe-area-context-4.5.0.tgz",

@ -30,6 +30,7 @@
"react-native-gesture-handler": "^2.9.0",
"react-native-keyboard-aware-scroll-view": "^0.9.5",
"react-native-linear-gradient": "^2.6.2",
"react-native-numeric-input": "^1.9.1",
"react-native-safe-area-context": "^4.5.0",
"react-native-screens": "^3.20.0",
"react-native-select-dropdown": "^3.3.4",

@ -1,32 +1,101 @@
import { FC, useContext } from 'react'
import { FlatList, ScrollView, Text, View } from 'react-native'
import { FlatList, Image, ScrollView, Text, TextInput, View } from 'react-native'
import { SalesOrderContext } from '../screens/salesorder/SalesOrderContex';
import { InputNumber } from './InputNumber';
import NumericInput from 'react-native-numeric-input'
import { CardItem } from './CardItem';
import { Avatar } from '@ui-kitten/components';
const OneToMany = () => {
interface Props {
//control: any,
//fields: any
}
const { lines, setLines } = useContext(SalesOrderContext);
const setCantidad = (productoId: number, nuevaCantidad: number) => {
setLines(lines.map(line => {
if (line.producto.id == productoId) {
line.cantidad = nuevaCantidad;
}
return line;
}))
const OneToMany: FC<Props> = ({}) => {
}
const { lines } = useContext(SalesOrderContext);
const setPrecio = (productoId: number, nuevoPrecio: number) => {
setLines(lines.map(line => {
if (line.producto.id == productoId) {
line.precio = nuevoPrecio;
}
return line;
}))
}
return (
<ScrollView >
<FlatList
data={lines}
renderItem={({ item }) =>
<View >
<>
<Text className='text-xl text-center my-4'>{item.producto.nombre}</Text>
</>
<View className='flex-row'>
<CardItem>
<View className='flex-row'>
<View>
<Image
source={{ uri: 'https://images.philips.com/is/image/PhilipsConsumer/271V8_69-IMS-en_HK?$jpglarge$&wid=1250' }}
style={{
width: 100,
height: 80
}}
/>
<NumericInput
value={item.cantidad}
onChange={value => setCantidad(item.producto.id, value)}
onLimitReached={(isMax, msg) => console.log(isMax, msg)}
minValue={1}
totalWidth={100}
totalHeight={50}
iconSize={50}
step={1}
valueType='integer'
rounded
textColor='#B0228C'
iconStyle={{ backgroundColor: 'white' }}
rightButtonBackgroundColor='#1d4ed8'
leftButtonBackgroundColor='#0ea5e9'
type='plus-minus'
/>
</View>
<View className='mx-4'>
<Text className='text-xl text-center'>{item.producto.nombre}</Text>
<View className='flex-row justify-center'>
<Text className=' my-2 font-bold text-black text-4xl text-center'>{item.precio * item.cantidad}</Text>
<Text className=' my-2 ml-2 text-3xl text-left text-teal-500'>$</Text>
</View>
<View className='flex-row items-center border-b-2 border-sky-500'>
<TextInput
id={'precio'}
value={String(item.precio)}
onChangeText={value => setPrecio(item.producto.id, Number(value))}
placeholder={'Precio'}
keyboardType="decimal-pad"
className='p-2 h-10 text-right '
/>
<Text>/ unidad</Text>
</View>
</View>
</View>
</CardItem>
</View>
}
/>
{lines.map((line: SalesOrderLine) =>(<Text key={line.producto.id}>{line.producto.id}</Text>))}
</ScrollView>
)
}

@ -1,4 +1,4 @@
import React, { FC, useContext, useEffect, useState } from 'react'
import React, { FC, useContext } from 'react'
import { FlatList, Text, TouchableOpacity, View } from 'react-native'
import { useNavigation } from '@react-navigation/native';

Loading…
Cancel
Save