mirror of
https://github.com/fergalmoran/supanextail.git
synced 2025-12-22 09:17:54 +00:00
Clean code WIP
This commit is contained in:
@@ -19,37 +19,37 @@ const CardsLanding = (): JSX.Element => (
|
|||||||
</p>
|
</p>
|
||||||
<div className="flex flex-wrap justify-center mt-10">
|
<div className="flex flex-wrap justify-center mt-10">
|
||||||
<CardLanding
|
<CardLanding
|
||||||
image={cardPage}
|
image={cardPage as string}
|
||||||
text="7 pages fully designed and easily customizable"
|
text="7 pages fully designed and easily customizable"
|
||||||
title="Templates"
|
title="Templates"
|
||||||
/>
|
/>
|
||||||
<CardLanding
|
<CardLanding
|
||||||
image={cardServer}
|
image={cardServer as string}
|
||||||
text="Integrated backend already setup with Next.js API Routes"
|
text="Integrated backend already setup with Next.js API Routes"
|
||||||
title="Backend"
|
title="Backend"
|
||||||
/>
|
/>
|
||||||
<CardLanding
|
<CardLanding
|
||||||
image={cardAuth}
|
image={cardAuth as string}
|
||||||
text="Auth and user management with Supabase"
|
text="Auth and user management with Supabase"
|
||||||
title="Auth"
|
title="Auth"
|
||||||
/>
|
/>
|
||||||
<CardLanding
|
<CardLanding
|
||||||
image={cardResponsive}
|
image={cardResponsive as string}
|
||||||
text="Mobile ready, fully responsive and customizable with Tailwind CSS"
|
text="Mobile ready, fully responsive and customizable with Tailwind CSS"
|
||||||
title="Responsive"
|
title="Responsive"
|
||||||
/>
|
/>
|
||||||
<CardLanding
|
<CardLanding
|
||||||
image={cardTheme}
|
image={cardTheme as string}
|
||||||
text="Custom themes available and easily switch to dark mode"
|
text="Custom themes available and easily switch to dark mode"
|
||||||
title="Themes"
|
title="Themes"
|
||||||
/>
|
/>
|
||||||
<CardLanding
|
<CardLanding
|
||||||
image={cardStripe}
|
image={cardStripe as string}
|
||||||
text="Stripe integration. Fully functional subscription system"
|
text="Stripe integration. Fully functional subscription system"
|
||||||
title="Payment"
|
title="Payment"
|
||||||
/>
|
/>
|
||||||
<CardLanding
|
<CardLanding
|
||||||
image={cardFee}
|
image={cardFee as string}
|
||||||
text="One-time fee. No subscription, you’ll have access to all the updates"
|
text="One-time fee. No subscription, you’ll have access to all the updates"
|
||||||
title="Lifetime access"
|
title="Lifetime access"
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -113,7 +113,7 @@ const Dashboard = ({
|
|||||||
id="username"
|
id="username"
|
||||||
type="text"
|
type="text"
|
||||||
value={username || ''}
|
value={username || ''}
|
||||||
onChange={(e) => setUsername(e.target.value)}
|
onChange={(event) => setUsername(event.target.value)}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex flex-col mb-5">
|
<div className="flex flex-col mb-5">
|
||||||
@@ -140,7 +140,7 @@ const Dashboard = ({
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="flex flex-row flex-wrap w-full max-w-xl p-5 m-auto my-5 border-2 shadow-lg bordered border-primary">
|
<div className="flex flex-row flex-wrap w-full max-w-xl p-5 m-auto my-5 border-2 shadow-lg bordered border-primary">
|
||||||
<Image src={Plan} alt="credit card" />
|
<Image src={Plan as string} alt="credit card" />
|
||||||
<div className="flex flex-col m-auto">
|
<div className="flex flex-col m-auto">
|
||||||
<h2>Your current plan</h2>
|
<h2>Your current plan</h2>
|
||||||
<p className="">{planName}</p>
|
<p className="">{planName}</p>
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ const Landing = (): JSX.Element => (
|
|||||||
</div>
|
</div>
|
||||||
<div className="max-w-xl">
|
<div className="max-w-xl">
|
||||||
<Image
|
<Image
|
||||||
src={landTop}
|
src={landTop as string}
|
||||||
height={417}
|
height={417}
|
||||||
width={583}
|
width={583}
|
||||||
alt="Construction of a website"
|
alt="Construction of a website"
|
||||||
@@ -40,7 +40,7 @@ const Landing = (): JSX.Element => (
|
|||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<div className="max-w-xl">
|
<div className="max-w-xl">
|
||||||
<Image src={start} alt="screenshot of the website" />
|
<Image src={start as string} alt="screenshot of the website" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex flex-wrap justify-around max-w-6xl m-auto mt-24">
|
<div className="flex flex-wrap justify-around max-w-6xl m-auto mt-24">
|
||||||
@@ -60,7 +60,10 @@ const Landing = (): JSX.Element => (
|
|||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex order-2 max-w-md lg:order-1">
|
<div className="flex order-2 max-w-md lg:order-1">
|
||||||
<Image src={supabaseImage} alt="screenshot of the Supabase website" />
|
<Image
|
||||||
|
src={supabaseImage as string}
|
||||||
|
alt="screenshot of the Supabase website"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<MailingList />
|
<MailingList />
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ const MailingList = (): JSX.Element => {
|
|||||||
const [loading, setLoading] = useState(false);
|
const [loading, setLoading] = useState(false);
|
||||||
const [valid, setValid] = useState(true);
|
const [valid, setValid] = useState(true);
|
||||||
|
|
||||||
const validateEmail = () => {
|
const validateEmail = (): void => {
|
||||||
// Regex patern for email validation
|
// Regex patern for email validation
|
||||||
const regex =
|
const regex =
|
||||||
/^(([^\s"(),.:;<>@[\\\]]+(\.[^\s"(),.:;<>@[\\\]]+)*)|(".+"))@((\[(?:\d{1,3}\.){3}\d{1,3}])|(([\dA-Za-z\-]+\.)+[A-Za-z]{2,}))$/;
|
/^(([^\s"(),.:;<>@[\\\]]+(\.[^\s"(),.:;<>@[\\\]]+)*)|(".+"))@((\[(?:\d{1,3}\.){3}\d{1,3}])|(([\dA-Za-z\-]+\.)+[A-Za-z]{2,}))$/;
|
||||||
@@ -30,7 +30,7 @@ const MailingList = (): JSX.Element => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const subscribe = () => {
|
const subscribe = (): void => {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
axios
|
axios
|
||||||
.put('api/mailingList', {
|
.put('api/mailingList', {
|
||||||
@@ -52,7 +52,7 @@ const MailingList = (): JSX.Element => {
|
|||||||
<h2 className="text-3xl font-bold text-center uppercase md:text-4xl font-title">
|
<h2 className="text-3xl font-bold text-center uppercase md:text-4xl font-title">
|
||||||
Stay Tuned
|
Stay Tuned
|
||||||
</h2>
|
</h2>
|
||||||
<Image src={Mailing} alt="Mail" />
|
<Image src={Mailing as string} alt="Mail" />
|
||||||
<label className="label">
|
<label className="label">
|
||||||
<p className="max-w-md m-auto text-center">
|
<p className="max-w-md m-auto text-center">
|
||||||
Want to be the first to know when SupaNexTail launches and get an
|
Want to be the first to know when SupaNexTail launches and get an
|
||||||
@@ -61,13 +61,13 @@ const MailingList = (): JSX.Element => {
|
|||||||
</label>
|
</label>
|
||||||
<div className="m-auto mt-5">
|
<div className="m-auto mt-5">
|
||||||
<input
|
<input
|
||||||
onChange={(e) => {
|
onChange={(event) => {
|
||||||
setMail(e.target.value);
|
setMail(event.target.value);
|
||||||
}}
|
}}
|
||||||
type="email"
|
type="email"
|
||||||
placeholder="Your email"
|
placeholder="Your email"
|
||||||
className={`input input-primary input-bordered ${
|
className={`input input-primary input-bordered ${
|
||||||
valid ? null : 'input-error'
|
valid ? '' : 'input-error'
|
||||||
}`}
|
}`}
|
||||||
/>
|
/>
|
||||||
<button
|
<button
|
||||||
|
|||||||
@@ -7,9 +7,10 @@ import { LogOut, Menu } from 'react-feather';
|
|||||||
import Image from 'next/image';
|
import Image from 'next/image';
|
||||||
import Link from 'next/link';
|
import Link from 'next/link';
|
||||||
import Logo from 'public/logo.svg';
|
import Logo from 'public/logo.svg';
|
||||||
|
import { UserCredentials } from '@supabase/gotrue-js';
|
||||||
|
|
||||||
type NavProperties = {
|
type NavProperties = {
|
||||||
user: Record<string, unknown>;
|
user: UserCredentials | undefined;
|
||||||
signOut: () => void;
|
signOut: () => void;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -66,7 +67,7 @@ const Nav = ({ user, signOut }: NavProperties): JSX.Element => {
|
|||||||
<nav className="w-full mb-2 navbar">
|
<nav className="w-full mb-2 navbar">
|
||||||
<Link href="/">
|
<Link href="/">
|
||||||
<a>
|
<a>
|
||||||
<Image src={Logo} alt="SupaNexTail Logo" />
|
<Image src={Logo as string} alt="SupaNexTail Logo" />
|
||||||
</a>
|
</a>
|
||||||
</Link>
|
</Link>
|
||||||
|
|
||||||
|
|||||||
@@ -28,10 +28,10 @@ const stripe = new Stripe(process.env.STRIPE_SECRET || '', {
|
|||||||
|
|
||||||
export default async function handler(
|
export default async function handler(
|
||||||
request: NextApiRequest,
|
request: NextApiRequest,
|
||||||
res: NextApiResponse
|
response: NextApiResponse
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
await cors(request, res);
|
await cors(request, response);
|
||||||
await limiter(request, res);
|
await limiter(request, response);
|
||||||
if (request.method === 'POST') {
|
if (request.method === 'POST') {
|
||||||
const returnUrl = `${request.headers.origin}/dashboard`; // Stripe will return to the dashboard, you can change it
|
const returnUrl = `${request.headers.origin}/dashboard`; // Stripe will return to the dashboard, you can change it
|
||||||
|
|
||||||
|
|||||||
@@ -5,14 +5,16 @@ import {
|
|||||||
useEffect,
|
useEffect,
|
||||||
useState,
|
useState,
|
||||||
} from 'react';
|
} from 'react';
|
||||||
|
import { Session, UserCredentials } from '@supabase/gotrue-js';
|
||||||
|
|
||||||
import { UserCredentials } from '@supabase/gotrue-js';
|
|
||||||
import { supabase } from 'utils/supabaseClient';
|
import { supabase } from 'utils/supabaseClient';
|
||||||
|
|
||||||
type authContextType = {
|
type authContextType = {
|
||||||
user: boolean;
|
user: UserCredentials | undefined;
|
||||||
|
session: Session | undefined;
|
||||||
login: () => void;
|
login: () => void;
|
||||||
logout: () => void;
|
logout: () => void;
|
||||||
|
signOut: () => void;
|
||||||
};
|
};
|
||||||
|
|
||||||
type Properties = {
|
type Properties = {
|
||||||
@@ -20,9 +22,11 @@ type Properties = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const authContextDefaultValues: authContextType = {
|
const authContextDefaultValues: authContextType = {
|
||||||
user: false,
|
user: undefined,
|
||||||
|
session: undefined,
|
||||||
login: () => {},
|
login: () => {},
|
||||||
logout: () => {},
|
logout: () => {},
|
||||||
|
signOut: () => {},
|
||||||
};
|
};
|
||||||
|
|
||||||
// create a context for authentication
|
// create a context for authentication
|
||||||
@@ -82,4 +86,4 @@ export const AuthProvider = ({ children }: Properties): JSX.Element => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// export the useAuth hook
|
// export the useAuth hook
|
||||||
export const useAuth = () => useContext(AuthContext);
|
export const useAuth = (): authContextType => useContext(AuthContext);
|
||||||
|
|||||||
Reference in New Issue
Block a user