import React, {useEffect} from 'react';
import {Flex, Image, Text} from "@chakra-ui/react";
import pdIcon from "../assets/img/pd.png";


export default function Home() {
    const [data, setData] = React.useState({});

    useEffect(() => {
        window.electronAPI.invoke('example', {}).then((result: any) => {
            setData(result);
        }).catch((err: any) => {
            console.error("Failed to call electron API", err);
        });
    }, [])

    return (
        <Flex
            direction={"column"}
            fontFamily={"RosarioRegular, sans-serif"}
            margin={0}
            padding={0}
            width={"100%"}
            height={"100vh"}
            alignItems={"center"}
            justifyContent={"center"}
            textAlign={"center"}
        >
            <Text>
                {data["msg"] ? data["msg"] + " from " : "Welcome to"} <Text as={"span"} color={"blue"}>pd</Text>
            </Text>

            <Image src={pdIcon} alt={"pd"}/>

            <Text>
                Generated by pd © 2023. All Rights Reserved.
            </Text>
        </Flex>
    )
}

