Commit ef76de86 authored by Ashan Tharuka's avatar Ashan Tharuka

Merge branch 'it19202464' into 'main'

It19202464

See merge request !8
parents 8dfa5ab4 769ca648
import { StyleSheet, Text, View, TouchableOpacity } from "react-native";
import React from "react";
import { FontAwesome5 } from "@expo/vector-icons";
import { MaterialCommunityIcons } from '@expo/vector-icons';
import { Entypo } from '@expo/vector-icons';
import { useNavigation } from '@react-navigation/native';
export default function Admin({ userid,role }) {
const navigation = useNavigation();
return (
<View style={styles.container}>
<View style={[styles.row,styles.mb5]}>
<TouchableOpacity style={styles.box} onPress={() => navigation.navigate("Station")}>
<FontAwesome5 name="gas-pump" size={40} color="white" />
<Text style={styles.boxText}>Gas Stations</Text>
</TouchableOpacity>
<TouchableOpacity style={styles.box} onPress={() => navigation.navigate("Fuel")}>
<MaterialCommunityIcons name="fuel" size={45} color="white" />
<Text style={styles.boxText}>Fuel</Text>
</TouchableOpacity>
</View>
<View style={styles.row}>
<TouchableOpacity style={styles.box} onPress={() => navigation.navigate("Userslist")}>
<Entypo name="users" size={40} color="white" />
<Text style={styles.boxText}>Users</Text>
</TouchableOpacity>
<TouchableOpacity style={styles.box} onPress={() => navigation.navigate("Browser",{user_id:-1,role:role})}>
<FontAwesome5 name="truck-moving" size={40} color="white" />
<Text style={styles.boxText}>Bowsers</Text>
</TouchableOpacity>
</View>
</View>
);
}
const styles = StyleSheet.create({
container:{
flex:1,
justifyContent:'center'
},
row: {
flexDirection: "row",
justifyContent: "space-evenly",
},
mb5:{
marginBottom:20
},
box: {
backgroundColor: "#f05a36",
width: 150,
height: 150,
justifyContent: "center",
alignItems: "center",
borderRadius: 15,
},
boxText: {
color: "#fff",
fontSize: 18,
marginTop: 10,
},
});
import {
StyleSheet,
Text,
View,
TouchableOpacity,
Image,
FlatList,
} from "react-native";
import React, { useState, useEffect } from "react";
import { Entypo } from "@expo/vector-icons";
import { MaterialCommunityIcons } from "@expo/vector-icons";
import { useIsFocused } from "@react-navigation/native";
export default function Users({navigation}) {
const [loading, setLoading] = useState(true);
const [users, setUsers] = useState([]);
const isFocused = useIsFocused();
const fetchData = () => {
fetch("https://fuel.udarax.me/api/user/list")
.then((response) => response.json())
.then((data) => {
setUsers(data["respond"]);
setLoading(false);
});
};
useEffect(() => {
if (isFocused) {
fetchData();
console.log(users);
console.log(users.length);
}
}, [loading, isFocused]);
const Item = ({ item }) => (
<TouchableOpacity
style={styles.box}
onPress={() => navigation.navigate("Audit",{user_id:item.id,role:'user'})}
>
<View style={styles.row}>
<View style={styles.col70}>
<Text style={styles.boxTitle}>{item.name}</Text>
<Text style={styles.boxtext}>{item.email}</Text>
<Text style={styles.boxtext}>{item.phone}</Text>
</View>
<View style={[styles.col30, styles.center]}>
<Entypo name="user" size={50} color="black" />
</View>
</View>
</TouchableOpacity>
);
const renderItem = ({ item }) => <Item item={item} />;
return (
<View style={styles.container}>
{loading && (
<View>
<Image
style={styles.tinyLogo}
source={require("../../assets/gasloading.gif")}
/>
</View>
)}
{users.length ==0 && <Text style={{fontSize:20}}>No Data</Text>}
{!loading && (
<FlatList
showsVerticalScrollIndicator={false}
showsHorizontalScrollIndicator={false}
data={users}
renderItem={renderItem}
keyExtractor={(item) => item.id}
onRefresh={() => fetchData()}
refreshing={loading}
/>
)}
</View>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
paddingHorizontal: 20,
paddingTop: 20,
backgroundColor: "#fff",
justifyContent: "center",
alignItems: "center",
},
tinyLogo: {
backgroundColor: "#f00",
justifyContent: "center",
alignItems: "center",
},
row: {
flexDirection: "row",
},
col70: {
width: "70%",
},
col30: {
width: "30%",
},
center: {
alignItems: "center",
justifyContent: "center",
},
floatButton: {
width: 65,
height: 65,
backgroundColor: "#f05a36",
borderRadius: 100,
position: "absolute",
right: 20,
bottom: 20,
},
box: {
backgroundColor: "#f7c469",
padding: 20,
borderRadius: 15,
marginBottom: 20,
},
boxTitle: {
color: "#000",
fontWeight: "700",
fontSize: 16,
},
boxtext: {
color: "#000",
},
});
\ No newline at end of file
import {
StyleSheet,
Text,
View,
TouchableOpacity,
Image,
FlatList,
} from "react-native";
import React, { useState, useEffect } from "react";
import { Entypo } from "@expo/vector-icons";
import { MaterialCommunityIcons } from "@expo/vector-icons";
import { useIsFocused } from "@react-navigation/native";
export default function Fuel({ navigation }) {
const [loading, setLoading] = useState(true);
const [fuel, setFuel] = useState([]);
const isFocused = useIsFocused();
const fetchData = () => {
fetch("https://fuel.udarax.me/api/fuel/")
.then((response) => response.json())
.then((data) => {
setFuel(data["respond"]);
setLoading(false);
});
};
useEffect(() => {
if (isFocused) {
fetchData();
}
}, [loading, isFocused]);
function FloatButton() {
return (
<TouchableOpacity
style={[styles.floatButton, styles.center]}
onPress={() => navigation.navigate("FuelAdd")}
>
<Entypo name="plus" size={30} color="white" />
</TouchableOpacity>
);
}
const Item = ({ item }) => (
<TouchableOpacity
style={styles.box}
onPress={() => navigation.navigate("FuelEdit", { typeID: item.id })}
>
<View style={styles.row}>
<View style={styles.col70}>
<Text style={styles.boxTitle}>{item.name}</Text>
<Text style={styles.boxtext}>{item.price}</Text>
</View>
<View style={[styles.col30, styles.center]}>
<MaterialCommunityIcons name="fuel" size={50} color="black" />
</View>
</View>
</TouchableOpacity>
);
const renderItem = ({ item }) => <Item item={item} />;
return (
<View style={styles.container}>
{loading && (
<View>
<Image
style={styles.tinyLogo}
source={require("../../assets/gasloading.gif")}
/>
</View>
)}
{!loading && (
<FlatList
showsVerticalScrollIndicator={false}
showsHorizontalScrollIndicator={false}
data={fuel}
renderItem={renderItem}
keyExtractor={(item) => item.id}
onRefresh={() => fetchData()}
refreshing={loading}
/>
)}
<FloatButton />
</View>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
paddingHorizontal: 20,
paddingTop: 20,
backgroundColor: "#fff",
justifyContent: "center",
alignItems:'center'
},
tinyLogo:{
backgroundColor:"#f00",
justifyContent:'center',
alignItems:'center'
},
row:{
flexDirection:'row'
},
col70:{
width:"70%"
},
col30:{
width:"30%"
},
center: {
alignItems: "center",
justifyContent: "center",
},
floatButton: {
width: 65,
height: 65,
backgroundColor: "#f05a36",
borderRadius: 100,
position: "absolute",
right: 20,
bottom: 20,
},
box: {
backgroundColor: "#f7c469",
padding: 20,
borderRadius: 15,
marginBottom: 20,
},
boxTitle: {
color: "#000",
fontWeight: "700",
fontSize: 16,
},
boxtext: {
color: "#000",
},
});
import { StyleSheet, Text, View } from 'react-native'
import React from 'react'
export default function Settings() {
return (
<View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
<Text>Setting Screen</Text>
</View>
)
}
const styles = StyleSheet.create({})
\ No newline at end of file
import {
StyleSheet,
Text,
View,
TextInput,
TouchableOpacity,
Alert,
} from "react-native";
import React, { useState, useEffect } from "react";
export default function Fillingqueue({ route, navigation }) {
const {
user_id,
vehicle_id,
station_id,
fueltype_id,
ftype,
username,
vehicle,
no,
qid,
stuid
} = route.params;
const [qty, setQty] = useState([]);
const fillFuel = () => {
if (qty != "" && qty != null) {
const requestOptions = {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
qty: qty,
user_id: user_id,
vehicle_id: vehicle_id,
station_id: station_id,
fueltype_id: fueltype_id,
qid: qid,
}),
};
fetch("https://fuel.udarax.me/api/audit/create", requestOptions)
.then((response) => response.json())
.then((data) => {
console.log(data);
if (data["message"] == "success") {
Alert.alert(
"Alert!",
"Fuel Filled Successfully",
[
{
text: "Yes",
onPress: () => {
navigation.navigate("Queue",{
user_id:stuid
});
},
},
],
{ cancelable: false }
);
} else {
alert(data["message"]);
}
});
} else {
alert("Qty cannot empty!");
}
};
return (
<View style={styles.container}>
<View style={styles.mb5}>
<Text>Fuel Type</Text>
<TextInput style={styles.input} value={ftype} editable={false} />
</View>
<View style={styles.mb5}>
<Text>User Name</Text>
<TextInput style={styles.input} value={username} editable={false} />
</View>
<View style={styles.mb5}>
<Text>Vehicle Type</Text>
<TextInput style={styles.input} value={vehicle} editable={false} />
</View>
<View style={styles.mb5}>
<Text>Queue No</Text>
<TextInput style={styles.input} value={no} editable={false} />
</View>
<View style={styles.mb5}>
<Text>Amount of Leaters</Text>
<TextInput
style={styles.input}
onChangeText={setQty}
value={qty}
placeholder="Enter Amount of Leaters"
keyboardType="numeric"
/>
</View>
<TouchableOpacity style={styles.button} onPress={fillFuel}>
<Text style={styles.buttonText}>Fill Fuel</Text>
</TouchableOpacity>
</View>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
paddingHorizontal: 20,
paddingTop: 20,
backgroundColor: "#fff",
},
mb5: {
marginBottom: 20,
},
input: {
height: 45,
marginTop: 5,
borderWidth: 1,
padding: 10,
borderRadius: 5,
},
button: {
alignItems: "center",
backgroundColor: "#f05a36",
height: 45,
borderRadius: 5,
justifyContent: "center",
marginBottom: 20,
},
buttonText: {
color: "#fff",
},
});
import {
StyleSheet,
Text,
View,
TouchableOpacity,
Image,
FlatList,
} from "react-native";
import React, { useState, useEffect } from "react";
import { Entypo } from "@expo/vector-icons";
import { AntDesign } from '@expo/vector-icons';
import { useIsFocused } from "@react-navigation/native";
export default function Gasstock({ route, navigation }) {
const { user_id } = route.params;
const [loading, setLoading] = useState(true);
const [stocks, setStocks] = useState([]);
const isFocused = useIsFocused();
const fetchData = () => {
fetch("https://fuel.udarax.me/api/station/stocks/" + user_id)
.then((response) => response.json())
.then((data) => {
setStocks(data["respond"]);
setLoading(false);
});
};
function FloatButton() {
return (
<TouchableOpacity
style={[styles.floatButton, styles.center]}
onPress={() =>
navigation.navigate("GasStockAdd", {
user_id: user_id,
})
}
>
<Entypo name="plus" size={30} color="white" />
</TouchableOpacity>
);
}
useEffect(() => {
if (isFocused) {
fetchData();
}
}, [loading, isFocused]);
const Item = ({ item }) => (
<TouchableOpacity
style={styles.box}
onPress={() => navigation.navigate("GasStockEdit", { stockID: item.fcid , user_id:user_id })}
>
<View style={styles.row}>
<View style={styles.col70}>
<Text style={styles.boxTitle}>{item.name}</Text>
<Text style={styles.boxtext}>Initial Volum : {item.ini_qty}</Text>
<Text style={styles.boxtext}>Current Volum : {item.current_qty}</Text>
</View>
<View style={[styles.col30, styles.center]}>
<View style={styles.delBox}>
<AntDesign name="edit" size={20} color="white" />
</View>
</View>
</View>
</TouchableOpacity>
);
const renderItem = ({ item }) => <Item item={item} />;
return (
<View style={styles.container}>
{loading && (
<View>
<Image
style={styles.tinyLogo}
source={require("../../assets/gasloading.gif")}
/>
</View>
)}
{!loading && (
<FlatList
showsVerticalScrollIndicator={false}
showsHorizontalScrollIndicator={false}
data={stocks}
renderItem={renderItem}
keyExtractor={(item) => item.fcid}
onRefresh={() => fetchData()}
refreshing={loading}
/>
)}
<FloatButton />
</View>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
paddingHorizontal: 20,
paddingTop: 20,
backgroundColor: "#fff",
justifyContent: "center",
alignItems: "center",
},
tinyLogo: {
backgroundColor: "#f00",
justifyContent: "center",
alignItems: "center",
},
row: {
flexDirection: "row",
},
col70: {
width: "70%",
},
col30: {
width: "30%",
},
center: {
alignItems: "center",
justifyContent: "center",
},
floatButton: {
width: 65,
height: 65,
backgroundColor: "#f05a36",
borderRadius: 100,
position: "absolute",
right: 20,
bottom: 20,
},
box: {
backgroundColor: "#f7c469",
padding: 20,
borderRadius: 15,
marginBottom: 20,
},
boxTitle: {
color: "#000",
fontWeight: "700",
fontSize: 16,
},
boxtext: {
color: "#000",
},
delBox:{
backgroundColor:"#f00",
borderRadius:50,
padding:15
},
});
import {
StyleSheet,
Text,
View,
TouchableOpacity,
Image,
FlatList,
} from "react-native";
import React, { useState, useEffect } from "react";
import { AntDesign } from "@expo/vector-icons";
import { MaterialCommunityIcons } from "@expo/vector-icons";
import { useIsFocused } from "@react-navigation/native";
import { FontAwesome5 } from "@expo/vector-icons";
import { Ionicons } from "@expo/vector-icons";
export default function Queue({ route, navigation }) {
const { user_id } = route.params;
const [loading, setLoading] = useState(true);
const [queue, setQueue] = useState([]);
const isFocused = useIsFocused();
const fetchData = () => {
console.log(queue.length);
fetch("https://fuel.udarax.me/api/station/queue/" + user_id)
.then((response) => response.json())
.then((data) => {
console.log("aaa");
console.log(data["respond"]);
if (data["respond"] == "error") {
setQueue([]);
} else {
setQueue(data["respond"]);
}
setLoading(false);
});
};
useEffect(() => {
if (isFocused) {
fetchData();
}
}, [loading, isFocused]);
const Item = ({ item }) => (
<TouchableOpacity
style={styles.box}
onPress={() =>
navigation.navigate("FillingQueue", {
user_id: item.uid,
vehicle_id: item.vid,
station_id: item.sid,
fueltype_id: item.fid,
ftype: item.fname,
username: item.uname,
vehicle: item.vtype,
no: item.no,
qid: item.id,
stuid: user_id,
})
}
>
<View style={styles.row}>
<View style={styles.col70}>