added map for environmentCard and added props
This commit is contained in:
parent
d374cdeea5
commit
f3674324f9
1
app.json
1
app.json
|
|
@ -7,6 +7,7 @@
|
||||||
"icon": "./assets/images/icon.png",
|
"icon": "./assets/images/icon.png",
|
||||||
"scheme": "myapp",
|
"scheme": "myapp",
|
||||||
"userInterfaceStyle": "automatic",
|
"userInterfaceStyle": "automatic",
|
||||||
|
"jsEngine": "hermes",
|
||||||
"newArchEnabled": true,
|
"newArchEnabled": true,
|
||||||
"ios": {
|
"ios": {
|
||||||
"supportsTablet": true
|
"supportsTablet": true
|
||||||
|
|
|
||||||
|
|
@ -1,19 +1,43 @@
|
||||||
import { View, StyleSheet, Text, Pressable } from "react-native";
|
import { View, Text, StyleSheet } from 'react-native';
|
||||||
|
|
||||||
|
interface EnvironmentCardProps {
|
||||||
|
name: string;
|
||||||
|
publicUrl: string;
|
||||||
|
status: number;
|
||||||
|
url: string;
|
||||||
|
}
|
||||||
|
|
||||||
export default function EnvironmentCard() {
|
export default function EnvironmentCard({ name, publicUrl, status, url }: EnvironmentCardProps) {
|
||||||
return (
|
return (
|
||||||
<Pressable onPress={() => console.log('Environment card pressed')} style={styles.container}>
|
<View style={styles.card}>
|
||||||
<Text>I'm pressable!</Text>
|
<Text style={styles.title}>{name}</Text>
|
||||||
</Pressable>
|
{publicUrl && <Text>Public URL: {publicUrl}</Text>}
|
||||||
);
|
{status === 1 && <Text>Status: Running</Text>}
|
||||||
|
{status === 2 && <Text>Status: Stopped</Text>}
|
||||||
|
{status === 3 && <Text>Status: Pending</Text>}
|
||||||
|
<Text>URL: {url}</Text>
|
||||||
|
</View>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const styles = StyleSheet.create({
|
const styles = StyleSheet.create({
|
||||||
container: {
|
card: {
|
||||||
backgroundColor: '#fff',
|
backgroundColor: 'white',
|
||||||
padding: 16,
|
borderRadius: 8,
|
||||||
margin: 8,
|
padding: 16,
|
||||||
borderRadius: 8,
|
marginBottom: 16,
|
||||||
|
shadowColor: '#000',
|
||||||
|
shadowOffset: {
|
||||||
|
width: 0,
|
||||||
|
height: 2,
|
||||||
},
|
},
|
||||||
|
shadowOpacity: 0.25,
|
||||||
|
shadowRadius: 3.84,
|
||||||
|
elevation: 5,
|
||||||
|
},
|
||||||
|
title: {
|
||||||
|
fontSize: 18,
|
||||||
|
fontWeight: 'bold',
|
||||||
|
marginBottom: 8,
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
@ -6,10 +6,16 @@ import LoginForm from "./components/LoginForm";
|
||||||
import LogoutButton from "./components/LogoutButton";
|
import LogoutButton from "./components/LogoutButton";
|
||||||
import EnvironmentCard from "./components/EnvironmentCard";
|
import EnvironmentCard from "./components/EnvironmentCard";
|
||||||
|
|
||||||
|
|
||||||
import { AuthProvider } from "./context/AuthContext";
|
import { AuthProvider } from "./context/AuthContext";
|
||||||
import { useAuth } from "./context/AuthContext";
|
import { useAuth } from "./context/AuthContext";
|
||||||
|
|
||||||
|
interface Environment {
|
||||||
|
Name: string;
|
||||||
|
PublicURL: string;
|
||||||
|
Status: number;
|
||||||
|
URL: string;
|
||||||
|
}
|
||||||
|
|
||||||
export default function Index() {
|
export default function Index() {
|
||||||
return (
|
return (
|
||||||
|
|
||||||
|
|
@ -23,7 +29,7 @@ export default function Index() {
|
||||||
|
|
||||||
function MainContent() {
|
function MainContent() {
|
||||||
const { isAuthenticated, domain, username, authData } = useAuth();
|
const { isAuthenticated, domain, username, authData } = useAuth();
|
||||||
const [environmentData, setEnvironmentData] = useState(null);
|
const [environmentData, setEnvironmentData] = useState<Environment[] | null>(null);
|
||||||
const [isLoading, setIsLoading] = useState(false);
|
const [isLoading, setIsLoading] = useState(false);
|
||||||
const [error, setError] = useState(null);
|
const [error, setError] = useState(null);
|
||||||
|
|
||||||
|
|
@ -60,12 +66,20 @@ function MainContent() {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<SafeAreaProvider>
|
<SafeAreaProvider>
|
||||||
<SafeAreaView style={{ flex: 1, padding: 16, width: '100%' }}>
|
<SafeAreaView style={{ flex: 1, padding: 16, width: '100%' }}>
|
||||||
<ScrollView>
|
<ScrollView showsVerticalScrollIndicator={false}>
|
||||||
<EnvironmentCard/>
|
{environmentData && environmentData.map((environment, index) => (
|
||||||
</ScrollView>
|
<EnvironmentCard
|
||||||
</SafeAreaView>
|
key={index}
|
||||||
<LogoutButton />
|
name={environment.Name}
|
||||||
|
publicUrl={environment.PublicURL}
|
||||||
|
status={environment.Status}
|
||||||
|
url={environment.URL}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
</ScrollView>
|
||||||
|
</SafeAreaView>
|
||||||
|
<LogoutButton />
|
||||||
</SafeAreaProvider>
|
</SafeAreaProvider>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue