diff --git a/src/components/auth/Login.tsx b/src/components/auth/Login.tsx index 86c33e3..38b2c6b 100644 --- a/src/components/auth/Login.tsx +++ b/src/components/auth/Login.tsx @@ -1,11 +1,16 @@ -import { useState } from "react"; -import { TextInput, View, StyleSheet, Text } from "react-native"; +import { + TextInput, + View, + StyleSheet, + Text, + Keyboard, + TouchableWithoutFeedback, +} from "react-native"; import FormStyles from "../../styles/Forms"; import Button from "../Button"; import TextStyles from "../../styles/Text"; import { Formik } from "formik"; import * as Yup from "yup"; -import { login } from "../../services/auth"; import useAuth from "../../hooks/useAuth"; const LoginSchema = Yup.object().shape({ @@ -17,64 +22,66 @@ const Login = () => { const { fetchingLogin, errorLogin, login } = useAuth(); return ( - - Welcome to Resty - - Please authenticate to access the platform - + Keyboard.dismiss()}> + + Welcome to Resty + + Please authenticate to access the platform + - - login(values.email, values.password)} - > - {({ handleChange, handleBlur, handleSubmit, errors, values }) => ( - <> - - {errors.email && ( - {errors.email} - )} + + login(values.email, values.password)} + > + {({ handleChange, handleBlur, handleSubmit, errors, values }) => ( + <> + + {errors.email && ( + {errors.email} + )} - - {errors.password && ( - - {errors.password} - - )} + + {errors.password && ( + + {errors.password} + + )} - {errorLogin && ( - - Invalid email or password - - )} + {errorLogin && ( + + Invalid email or password + + )} - - - )} - - + + + )} + + + ); }; diff --git a/src/components/products/Product.tsx b/src/components/products/Product.tsx index 660defd..0bad5b6 100644 --- a/src/components/products/Product.tsx +++ b/src/components/products/Product.tsx @@ -1,7 +1,14 @@ import Text from "../Text"; import { ProductProps } from "../../types/stack/ProductStack"; import { formatPrice } from "../../config/helpers"; -import { View, StyleSheet, Pressable, TextInput } from "react-native"; +import { + View, + StyleSheet, + Pressable, + TextInput, + Keyboard, + TouchableWithoutFeedback, +} from "react-native"; import ContainerStyle from "../../styles/Containers"; import Header from "../headers/Header"; import Divider from "../Divider"; @@ -68,102 +75,104 @@ const Product = ({ navigation, route }: ProductProps) => { }; return ( - -
- {loading ? ( - - ) : ( - - )} - - } - goBack={() => navigation.navigate("Products")} - /> + Keyboard.dismiss()}> + +
+ {loading ? ( + + ) : ( + + )} + + } + goBack={() => navigation.navigate("Products")} + /> - + - - - Name: - - {editing ? ( - - setProductDetails((prevDetails) => ({ - ...prevDetails, - editedName: text, - })) - } - style={{ fontSize: 16 }} - /> - ) : ( - - {productDetails.currentName} + + + Name: - )} - - - - - - - Price: - - {editing ? ( - { - const cleanedText = text.replace(",", "."); - const validated = cleanedText.match(/^(\d*\.{0,1}\d{0,2}$)/); - if (validated) { + {editing ? ( + setProductDetails((prevDetails) => ({ ...prevDetails, - editedPrice: cleanedText, - })); + editedName: text, + })) } - }} - style={{ fontSize: 16 }} - keyboardType="numeric" - /> - ) : ( - - {formatPrice(productDetails.currentPrice)} + style={{ fontSize: 16 }} + /> + ) : ( + + {productDetails.currentName} + + )} + + + + + + + Price: - )} - + {editing ? ( + { + const cleanedText = text.replace(",", "."); + const validated = cleanedText.match(/^(\d*\.{0,1}\d{0,2}$)/); + if (validated) { + setProductDetails((prevDetails) => ({ + ...prevDetails, + editedPrice: cleanedText, + })); + } + }} + style={{ fontSize: 16 }} + keyboardType="numeric" + /> + ) : ( + + {formatPrice(productDetails.currentPrice)} + + )} + - + - - - Category: - - - {categoryName} - - + + + Category: + + + {categoryName} + + - + - - + + + ); };