Skip to content

Commit bb37fa6

Browse files
committed
Get Statement Done
1 parent d15b9a1 commit bb37fa6

File tree

1 file changed

+131
-5
lines changed

1 file changed

+131
-5
lines changed

Admin_Screens/admin_statement.js

Lines changed: 131 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,17 +31,143 @@ export default function Admin_Statements({navigation}){
3131

3232
const [modalopen, setmodalopen] = useState(false);
3333

34+
const [type, settype] = useState("");
35+
36+
const [newnotes, setnewnotes] = useState("");
37+
const [modal2open, setmodal2open] = useState(false);
38+
39+
const [hidden, setHidden]=useState([false, false, false, false, false, false, false, false, false]);
40+
41+
function handle2modal(){
42+
setmodal2open(false);
43+
}
44+
3445
function handlemodal(){
3546
setmodalopen(false);
3647
}
48+
49+
function toggleAns(key){
50+
let x=hidden.slice();
51+
x[key-1]=!x[key-1];
52+
setHidden(x);
53+
}
54+
55+
const [received, setReceived] = useState([]);
56+
const [sent, setSent] = useState([]);
57+
const [exists, setExists]= useState(true);
3758

38-
function getstatement(){
59+
async function getstatement(){
60+
setExists(true);
61+
const rc=[];
62+
const st=[];
63+
const subscriber=await firestore().collection("AccountData")
64+
.get()
65+
.then(querySnapshot=>{
66+
querySnapshot.forEach(documentSnapshot=>{
67+
const u=documentSnapshot.id;
68+
if(u===email){
69+
setExists(true);
70+
const d=documentSnapshot.data();
71+
if(d.Recieved!==undefined){
72+
const length=d.Recieved.length;
73+
for(let i=0; i<length; i++){
74+
rc.push({key:i, data:d.Recieved[i], type:"Received"});
75+
rc[i]["key"] = i+1;
76+
}
3977

78+
}
79+
if(d.Sent!==undefined){
80+
const length=d.Sent.length;
81+
for(let i=0; i<length; i++){
82+
st.push({key:i, data:d.Sent[i], type:"Sent"});
83+
st[i]["key"] = i+1;
84+
}
85+
}
86+
}
87+
});
88+
});
89+
setReceived(rc);
90+
setSent(st);
91+
if(rc.length === 0 && st.length === 0){
92+
setExists(false);
93+
}
4094
}
95+
96+
function handleShit(){
97+
if(exists){
98+
return(
99+
<View style={{flex:1}}>
100+
<FlatList
101+
data={received}
102+
renderItem={({ item }) => (
103+
<View style={{backgroundColor: '#841851', borderRadius: 15,paddingTop: 25,paddingBottom: 25,paddingVertical:15,borderBottomWidth:1.5,borderTopWidth:0,borderColor:'#14062E',paddingHorizontal:10, margin: 10, marginBottom: 0}}>
104+
<View style = {{flex:1,flexDirection:'row'}} >
105+
<Text style={[{fontSize:20,color:'white', flex: 10}, {fontWeight:'bold'}]}>Recieved</Text>
106+
107+
<TouchableOpacity disabled={false} style={{flex:1}} onPress={()=>toggleAns(item.key)}>
108+
<Text style={[{fontSize:25,fontWeight:'bold'}, {color:'#000'}]}>{!hidden[item.key-1]?"\u{1F448}":"\u{1F447}"}</Text>
109+
</TouchableOpacity>
110+
</View>
111+
{hidden[item.key-1]?<Text style={[{fontSize:20}, {fontWeight:'bold', color: '#000'}]}>Name: {item.data.Name}</Text>:<></>}
112+
{hidden[item.key-1]?<Text style={[{fontSize:20, fontWeight: 'bold'},{color:'#000'}]}>Account Number: {item.data["Account Number"]}</Text>:<></>}
113+
{hidden[item.key-1]?<Text style ={[{fontSize:20, fontWeight: 'bold'},{color:'#000'}]}>Bank: {item.data.Bank}</Text>:<></>}
114+
{hidden[item.key-1]?<Text style ={[{fontSize:20, fontWeight: 'bold'},{color:'#000'}]}>Date: {item.data.Date}</Text>:<></>}
115+
{hidden[item.key-1]?<Text style ={[{fontSize:20, fontWeight: 'bold'},{color:'#000'}]}>Balance: {item.data.Money}</Text>:<></>}
116+
117+
118+
</View>
119+
)}
120+
/>
121+
122+
<FlatList
123+
data={sent}
124+
renderItem={({ item }) => (
125+
<View style={{backgroundColor: '#841851', borderRadius: 15,paddingTop: 25,paddingBottom: 25,paddingVertical:15,borderBottomWidth:1.5,borderTopWidth:0,borderColor:'#14062E',paddingHorizontal:10, margin: 10, marginBottom: 0, marginTop: 0}}>
126+
<View style = {{flex:1,flexDirection:'row'}} >
127+
<Text style={[{fontSize:20,color:'white', flex: 10}, {fontWeight:'bold'}]}>Sent</Text>
128+
129+
<TouchableOpacity disabled={false} style={{flex:1}} onPress={()=>toggleAns(item.key)}>
130+
<Text style={[{fontSize:25,fontWeight:'bold'}, {color:'#000'}]}>{!hidden[item.key-1]?"\u{1F448}":"\u{1F447}"}</Text>
131+
</TouchableOpacity>
132+
</View>
133+
{hidden[item.key-1]?<Text style={[{fontSize:20}, {fontWeight:'bold', color: '#000'}]}>Name: {item.data.Name}</Text>:<></>}
134+
{hidden[item.key-1]?<Text style={[{fontSize:20, fontWeight: 'bold'},{color:'#000'}]}>Account Number: {item.data["Account Number"]}</Text>:<></>}
135+
{hidden[item.key-1]?<Text style ={[{fontSize:20, fontWeight: 'bold'},{color:'#000'}]}>Bank: {item.data.Bank}</Text>:<></>}
136+
{hidden[item.key-1]?<Text style ={[{fontSize:20, fontWeight: 'bold'},{color:'#000'}]}>Date: {item.data.Date}</Text>:<></>}
137+
{hidden[item.key-1]?<Text style ={[{fontSize:20, fontWeight: 'bold'},{color:'#000'}]}>Balance: {item.data.Money}</Text>:<></>}
138+
139+
140+
</View>
141+
)}
142+
/>
143+
</View>
144+
);
145+
}else{
146+
return(
147+
<View style={{flex:1, justifyContent: 'center'}}>
148+
<Text style={{margin:10, color:'white', textAlign: 'center', backgroundColor: '#841851', padding: 20, fontSize: 20, fontWeight: 'bold', borderRadius: 10, }}>Sorry! No account statement found for this account.</Text>
149+
</View>
150+
);
151+
}
152+
}
153+
154+
41155
return(
42156
<LinearGradient colors={[ '#1e2127','#000','#1e2127']} style={{flex: 8, justifyContent: 'center'}}>
43157

44-
<Modal visible = {modalopen} animationType = 'slide' transparent = {true}>
158+
159+
<Modal visible = {modal2open} animationType = 'slide' transparent = {true}>
160+
<View style= {{flex: 1,justifyContent: 'flex-end'}}>
161+
<View style={{opacity: .88, backgroundColor: 'black', height: '100%',}}>
162+
{handleShit()}
163+
<TouchableOpacity onPress={() => handle2modal()}><Icon name="arrow-left" size={30} color="#c0c0c0" style = {{marginLeft: 160, marginRight: 160, marginTop: 100, marginBottom: 0}}/></TouchableOpacity>
164+
<Text style = {{marginLeft: 160, marginRight: 160, color: 'white', marginBottom: 15}}>Close</Text>
165+
166+
</View>
167+
</View>
168+
</Modal>
169+
170+
<Modal visible = {modalopen} animationType = 'slide' transparent = {true}>
45171
<View style= {{flex: 1,justifyContent: 'flex-end'}}>
46172
<View style={{opacity: .88, backgroundColor: 'black', height: '100%' }}>
47173

@@ -82,18 +208,18 @@ export default function Admin_Statements({navigation}){
82208

83209
</View>
84210
</View>
85-
</Modal>
211+
</Modal>
86212

87213
<View style={{flex: 1, justifyContent: 'center'}}>
88214
<Text style = {{margin: 10, marginTop: 20, fontSize: 20, fontWeight: 'bold', color: '#841851'}}>Enter Email:</Text>
89215
<TextInput
90216
placeholder="Email Address..."
91-
style={[styles.notification_input, {height: '10%'}]}
217+
style={[styles.notification_input, {height: '14%'}]}
92218
textAlignVertical="top"
93219
placeholderTextColor={"#c0c0c0"}
94220
onChangeText={setemail}
95221
></TextInput>
96-
<TouchableOpacity onPress={() => getstatement()}>
222+
<TouchableOpacity onPress={() => {getstatement() ; setmodal2open(true)}}>
97223
<Text style= {[styles.buttons , {textAlign: 'center', color: '#c0c0c0', marginTop: 20, backgroundColor:'#841851', color: '#c0c0c0', borderColor: '#c0c0c0', borderWidth: 2, paddingBottom: 3}]}>Get Statement</Text>
98224
</TouchableOpacity>
99225
</View>

0 commit comments

Comments
 (0)