chore: code cleaning (#21)
This commit is contained in:
@@ -7,7 +7,7 @@ import {
|
||||
CardHeader,
|
||||
CardTitle
|
||||
} from './Card';
|
||||
import Footer from './Footer';
|
||||
import { Footer } from './Footer';
|
||||
|
||||
interface CardProps {
|
||||
title: string;
|
||||
@@ -17,13 +17,13 @@ interface CardProps {
|
||||
footer?: boolean;
|
||||
}
|
||||
|
||||
export default function CustomCard({
|
||||
export const CustomCard = ({
|
||||
title,
|
||||
description,
|
||||
content,
|
||||
className,
|
||||
footer = true
|
||||
}: CardProps) {
|
||||
}: CardProps) => {
|
||||
const [isLoaded, setIsLoaded] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
@@ -53,4 +53,4 @@ export default function CustomCard({
|
||||
</Card>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
'use client';
|
||||
|
||||
export default function ErrorMessage() {
|
||||
export const ErrorMessage = () => {
|
||||
return 'Oops. Something went wrong. Please try later :(';
|
||||
}
|
||||
};
|
||||
|
||||
@@ -5,7 +5,7 @@ import CustomLink from './CustomLink';
|
||||
|
||||
const links = [{ name: 'Subscribe', path: '/' }];
|
||||
|
||||
export default function Footer() {
|
||||
export const Footer = () => {
|
||||
const pathname = usePathname();
|
||||
|
||||
return (
|
||||
@@ -37,4 +37,4 @@ export default function Footer() {
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import Head from 'next/head';
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
const SchemaOrg = ({ schema }: Record<string, any>) => (
|
||||
export const SchemaOrg = ({ schema }: Record<string, any>) => (
|
||||
<Head>
|
||||
<script
|
||||
type='application/ld+json'
|
||||
@@ -9,5 +9,3 @@ const SchemaOrg = ({ schema }: Record<string, any>) => (
|
||||
/>
|
||||
</Head>
|
||||
);
|
||||
|
||||
export default SchemaOrg;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import React from 'react';
|
||||
import Note from './components/Note';
|
||||
import Template from './Template';
|
||||
import { Note } from './components/Note';
|
||||
import { Template } from './Template';
|
||||
|
||||
export default function ConfirmationTemplate(code: string) {
|
||||
export const ConfirmationTemplate = (code: string) => {
|
||||
return {
|
||||
subject: 'Welcome!',
|
||||
template: (
|
||||
@@ -46,4 +46,4 @@ export default function ConfirmationTemplate(code: string) {
|
||||
/>
|
||||
)
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
@@ -2,10 +2,10 @@ import React from 'react';
|
||||
import { summirize } from '@utils/summarize';
|
||||
import { NewsType } from '@utils/validationSchemas';
|
||||
import createDOMPurify from 'isomorphic-dompurify';
|
||||
import Template from './Template';
|
||||
import newsletterSubject from '@utils/newsletterSubject';
|
||||
import getNewsletterSubject from '@utils/getNewsletterSubject';
|
||||
import { Template } from './Template';
|
||||
|
||||
export default async function NewsletterTemplate(stories: NewsType[]) {
|
||||
export const NewsletterTemplate = async (stories: NewsType[]) => {
|
||||
const summary = await summirize(stories);
|
||||
const sanitizedSummary = createDOMPurify.sanitize(summary, {
|
||||
USE_PROFILES: { html: true },
|
||||
@@ -17,7 +17,7 @@ export default async function NewsletterTemplate(stories: NewsType[]) {
|
||||
throw new Error('Failed to sanitize summary');
|
||||
}
|
||||
|
||||
const topic = newsletterSubject(sanitizedSummary);
|
||||
const topic = getNewsletterSubject(sanitizedSummary);
|
||||
|
||||
return {
|
||||
subject: topic,
|
||||
@@ -66,4 +66,4 @@ export default async function NewsletterTemplate(stories: NewsType[]) {
|
||||
/>
|
||||
)
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import React from 'react';
|
||||
import Footer from './components/Footer';
|
||||
import { Footer } from './components/Footer';
|
||||
|
||||
interface TemplateProps {
|
||||
title: string;
|
||||
@@ -7,11 +7,11 @@ interface TemplateProps {
|
||||
variant?: string;
|
||||
}
|
||||
|
||||
export default function Template({
|
||||
export const Template = ({
|
||||
title,
|
||||
body,
|
||||
variant = 'default'
|
||||
}: TemplateProps) {
|
||||
}: TemplateProps) => {
|
||||
const isNewsletter = variant === 'newsletter';
|
||||
|
||||
return (
|
||||
@@ -74,4 +74,4 @@ export default function Template({
|
||||
<Footer />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import React from 'react';
|
||||
import Note from './components/Note';
|
||||
import Template from './Template';
|
||||
import { Note } from './components/Note';
|
||||
import { Template } from './Template';
|
||||
|
||||
export default function UnsubscribeTemplate() {
|
||||
export const UnsubscribeTemplate = () => {
|
||||
return {
|
||||
subject: 'Unsubscribe confirmation',
|
||||
template: (
|
||||
@@ -55,4 +55,4 @@ export default function UnsubscribeTemplate() {
|
||||
/>
|
||||
)
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
@@ -8,7 +8,7 @@ import {
|
||||
Home
|
||||
} from 'lucide-react';
|
||||
|
||||
export default function Footer() {
|
||||
export const Footer = () => {
|
||||
return (
|
||||
<footer
|
||||
style={{
|
||||
@@ -167,4 +167,4 @@ export default function Footer() {
|
||||
</div>
|
||||
</footer>
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -2,10 +2,10 @@ interface NoteProps {
|
||||
children: React.ReactNode;
|
||||
}
|
||||
|
||||
export default function Note({ children }: NoteProps) {
|
||||
export const Note = ({ children }: NoteProps) => {
|
||||
return (
|
||||
<div className='mt-6 rounded-md bg-gray-50 p-4 text-sm text-gray-600'>
|
||||
{children}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -3,13 +3,13 @@
|
||||
import { NewsTileType } from '@utils/validationSchemas';
|
||||
import { usePathname } from 'next/navigation';
|
||||
import { useCallback, useEffect, useState } from 'react';
|
||||
import Tile from './components/Tile';
|
||||
import { Tile } from './components/Tile';
|
||||
|
||||
interface TilesProps {
|
||||
children: React.ReactNode;
|
||||
}
|
||||
|
||||
export default function Tiles({ children }: TilesProps) {
|
||||
export const Tiles = ({ children }: TilesProps) => {
|
||||
const pathname = usePathname();
|
||||
const [windowSize, setWindowSize] = useState<{
|
||||
width: number;
|
||||
@@ -101,4 +101,4 @@ export default function Tiles({ children }: TilesProps) {
|
||||
if (pathname === '/maintenance') return <div>{children}</div>;
|
||||
|
||||
return <div className='flex h-[100vh] overflow-hidden'>{renderGrid()}</div>;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { getRandomGrey } from '@utils/getRandomGrey';
|
||||
import { NewsTileType } from '@utils/validationSchemas';
|
||||
import { useEffect, useState } from 'react';
|
||||
import TileContent from './TileContent';
|
||||
import { TileContent } from './TileContent';
|
||||
|
||||
interface CardProps {
|
||||
newsA?: NewsTileType;
|
||||
@@ -11,7 +11,7 @@ interface CardProps {
|
||||
const TEN_SECONDS = 10000;
|
||||
const HALF_SECOND = 500;
|
||||
|
||||
export default function Tile({ newsA, newsB }: CardProps) {
|
||||
export const Tile = ({ newsA, newsB }: CardProps) => {
|
||||
const [switched, setSwitched] = useState(false);
|
||||
const [active, setActive] = useState(false);
|
||||
const [delayed, setDelayed] = useState(true);
|
||||
@@ -65,4 +65,4 @@ export default function Tile({ newsA, newsB }: CardProps) {
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -7,12 +7,12 @@ interface CardContentProps {
|
||||
secondColor: string;
|
||||
}
|
||||
|
||||
export default function TileContent({
|
||||
export const TileContent = ({
|
||||
story,
|
||||
side,
|
||||
firstColor,
|
||||
secondColor
|
||||
}: CardContentProps) {
|
||||
}: CardContentProps) => {
|
||||
const color = side ? firstColor : secondColor;
|
||||
|
||||
return (
|
||||
@@ -38,4 +38,4 @@ export default function TileContent({
|
||||
></div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user