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/NewProduct.tsx b/src/components/products/NewProduct.tsx
index ad78a78..9f822e0 100644
--- a/src/components/products/NewProduct.tsx
+++ b/src/components/products/NewProduct.tsx
@@ -5,7 +5,13 @@ import DropDownPicker from "react-native-dropdown-picker";
import theme from "../../theme";
import { Formik } from "formik";
import * as Yup from "yup";
-import { View, StyleSheet, TextInput } from "react-native";
+import {
+ View,
+ StyleSheet,
+ TextInput,
+ Keyboard,
+ TouchableWithoutFeedback,
+} from "react-native";
import ContainerStyle from "../../styles/Containers";
import Header from "../headers/Header";
import Divider from "../Divider";
@@ -53,126 +59,132 @@ const NewProduct = ({ navigation, route }: NewProductProps) => {
setLoading(false);
};
return (
-
- navigation.navigate("Products")}
- />
+ Keyboard.dismiss()}>
+
+ navigation.navigate("Products")}
+ />
-
+
- {
- onCreateProduct(values.name, values.price, values.category);
- }}
- >
- {({
- handleChange,
- handleBlur,
- handleSubmit,
- setFieldValue,
- errors,
- touched,
- values,
- }) => (
-
-
-
- Product name
-
-
- {touched.name && errors.name && (
- {errors.name}
- )}
-
+ {
+ onCreateProduct(values.name, values.price, values.category);
+ }}
+ >
+ {({
+ handleChange,
+ handleBlur,
+ handleSubmit,
+ setFieldValue,
+ errors,
+ touched,
+ values,
+ }) => (
+
+
+
+ Product name
+
+
+ {touched.name && errors.name && (
+
+ {errors.name}
+
+ )}
+
-
+
-
-
- Price
-
- {
- const cleanedText = text.replace(",", ".");
- setFieldValue("price", cleanedText);
- handleChange("price")(cleanedText);
- }}
- onBlur={handleBlur("price")}
- value={values.price}
- keyboardType="numeric"
- style={{ paddingTop: 5 }}
- >
- {touched.price && errors.price && (
-
- {errors.price}
+
+
+ Price
- )}
-
+ {
+ const cleanedText = text.replace(",", ".");
+ const decimalRegex = /^\d*\.?\d{0,2}$/;
+ if (decimalRegex.test(cleanedText)) {
+ setFieldValue("price", cleanedText);
+ }
+ }}
+ onBlur={handleBlur("price")}
+ value={values.price}
+ keyboardType="numeric"
+ style={{ paddingTop: 5 }}
+ >
+ {touched.price && errors.price && (
+
+ {errors.price}
+
+ )}
+
-
+
-
-
- Category
-
- ({
- label: category.name,
- value: category.id.toString(),
- }))}
- setOpen={(isOpen) => {
- setOpen(isOpen);
- }}
- setValue={(val) => {
- const actualValue = val({});
- setFieldValue("category", actualValue);
- }}
- placeholder="Select a category"
- style={{
- backgroundColor: "transparent",
- minHeight: 30,
- borderWidth: 0,
- borderRadius: 0,
- paddingLeft: 0,
- }}
- dropDownContainerStyle={{
- zIndex: 2,
- borderWidth: 0,
- }}
- placeholderStyle={{
- color: "#C2B7AB",
- }}
- />
- {touched.category && errors.category && (
-
- {errors.category}
+
+
+ Category
- )}
-
-
+ ({
+ label: category.name,
+ value: category.id.toString(),
+ }))}
+ setOpen={(isOpen) => {
+ setOpen(isOpen);
+ }}
+ setValue={(val) => {
+ const actualValue = val({});
+ setFieldValue("category", actualValue);
+ }}
+ placeholder="Select a category"
+ style={{
+ backgroundColor: "transparent",
+ minHeight: 30,
+ borderWidth: 0,
+ borderRadius: 0,
+ paddingLeft: 0,
+ }}
+ dropDownContainerStyle={{
+ zIndex: 2,
+ borderWidth: 0,
+ }}
+ placeholderStyle={{
+ color: "#C2B7AB",
+ }}
+ />
+ {touched.category && errors.category && (
+
+ {errors.category}
+
+ )}
+
+
-
-
- )}
-
-
+
+
+ )}
+
+
+
);
};
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}
+
+
-
+
-
-
+
+
+
);
};