2021-06-04 00:58:40 +00:00
|
|
|
import styled from 'styled-components';
|
|
|
|
|
import Head from 'next/head';
|
|
|
|
|
import useUser from '../lib/useUser';
|
|
|
|
|
import HomeContent from '../components/HomeContent';
|
|
|
|
|
import Login from '../components/Login';
|
|
|
|
|
import Layout from '../components/Layout';
|
2022-01-28 22:54:47 +00:00
|
|
|
import buildBase64Data from '../utils/buildBase64Data';
|
2021-06-04 00:58:40 +00:00
|
|
|
|
|
|
|
|
const LandingStyles = styled.div`
|
|
|
|
|
display: grid;
|
|
|
|
|
`;
|
|
|
|
|
|
2022-01-28 22:54:47 +00:00
|
|
|
export default function Home({ alt, imageProps }) {
|
2021-06-04 00:58:40 +00:00
|
|
|
const { user, mutateUser } = useUser();
|
|
|
|
|
|
|
|
|
|
if (!user) {
|
|
|
|
|
return (
|
|
|
|
|
<Layout>
|
2022-01-28 22:54:47 +00:00
|
|
|
<LandingStyles>
|
|
|
|
|
<h1>Loading...</h1>
|
|
|
|
|
</LandingStyles>
|
2021-06-04 00:58:40 +00:00
|
|
|
</Layout>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<LandingStyles>
|
|
|
|
|
<Head>
|
|
|
|
|
<title key="title">N & N | Wedding</title>
|
|
|
|
|
</Head>
|
2022-01-28 22:54:47 +00:00
|
|
|
{user && user.isLoggedIn === true ? (
|
|
|
|
|
<HomeContent alt={alt} imageProps={imageProps} />
|
|
|
|
|
) : (
|
|
|
|
|
<Login />
|
|
|
|
|
)}
|
2021-06-04 00:58:40 +00:00
|
|
|
</LandingStyles>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2022-01-28 22:54:47 +00:00
|
|
|
export async function getStaticProps() {
|
|
|
|
|
const src = 'https://picsum.photos/1307/880';
|
|
|
|
|
const data = await buildBase64Data(false, src, 'Picture of the couple');
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
props: { ...data },
|
|
|
|
|
};
|
2021-06-04 00:58:40 +00:00
|
|
|
}
|