matiru
Blockchain-Based Supply Chain Transparency for Agricultural Producegit clone https://github.com/maydayv7/matiru
frontend/components/TransferOwnershipForm.js (1454B)
1import { useState } from "react";
2import { View, TextInput, TouchableOpacity, Text } from "react-native";
3import Scanner from "./Scanner";
4import styles from "../styles";
5
6export default function TransferOwnershipForm({ onSubmit }) {
7 const [produceId, setProduceId] = useState("");
8 const [newOwnerId, setNewOwnerId] = useState("");
9 const [qty, setQty] = useState("");
10 const [salePrice, setSalePrice] = useState("");
11
12 const handleSubmit = () => {
13 onSubmit({
14 produceId,
15 newOwnerId,
16 qty,
17 salePrice,
18 onComplete: () => {
19 setProduceId("");
20 setNewOwnerId("");
21 setQty("");
22 setSalePrice("");
23 },
24 });
25 };
26
27 return (
28 <View>
29 <Scanner value={produceId} onChange={setProduceId} />
30 <TextInput
31 style={styles.input}
32 placeholder="New Owner ID"
33 value={newOwnerId}
34 onChangeText={setNewOwnerId}
35 />
36 <TextInput
37 style={styles.input}
38 placeholder="Quantity"
39 keyboardType="numeric"
40 value={qty}
41 onChangeText={setQty}
42 />
43 <TextInput
44 style={styles.input}
45 placeholder="Sale Price"
46 keyboardType="numeric"
47 value={salePrice}
48 onChangeText={setSalePrice}
49 />
50 <TouchableOpacity style={styles.primaryButton} onPress={handleSubmit}>
51 <Text style={styles.buttonText}>Transfer Ownership</Text>
52 </TouchableOpacity>
53 </View>
54 );
55}