import { View, Text, StyleSheet } from "react-native";
import { MaterialIcons } from "@expo/vector-icons";
import { TouchableOpacity } from "react-native-gesture-handler";

interface ErrorPageProps {
  refresh?: () => void;
}

export const ErrorPage = ({ refresh }: ErrorPageProps) => {
  return (
    <View style={styles.container}>
      <MaterialIcons name="error-outline" size={42} color="red" />
      <Text style={styles.text}>
        Ups, algo salio mal, revisa tu conexión a internet o intentalo más
        tarde...
      </Text>
      {refresh && (
        <TouchableOpacity style={styles.refreshButton} onPress={refresh}>
          <MaterialIcons name="refresh" size={24} color="black" />
          <Text>Reintentar</Text>
        </TouchableOpacity>
      )}
    </View>
  );
};

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: "center",
    alignItems: "center",
    gap: 20,
  },
  text: {
    width: "60%",
    textAlign: "center",
  },
  refreshButton: {
    flexDirection: "row",
    justifyContent: "center",
    alignItems: "center",
    gap: 5,
  },
});
