From 070680add8e2f80fd7d6e69453f7851ee5610048 Mon Sep 17 00:00:00 2001 From: freddyheredia4 Date: Sat, 5 Aug 2023 09:47:40 -0500 Subject: [PATCH] Mejoras en pedidos --- .vscode/settings.json | 3 +- android/app/build.gradle | 1 + package-lock.json | 21 ++++++ package.json | 1 + src/components/OneToMany.tsx | 97 ++++++++++++++++++++++---- src/screens/salesorder/ProductItem.tsx | 2 +- 6 files changed, 109 insertions(+), 16 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index d1431bf..41e65be 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,4 +1,5 @@ { "java.compile.nullAnalysis.mode": "automatic", - "eslint.enable": false + "eslint.enable": false, + "java.configuration.updateBuildConfiguration": "automatic" } \ No newline at end of file diff --git a/android/app/build.gradle b/android/app/build.gradle index eb7fa3c..d44a46d 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -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") diff --git a/package-lock.json b/package-lock.json index 5857339..ea7e362 100644 --- a/package-lock.json +++ b/package-lock.json @@ -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", diff --git a/package.json b/package.json index 8bc2deb..152ef59 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/components/OneToMany.tsx b/src/components/OneToMany.tsx index 972b8bc..035e115 100644 --- a/src/components/OneToMany.tsx +++ b/src/components/OneToMany.tsx @@ -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 = ({}) => { + } - 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 ( - - <> - {item.producto.nombre} - + + + + + + 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' + /> + + + + {item.producto.nombre} + + {item.precio * item.cantidad} + $ + + + + setPrecio(item.producto.id, Number(value))} + placeholder={'Precio'} + keyboardType="decimal-pad" + className='p-2 h-10 text-right ' + /> + / unidad + + + + + + + + + + + } - /> - {lines.map((line: SalesOrderLine) =>({line.producto.id}))} ) } diff --git a/src/screens/salesorder/ProductItem.tsx b/src/screens/salesorder/ProductItem.tsx index 2da3dd0..45af07a 100644 --- a/src/screens/salesorder/ProductItem.tsx +++ b/src/screens/salesorder/ProductItem.tsx @@ -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';