-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSubmitApplication.tsx
87 lines (79 loc) · 2.09 KB
/
SubmitApplication.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
/** @format */
import React, { useState } from "react";
import { View, Text, Button, TextInput, StyleSheet } from "react-native";
import { db } from "../Environment/config";
import {
collection,
updateDoc,
arrayUnion,
query,
where,
getDocs,
doc,
} from "firebase/firestore";
type propType = {
navigation: any;
};
const ApplyToProperty: React.FC<propType> = ({ navigation }) => {
const property = navigation.getParam("property");
//const email = '[email protected]'
const styles = getStyles();
const [email, setEmail] = useState("");
const [name, setName] = useState("");
const [addr, setAddr] = useState("");
return (
<View style={styles.container}>
<View style={styles.card}>
<Text style={styles.h1}>Apply to {property.name}</Text>
</View>
<View style={styles.card}>
<Text style={styles.p}>email:</Text>
<TextInput value={email} onChangeText={setEmail} />
<Text style={styles.p}>Your Name:</Text>
<TextInput value={name} onChangeText={setName} />
<Text style={styles.p}>Previous Address:</Text>
<TextInput value={addr} onChangeText={setAddr} />
<Button
onPress={async () => {
const appStr = email + ":" + name + ":" + addr;
var docName = property.name;
const docRef = doc(db, "housing", docName);
await updateDoc(docRef, {
Applications: arrayUnion(appStr),
});
navigation.goBack();
}}
title="Submit Application"
/>
</View>
</View>
);
};
const getStyles = () => {
return StyleSheet.create({
container: {
padding: 20,
backgroundColor: "#d1fff4",
flex: 1,
},
card: {
backgroundColor: "#fff",
borderRadius: 5,
padding: 20,
marginBottom: 20,
},
h1: {
fontSize: 18,
color: "#000",
},
h2: {
fontSize: 14,
color: "#000",
},
p: {
fontSize: 12,
color: "#000",
},
});
};
export default ApplyToProperty;