import { useModalsManagerContext } from "@/contexts/ModalsManagerContext";
import Button from "@components/Button";
import Box from "@components/bases/Box";
import InformationIcon from "@components/icons/InformationIcon";
import { Text } from "react-native";

interface Props {
	message?: string;
	onPress?: () => void;
	actionLabel?: string;
}

const InformationModal = ({
	message = "Une erreur s'est produite",
	onPress = undefined,
	actionLabel = "Ok",
}: Props) => {
	const { closeModal } = useModalsManagerContext();
	return (
		<Box
			width={300}
			// height={200}
			backgroundColor={"white"}
			alignItems={"center"}
			justifyContent={"center"}
			alignSelf={"center"}
			marginTop={"x240"}
			position={"absolute"}
			zIndex={10}
			borderRadius={20}
			gap={"m"}
			shadowColor={"black"}
			shadowOffset={{ width: 0, height: 0 }}
			shadowOpacity={0.5}
			p={"m"}
		>
			<InformationIcon />
			<Text>{message}</Text>
			<Box style={{ width: "80%" }}>
				{onPress && (
					<Button
						variant={"fullInformation"}
						textVariants={"white"}
						label={actionLabel}
						onPress={onPress}
					/>
				)}

				<Button
					variant={"noMargin"}
					textVariants={"error"}
					label="Fermer"
					onPress={closeModal}
				/>
			</Box>
		</Box>
	);
};

export default InformationModal;
