diff --git a/app/api/confirmation/route.ts b/app/api/confirmation/route.ts index 242b5cf..fb51dea 100644 --- a/app/api/confirmation/route.ts +++ b/app/api/confirmation/route.ts @@ -1,7 +1,7 @@ import { z } from 'zod'; import prisma from '../../../prisma/prisma'; import { ApiResponse } from '../../../utils/apiResponse'; -import { ConfirmationSchema, ResponseSchema } from '../../../utils/types'; +import { ConfirmationSchema, ResponseSchema } from '../../../utils/schemas'; export const dynamic = 'force-dynamic'; // defaults to force-static export async function POST(request: Request) { diff --git a/app/api/cron/route.ts b/app/api/cron/route.ts index 03c76db..79ec22f 100644 --- a/app/api/cron/route.ts +++ b/app/api/cron/route.ts @@ -2,8 +2,8 @@ import { NextResponse } from 'next/server'; import { z } from 'zod'; import NewsletterTemplate from '../../../components/emails/newsletter'; import prisma from '../../../prisma/prisma'; +import { NewsDatabaseSchema, NewsSchema } from '../../../utils/schemas'; import { sender } from '../../../utils/sender'; -import { NewsDatabaseSchema, NewsSchema } from '../../../utils/types'; import { singleNews, topNews } from '../../../utils/urls'; export async function GET(request: Request) { diff --git a/app/api/subscribe/route.ts b/app/api/subscribe/route.ts index 051077d..317ac16 100644 --- a/app/api/subscribe/route.ts +++ b/app/api/subscribe/route.ts @@ -1,10 +1,10 @@ import * as crypto from 'crypto'; import { z } from 'zod'; -import SubscribeTemplate from '../../../components/emails/subscribe'; +import ConfirmationTemplate from '../../../components/emails/confirmation'; import prisma from '../../../prisma/prisma'; import { ApiResponse } from '../../../utils/apiResponse'; +import { ResponseSchema, SubscribeFormSchema } from '../../../utils/schemas'; import { sender } from '../../../utils/sender'; -import { ResponseSchema, SubscribeFormSchema } from '../../../utils/types'; export const dynamic = 'force-dynamic'; // defaults to force-static export async function POST(request: Request) { @@ -60,7 +60,7 @@ export async function POST(request: Request) { } }); - const sent = await sender([email], SubscribeTemplate(code)); + const sent = await sender([email], ConfirmationTemplate(code)); if (!sent) { return ApiResponse(500, 'Internal server error'); diff --git a/app/api/unsubscribe/route.ts b/app/api/unsubscribe/route.ts index 348d3f7..94ed3de 100644 --- a/app/api/unsubscribe/route.ts +++ b/app/api/unsubscribe/route.ts @@ -2,8 +2,8 @@ import { z } from 'zod'; import UnsubscribeTemplate from '../../../components/emails/unsubscribe'; import prisma from '../../../prisma/prisma'; import { ApiResponse } from '../../../utils/apiResponse'; +import { ResponseSchema, UnsubscribeFormSchema } from '../../../utils/schemas'; import { sender } from '../../../utils/sender'; -import { ResponseSchema, UnsubscribeFormSchema } from '../../../utils/types'; export const dynamic = 'force-dynamic'; // defaults to force-static export async function POST(request: Request) { diff --git a/app/confirmation/page.tsx b/app/confirmation/page.tsx index 7022498..545aefe 100644 --- a/app/confirmation/page.tsx +++ b/app/confirmation/page.tsx @@ -3,7 +3,7 @@ import { useRouter, useSearchParams } from 'next/navigation'; import { useEffect, useState } from 'react'; import { z } from 'zod'; import { CustomCard } from '../../components/custom/card'; -import { ResponseSchema } from '../../utils/types'; +import { ResponseSchema } from '../../utils/schemas'; export default function Confirmation() { const router = useRouter(); diff --git a/app/page.tsx b/app/page.tsx index c0854ed..f674de4 100644 --- a/app/page.tsx +++ b/app/page.tsx @@ -14,7 +14,7 @@ import { FormMessage } from '../components/ui/form'; import { Input } from '../components/ui/input'; -import { ResponseSchema, SubscribeFormSchema } from '../utils/types'; +import { ResponseSchema, SubscribeFormSchema } from '../utils/schemas'; export default function Home() { const [completed, setCompleted] = useState(false); diff --git a/app/unsubscribe/page.tsx b/app/unsubscribe/page.tsx index 4155619..34c66ac 100644 --- a/app/unsubscribe/page.tsx +++ b/app/unsubscribe/page.tsx @@ -14,7 +14,7 @@ import { FormMessage } from '../../components/ui/form'; import { Input } from '../../components/ui/input'; -import { ResponseSchema, UnsubscribeFormSchema } from '../../utils/types'; +import { ResponseSchema, UnsubscribeFormSchema } from '../../utils/schemas'; export default function Unsubscribe() { const [completed, setCompleted] = useState(false); diff --git a/components/custom/background/background.tsx b/components/custom/background/background.tsx index 75b2ee8..b8b232f 100644 --- a/components/custom/background/background.tsx +++ b/components/custom/background/background.tsx @@ -1,4 +1,4 @@ -import { Tiles } from './components/tiles'; +import { Tiles } from './tile/tiles'; type BackgroundProps = { children: React.ReactNode; diff --git a/components/custom/background/components/card.tsx b/components/custom/background/tile/tile.tsx similarity index 79% rename from components/custom/background/components/card.tsx rename to components/custom/background/tile/tile.tsx index 354e897..5af3285 100644 --- a/components/custom/background/components/card.tsx +++ b/components/custom/background/tile/tile.tsx @@ -1,7 +1,7 @@ import { useEffect, useState } from 'react'; import { z } from 'zod'; -import { NewsSchema } from '../../../../utils/types'; -import { CardContent } from './cardContent'; +import { NewsSchema } from '../../../../utils/schemas'; +import { TileContent } from './tileContent'; type CardProps = { newsA?: z.infer; @@ -10,7 +10,7 @@ type CardProps = { height: number; }; -export function Card({ newsA, newsB, width, height }: CardProps) { +export function Tile({ newsA, newsB, width, height }: CardProps) { const [switched, setSwitched] = useState(false); const [active, setActive] = useState(Math.random() < 0.5); const [delayed, setDelayed] = useState(true); @@ -41,8 +41,8 @@ export function Card({ newsA, newsB, width, height }: CardProps) {
{active - ? CardContent({ story: newsA, width, height, side: true }) - : CardContent({ story: newsB, width, height, side: false })} + ? TileContent({ story: newsA, width, height, side: true }) + : TileContent({ story: newsB, width, height, side: false })}
diff --git a/components/custom/background/components/cardContent.tsx b/components/custom/background/tile/tileContent.tsx similarity index 91% rename from components/custom/background/components/cardContent.tsx rename to components/custom/background/tile/tileContent.tsx index 2a0f57b..b30f7dc 100644 --- a/components/custom/background/components/cardContent.tsx +++ b/components/custom/background/tile/tileContent.tsx @@ -1,6 +1,6 @@ import { useState } from 'react'; import { z } from 'zod'; -import { NewsSchema } from '../../../../utils/types'; +import { NewsSchema } from '../../../../utils/schemas'; type CardContentProps = { story: z.infer; @@ -18,7 +18,7 @@ function getRandomColor() { return color; } -export function CardContent({ story, width, height, side }: CardContentProps) { +export function TileContent({ story, width, height, side }: CardContentProps) { const [firstColor, setFirstColor] = useState(getRandomColor()); const [secondColor, setSecondColor] = useState(getRandomColor()); const [switched, setSwitched] = useState(true); diff --git a/components/custom/background/components/tiles.tsx b/components/custom/background/tile/tiles.tsx similarity index 93% rename from components/custom/background/components/tiles.tsx rename to components/custom/background/tile/tiles.tsx index eb0f6d8..d044a8e 100644 --- a/components/custom/background/components/tiles.tsx +++ b/components/custom/background/tile/tiles.tsx @@ -3,8 +3,8 @@ import { usePathname } from 'next/navigation'; import { useEffect, useState } from 'react'; import { z } from 'zod'; -import { NewsSchema } from '../../../../utils/types'; -import { Card } from './card'; +import { NewsSchema } from '../../../../utils/schemas'; +import { Tile } from './tile'; type TilesProps = { children: React.ReactNode; @@ -74,7 +74,7 @@ export const Tiles = ({ children }: TilesProps) => { width: `${baseWidth * 4}px` }} > - { ); } - return
{renderGrid()}
; + return
{renderGrid()}
; }; diff --git a/components/custom/footer.tsx b/components/custom/footer.tsx index b7a7616..65fff94 100644 --- a/components/custom/footer.tsx +++ b/components/custom/footer.tsx @@ -1,27 +1,39 @@ import { usePathname } from 'next/navigation'; import { Link } from './link'; -const links = [ - { name: 'Subscribe', path: '/' }, - { name: 'Privacy Policy', path: '/privacy' }, -]; +const links = [{ name: 'Subscribe', path: '/' }]; function Footer() { const pathname = usePathname(); return ( -
    - {links.map( - (link) => - pathname !== link.path && - !(pathname === '/confirmation' && link.path === '/subscribe') && ( - - ) +
    + {pathname === '/' ? ( +

    + By subscribing, you agree to our{' '} + + Privacy Policy + + . +

    + ) : ( +
      + {links.map( + link => + pathname !== link.path && + !(pathname === '/confirmation' && link.path === '/') && ( + + ) + )} + {pathname === '/privacy' && ( + + )} +
    )} - {pathname === '/privacy' && ( - - )} -
+ ); } diff --git a/components/emails/subscribe.tsx b/components/emails/confirmation.tsx similarity index 87% rename from components/emails/subscribe.tsx rename to components/emails/confirmation.tsx index 7402ab0..85a57ba 100644 --- a/components/emails/subscribe.tsx +++ b/components/emails/confirmation.tsx @@ -1,6 +1,6 @@ import Email from './template'; -export default function ConfirmationEmail(code: string) { +export default function ConfirmationTemplate(code: string) { return { subject: 'Welcome!', template: ( diff --git a/components/emails/newsletter.tsx b/components/emails/newsletter.tsx index d340e7c..29e82dc 100644 --- a/components/emails/newsletter.tsx +++ b/components/emails/newsletter.tsx @@ -3,7 +3,7 @@ import { Html } from '@react-email/html'; import { Section } from '@react-email/section'; import { Text } from '@react-email/text'; import { z } from 'zod'; -import { NewsSchema } from '../../utils/types'; +import { NewsSchema } from '../../utils/schemas'; export default function NewsletterTemplate( stories: z.infer[] diff --git a/components/ui/card.tsx b/components/ui/card.tsx index 7f48283..cb0db38 100644 --- a/components/ui/card.tsx +++ b/components/ui/card.tsx @@ -8,7 +8,7 @@ const Card = React.forwardRef<
(({ className, ...props }, ref) => (

)); @@ -59,7 +59,7 @@ const CardContent = React.forwardRef< HTMLDivElement, React.HTMLAttributes >(({ className, ...props }, ref) => ( -

+
)); CardContent.displayName = 'CardContent'; @@ -69,7 +69,7 @@ const CardFooter = React.forwardRef< >(({ className, ...props }, ref) => (
)); diff --git a/tailwind.config.ts b/tailwind.config.ts index 433c23b..bc673f1 100644 --- a/tailwind.config.ts +++ b/tailwind.config.ts @@ -6,8 +6,7 @@ module.exports = { content: [ './pages/**/*.{ts,tsx}', './components/**/*.{ts,tsx}', - './app/**/*.{ts,tsx}', - './src/**/*.{ts,tsx}' + './app/**/*.{ts,tsx}' ], theme: { container: { diff --git a/utils/types.ts b/utils/schemas.ts similarity index 100% rename from utils/types.ts rename to utils/schemas.ts