|
| 1 | +import { Modal, Grid, Stack, Text, Flex } from "@mantine/core"; |
| 2 | +import { Auth, ThemeSupa } from "@supabase/auth-ui-react"; |
| 3 | +import { useSupabaseClient } from "@supabase/auth-helpers-react"; |
| 4 | +import { useRouter } from "next/router"; |
| 5 | +import Image from 'next/image' |
| 6 | +import theme from "../config/theme"; |
| 7 | + |
| 8 | +interface IAuthDialogProps { |
| 9 | + opened: boolean; |
| 10 | + onClose: () => void; |
| 11 | +} |
| 12 | +type ValuePropProps = { |
| 13 | + number: number |
| 14 | + title: string |
| 15 | + description: string |
| 16 | +} |
| 17 | + |
| 18 | +const ValueProp = ({ number, title, description }: ValuePropProps) => { |
| 19 | + return ( |
| 20 | + <Flex> |
| 21 | + <div style={{ |
| 22 | + border: 'solid 2px #C1C2C5', |
| 23 | + borderRadius: "100px", |
| 24 | + width: '30px', |
| 25 | + height: '30px', |
| 26 | + display: 'flex', |
| 27 | + alignItems: 'center', |
| 28 | + justifyContent: 'center' |
| 29 | + }}> |
| 30 | + <Text |
| 31 | + color={theme.colors.yellow[9]} |
| 32 | + >{number}</Text> |
| 33 | + </div> |
| 34 | + <div style={{ marginLeft: '10px' }}> |
| 35 | + <Text |
| 36 | + color={theme.colors.dark[3]} |
| 37 | + >{title}</Text> |
| 38 | + <Text |
| 39 | + fz={theme.fontSizes.xs} |
| 40 | + color={theme.colors.dark[1]} |
| 41 | + >{description}</Text> |
| 42 | + </div> |
| 43 | + </Flex > |
| 44 | + ) |
| 45 | +} |
| 46 | +const SalesContent = () => { |
| 47 | + return ( |
| 48 | + <Stack> |
| 49 | + <Image |
| 50 | + src="/upsell-image-small.png" |
| 51 | + width={500} |
| 52 | + height={300} |
| 53 | + alt="this is the alt text" |
| 54 | + placeholder="blur" |
| 55 | + blurDataURL="/upsell-image-blur.jpg" |
| 56 | + /> |
| 57 | + <Text |
| 58 | + align="center" |
| 59 | + fz="xl" |
| 60 | + weight={300} |
| 61 | + color="#343A40" |
| 62 | + >Your Menu is Almost Ready to Use</Text> |
| 63 | + <Stack> |
| 64 | + <ValueProp number={1} title="Save Your Work" description="Keep your menu up to date" /> |
| 65 | + <ValueProp number={2} title="Unlimited downloads" description="Get unlimited high-res and watermark-free downloads" /> |
| 66 | + <ValueProp number={3} title="Endless Designs" description="Unlock access to the most beautiful catalog of menus online" /> |
| 67 | + </Stack> |
| 68 | + </Stack> |
| 69 | + ) |
| 70 | +} |
| 71 | + |
| 72 | +const AuthDialog = ({ opened, onClose }: IAuthDialogProps) => { |
| 73 | + const supabase = useSupabaseClient(); |
| 74 | + const router = useRouter(); |
| 75 | + const origin = typeof window !== 'undefined' && window.location.origin ? window.location.origin : ''; |
| 76 | + |
| 77 | + return ( |
| 78 | + <Modal |
| 79 | + opened={opened} |
| 80 | + onClose={onClose} |
| 81 | + size="xl" |
| 82 | + radius="md" |
| 83 | + withCloseButton={false} |
| 84 | + padding={8} |
| 85 | + centered={true} |
| 86 | + > |
| 87 | + <Grid> |
| 88 | + <Grid.Col |
| 89 | + span={6} |
| 90 | + bg={theme.colors.gray[1]} |
| 91 | + sx={{ borderRadius: '8px 0 0 8px' }} |
| 92 | + p="xl" |
| 93 | + > |
| 94 | + <SalesContent /> |
| 95 | + </Grid.Col> |
| 96 | + <Grid.Col |
| 97 | + span={6} |
| 98 | + bg={"#fff"} |
| 99 | + p="xl" |
| 100 | + sx={{ borderRadius: '0 8px 8px 0' }} |
| 101 | + > |
| 102 | + <Auth |
| 103 | + redirectTo={`${origin}${router.asPath}`} |
| 104 | + supabaseClient={supabase} |
| 105 | + appearance={{ |
| 106 | + theme: ThemeSupa, |
| 107 | + variables: { |
| 108 | + default: { |
| 109 | + colors: { |
| 110 | + brand: 'orange', |
| 111 | + brandAccent: 'darkOrange', |
| 112 | + }, |
| 113 | + }, |
| 114 | + }, |
| 115 | + }} |
| 116 | + providers={["google", "facebook"]} |
| 117 | + magicLink |
| 118 | + view="sign_up" |
| 119 | + localization={{ |
| 120 | + variables: { |
| 121 | + sign_up: { |
| 122 | + social_provider_text: 'Sign up with', |
| 123 | + }, |
| 124 | + }, |
| 125 | + }} |
| 126 | + |
| 127 | + /> |
| 128 | + <Text fz="6pt" ta="center" color={theme.colors.dark[0]} lh="12px">By providing us with your information you are consenting to the collection and use |
| 129 | + of vour information in accordance with our <a href="https://www.flapjack.co/terms-of-use">Terms of Service</a> and <a href="https://www.flapjack.co/privacy-policy">Privacy Policy</a>.</Text> |
| 130 | + </Grid.Col> |
| 131 | + </Grid> |
| 132 | + </Modal> |
| 133 | + ); |
| 134 | +}; |
| 135 | + |
| 136 | +export default AuthDialog; |
0 commit comments