Compare commits
No commits in common. "b210c5a3e2cb81301375e76ebb707401b15add97" and "41f52e67d343d529e018927292a3486a4c2f377e" have entirely different histories.
b210c5a3e2
...
41f52e67d3
@ -5,17 +5,19 @@ import Text from "@components/Text";
|
||||
import { colors } from "@components/style";
|
||||
import * as ImagePicker from "expo-image-picker";
|
||||
import DropDownPicker from "react-native-dropdown-picker";
|
||||
/* import DropdownTheme from "@components/DropdownTheme"; */
|
||||
const DropdownTheme = require("@components/DropdownTheme");
|
||||
import { Platform } from "react-native";
|
||||
|
||||
export default function BeerAdd() {
|
||||
const [b_name, setBName] = useState("");
|
||||
const [b_degree, setBDegree] = useState("");
|
||||
const [b_packaging, setBPackaging] = useState(null);
|
||||
const [b_packaging, setBPackaging] = useState("");
|
||||
const [b_brand, setBBrand] = useState("");
|
||||
const [image, setImage] = useState(null);
|
||||
const [selectPackaging, setSelectedPackaging] = useState();
|
||||
|
||||
const [open, setOpen] = useState(false);
|
||||
const [value, setValue] = useState(null);
|
||||
const [items, setItems] = useState([
|
||||
{ label: "Tank beer", value: "tank" },
|
||||
{ label: "Cask beer", value: "cask" },
|
||||
@ -72,22 +74,6 @@ export default function BeerAdd() {
|
||||
}
|
||||
};
|
||||
|
||||
function validateDegreeInput(text) {
|
||||
let newText = "";
|
||||
let numbers = "0123456789.";
|
||||
|
||||
for (var i = 0; i < text.length; i++) {
|
||||
if (numbers.indexOf(text[i]) > -1) {
|
||||
newText = newText + text[i];
|
||||
setBDegree(newText);
|
||||
} else {
|
||||
// your call back function
|
||||
alert("Please enter numbers only.");
|
||||
setBDegree("");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async function addBeer() {
|
||||
// TODO: after the request - redirect to /beer/{new_beer_id}?; plus some modal about successful state
|
||||
const req = await fetch(`${process.env.EXPO_PUBLIC_API_URL}/beer/add`, {
|
||||
@ -137,22 +123,25 @@ export default function BeerAdd() {
|
||||
style={styles.input}
|
||||
placeholder="Degree"
|
||||
value={b_degree}
|
||||
onChangeText={(text) => validateDegreeInput(text)}
|
||||
onChangeText={(text) => setBDegree(text)}
|
||||
placeholderTextColor="#aaaaaa"
|
||||
/>
|
||||
<TextInput
|
||||
style={styles.input}
|
||||
placeholder="Packaging"
|
||||
value={b_packaging}
|
||||
onChangeText={(text) => setBPackaging(text)}
|
||||
placeholderTextColor="#aaaaaa"
|
||||
keyboardType="numeric"
|
||||
maxLength={3}
|
||||
/>
|
||||
|
||||
<DropDownPicker
|
||||
open={open}
|
||||
value={b_packaging}
|
||||
value={value}
|
||||
items={items}
|
||||
setOpen={setOpen}
|
||||
setValue={setBPackaging}
|
||||
setValue={setValue}
|
||||
setItems={setItems}
|
||||
placeholder={"What are you drinking from?"}
|
||||
theme="DropdownTheme"
|
||||
//searchable={true} //maybe we can use it later...
|
||||
/>
|
||||
<View style={styles.imageContainer}>
|
||||
<Button
|
||||
@ -162,16 +151,12 @@ export default function BeerAdd() {
|
||||
textStyle={styles.imageTextButton}
|
||||
/>
|
||||
|
||||
{Platform.OS != "web" ? (
|
||||
<Button
|
||||
onPress={openCamera}
|
||||
title={"Open camera"}
|
||||
buttonStyle={styles.imageButton}
|
||||
textStyle={styles.imageTextButton}
|
||||
/>
|
||||
) : (
|
||||
false
|
||||
)}
|
||||
<Button
|
||||
onPress={openCamera}
|
||||
title="Open camera"
|
||||
buttonStyle={styles.imageButton}
|
||||
textStyle={styles.imageTextButton}
|
||||
/>
|
||||
|
||||
{image && <Image source={{ uri: image }} style={styles.image} />}
|
||||
</View>
|
||||
|
Loading…
Reference in New Issue
Block a user