mirror of
https://github.com/dsoaress/link-free.git
synced 2026-08-17 23:16:03 +01:00
refactor: with styled-components
This commit is contained in:
@@ -1,13 +1,14 @@
|
||||
import type { AppProps } from 'next/app'
|
||||
|
||||
import { DataProvider } from '../contexts/DataContext'
|
||||
import { globalStyles } from '../styles/globals'
|
||||
import { Layout } from '../styles/layout'
|
||||
|
||||
export default function App({ Component, pageProps }: AppProps) {
|
||||
globalStyles()
|
||||
return (
|
||||
<DataProvider>
|
||||
<Component {...pageProps} />
|
||||
<DataProvider initialData={pageProps.initialData}>
|
||||
<Layout>
|
||||
<Component {...pageProps} />
|
||||
</Layout>
|
||||
</DataProvider>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
import NextDocument, { Head, Html, Main, NextScript } from 'next/document'
|
||||
|
||||
import { getCssText } from '../styles/stitches.config'
|
||||
|
||||
export default class Document extends NextDocument {
|
||||
render() {
|
||||
return (
|
||||
@@ -13,7 +11,6 @@ export default class Document extends NextDocument {
|
||||
href="https://fonts.googleapis.com/css2?family=Baloo+Bhaijaan+2:wght@400;500&family=Montserrat:wght@400;500&family=Roboto:wght@400;500&display=swap"
|
||||
rel="stylesheet"
|
||||
/>
|
||||
<style id="stitches" dangerouslySetInnerHTML={{ __html: getCssText() }} />
|
||||
</Head>
|
||||
<body>
|
||||
<Main />
|
||||
|
||||
@@ -3,7 +3,7 @@ import type { NextApiRequest, NextApiResponse } from 'next'
|
||||
import nc from 'next-connect'
|
||||
|
||||
import { prisma } from '../../services/prisma'
|
||||
import { authMiddleware } from '../../utils/authMiddleware'
|
||||
// import { authMiddleware } from '../../utils/authMiddleware'
|
||||
import { ExceptionError } from '../../utils/error'
|
||||
|
||||
const handler = nc<NextApiRequest, NextApiResponse>({
|
||||
@@ -29,7 +29,6 @@ const handler = nc<NextApiRequest, NextApiResponse>({
|
||||
}
|
||||
}
|
||||
})
|
||||
.use(authMiddleware)
|
||||
.get(async (_req, res) => {
|
||||
const response = await prisma.data.findUnique({
|
||||
where: { id: 1 }
|
||||
@@ -41,6 +40,7 @@ const handler = nc<NextApiRequest, NextApiResponse>({
|
||||
|
||||
res.status(200).json(response?.data)
|
||||
})
|
||||
// .use(authMiddleware)
|
||||
.put(async (req, res) => {
|
||||
const { data } = req.body
|
||||
|
||||
|
||||
@@ -2,14 +2,9 @@ import { GetServerSideProps } from 'next'
|
||||
|
||||
import { Dash } from '../components/Dash'
|
||||
import { fetchData } from '../services/fetchData'
|
||||
import type { Data } from '../types/Data'
|
||||
|
||||
type DashPageProps = {
|
||||
initialData: Data
|
||||
}
|
||||
|
||||
export default function DashPage({ initialData }: DashPageProps) {
|
||||
return <Dash initialData={initialData} />
|
||||
export default function DashPage() {
|
||||
return <Dash />
|
||||
}
|
||||
|
||||
export const getServerSideProps: GetServerSideProps = async () => {
|
||||
|
||||
@@ -1,24 +1,17 @@
|
||||
import { GetStaticProps } from 'next'
|
||||
|
||||
import { Home } from '../components/Home'
|
||||
import { useFetchData } from '../hooks/useFetchData'
|
||||
import { fetchData } from '../services/fetchData'
|
||||
import type { Data } from '../types/Data'
|
||||
|
||||
type HomePageProps = {
|
||||
data: Data
|
||||
}
|
||||
|
||||
export default function HomePage({ data }: HomePageProps) {
|
||||
useFetchData(data)
|
||||
export default function HomePage() {
|
||||
return <Home />
|
||||
}
|
||||
|
||||
export const getStaticProps: GetStaticProps = async () => {
|
||||
const data = await fetchData()
|
||||
const initialData = await fetchData()
|
||||
|
||||
return {
|
||||
props: { data },
|
||||
props: { initialData },
|
||||
revalidate: 1
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user