diff --git a/.pages/_app.tsx b/.pages/_app.tsx deleted file mode 100644 index 82b7f9c..0000000 --- a/.pages/_app.tsx +++ /dev/null @@ -1,90 +0,0 @@ -import React from 'react'; -import { SessionProvider } from 'next-auth/react'; -import { Session } from 'next-auth'; -import '@styles/globals.css'; -import type { AppProps } from 'next/app'; -import { PageLayout } from 'components/layout'; -import { generateBrowserId } from '@lib/browser'; -import Cookies from 'js-cookie'; -import Head from 'next/head'; -import { NextPageWithLayout } from 'types/page-with-layout'; -import { ThemeProvider } from 'next-themes'; - -type AppPropsWithLayout = AppProps & { - Component: NextPageWithLayout; -}; - -const MyApp = ({ - Component, - pageProps: { session, ...pageProps }, -}: AppPropsWithLayout<{ session: Session }>) => { - const getLayout = - Component.getLayout ?? - ((page: React.ReactElement) => ( - - - - - - )); - React.useEffect(() => { - const checkBrowserId = async () => { - const storedId = localStorage.getItem('__effp'); - if (!storedId) { - localStorage.setItem('__effp', generateBrowserId()); - } - Cookies.set('bid', localStorage.getItem('__effp') as string, { - sameSite: 'strict', - expires: new Date(8640000000000000), - }); - }; - checkBrowserId().catch(console.error); - }, []); - return ( - - - Frasier Gifs - - - - - - - - - {getLayout()} - - ); -}; - -export default MyApp; diff --git a/.pages/auth/signup.tsx b/.pages/auth/signup.tsx deleted file mode 100644 index 3207f06..0000000 --- a/.pages/auth/signup.tsx +++ /dev/null @@ -1,220 +0,0 @@ -import React, { FormEventHandler } from 'react'; -import { useRouter } from 'next/router'; -import { logger } from '@lib/logger'; - -const SignUpPage = () => { - const router = useRouter(); - const [userInfo, setUserInfo] = React.useState({ - email: 'fergal.moran+frasiergifs@gmail.com', - password: 'secret', - repeatPassword: 'secret', - }); - const handleSubmit: FormEventHandler = async (e) => { - //TODO: validation - e.preventDefault(); - try { - const res = await fetch(`/api/user/create`, { - method: 'POST', - headers: { 'Content-Type': 'application/json' }, - body: JSON.stringify({ - email: userInfo.email, - password: userInfo.password, - }), - }); - logger.debug(`res`, res); - router.push( - `signin${ - router.query.callbackUrl - ? `?callbackUrl=${router.query.callbackUrl}` - : '' - }` - ); - } catch (error) { - console.error(error); - } - }; - - return ( -
-
- {/* Signin */} - Workflow -

- Create new account -

-
- -
-
-
-
- -
- - setUserInfo({ ...userInfo, email: target.value }) - } - className="block w-full px-3 py-2 placeholder-gray-400 border border-gray-300 rounded-md shadow-sm appearance-none focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm" - /> -
-
- -
- -
- - setUserInfo({ ...userInfo, password: target.value }) - } - className="block w-full px-3 py-2 placeholder-gray-400 border border-gray-300 rounded-md shadow-sm appearance-none focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm" - /> -
-
-
- -
- - setUserInfo({ ...userInfo, repeatPassword: target.value }) - } - className="block w-full px-3 py-2 placeholder-gray-400 border border-gray-300 rounded-md shadow-sm appearance-none focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm" - /> -
-
- -
- -
-
- -
-
-
-
-
-
- - {' '} - Or continue with{' '} - -
-
- - -
-
-
-
- ); -}; - -export default SignUpPage; diff --git a/.pages/colours.tsx b/.pages/colours.tsx deleted file mode 100644 index 68215f9..0000000 --- a/.pages/colours.tsx +++ /dev/null @@ -1,29 +0,0 @@ -import React from 'react'; - -const ColoursPage = () => { - return ( - -
- - - - - - -
-
- ); -}; -export default ColoursPage; diff --git a/.pages/debug.tsx b/.pages/debug.tsx deleted file mode 100644 index 4eaf9df..0000000 --- a/.pages/debug.tsx +++ /dev/null @@ -1,56 +0,0 @@ -import { NextPage, GetServerSideProps } from 'next'; -import { useSession } from 'next-auth/react'; -import Router from 'next/router'; -import React from 'react'; -import SharingEmbedComponent from '@components/sharing/SharingEmbedComponent'; -import { Gif } from 'models'; -import { mapGif } from '@lib/mapping/gif'; -import client from '@lib/prismadb'; -interface IDebugPageProps { - gif: Gif; -} -const DebugPage: NextPage = ({ gif }): JSX.Element => { - const { status, data } = useSession(); - React.useEffect(() => { - if (status === 'unauthenticated') Router.replace('/auth/signin'); - }, [status]); - - if (status === 'authenticated') { - return ( - - close()} - gif={gif} - /> - - ); - } - return
Loading....
; -}; -export const getServerSideProps: GetServerSideProps = async ({ req }) => { - const results = await client.gif.findMany({ - take: 1, - include: { - _count: { - select: { - upVotes: true, - downVotes: true, - }, - }, - }, - orderBy: { - upVotes: { - _count: 'desc', - }, - }, - }); - const gifs = await Promise.all( - results.map(async (gif): Promise => mapGif(gif)) - ); - return { - props: { - gif: gifs[0], - }, - }; -}; -export default DebugPage; diff --git a/.pages/gifs/[slug].tsx b/.pages/gifs/[slug].tsx deleted file mode 100644 index df75476..0000000 --- a/.pages/gifs/[slug].tsx +++ /dev/null @@ -1,78 +0,0 @@ -import { - AddCommentComponent, - GifContainer, - SharingComponent, -} from '@components'; -import React from 'react'; -import { GetServerSideProps } from 'next'; -import client from '@lib/prismadb'; -import { Gif } from 'models'; -import { mapGif } from '@lib/mapping/gif'; -interface IGifPageProps { - gif: Gif; -} -const GifPage: React.FC = ({ gif }) => { - return ( -
-
-
-
-
-

- - {gif.title} - -

-

- {gif.description} -

- - {/*
- -
*/} -
-
-
- The gif - -
-
-
-
-
-
- ); -}; - -export const getServerSideProps: GetServerSideProps = async ({ - params, - req, -}) => { - const gif = await client.gif.findUnique({ - where: { - slug: params?.slug as string, - }, - include: { - _count: { - select: { - upVotes: true, - downVotes: true, - }, - }, - }, - }); - if (!gif) { - return { - notFound: true, - }; - } - return { - props: { - gif: mapGif(gif), - }, - }; -}; -export default GifPage; diff --git a/.pages/index.tsx b/.pages/index.tsx deleted file mode 100644 index abb0f16..0000000 --- a/.pages/index.tsx +++ /dev/null @@ -1,56 +0,0 @@ -import type { GetServerSideProps, NextPage } from 'next'; -import { Gif } from 'models'; -import { GifContainer } from 'components'; -import { mapGif } from '@lib/mapping/gif'; -import client from '@lib/prismadb'; - -interface IHomeProps { - gifs: Gif[]; -} - -const Home: NextPage = ({ gifs }) => { - return ( -
-
- {gifs.map((gif: Gif) => { - return ( -
- -
- ); - })} -
-
- ); -}; - -export const getServerSideProps: GetServerSideProps = async ({ req }) => { - const results = await client.gif.findMany({ - take: 12, - include: { - _count: { - select: { - upVotes: true, - downVotes: true, - }, - }, - }, - orderBy: { - upVotes: { - _count: 'desc', - }, - }, - }); - const gifs = await Promise.all( - results.map(async (gif): Promise => mapGif(gif)) - ); - return { - props: { - gifs, - }, - }; -}; -export default Home; diff --git a/.pages/protected.tsx b/.pages/protected.tsx deleted file mode 100644 index 9c152ae..0000000 --- a/.pages/protected.tsx +++ /dev/null @@ -1,18 +0,0 @@ -import { NextPage } from 'next'; -import { useSession } from 'next-auth/react'; -import Router from 'next/router'; -import React from 'react'; - -const ProtectedPage: NextPage = (): JSX.Element => { - const { status, data } = useSession(); - React.useEffect(() => { - if (status === 'unauthenticated') Router.replace('/auth/signin'); - }, [status]); - - if (status === 'authenticated') { - return
ProtectedPage
; - } - return
Loading....
; -}; - -export default ProtectedPage; diff --git a/.pages/request.tsx b/.pages/request.tsx deleted file mode 100644 index 7529829..0000000 --- a/.pages/request.tsx +++ /dev/null @@ -1,34 +0,0 @@ -import React from 'react'; -import { useSession } from 'next-auth/react'; -import Router from 'next/router'; - -const RequestPage = () => { - const { status } = useSession(); - React.useEffect(() => { - if (status === 'unauthenticated') Router.replace('/auth/signin'); - }, [status]); - - return status === 'authenticated' ? ( -
-
-

- - Work in progress - - - Request a gif - -

-

- Here you can allow your users to request a gif, if you have the TV - Show module enabled you can allow Season/Episode/Timestamp/Duration - type stuff -

-
-
- ) : ( -
Loading....
- ); -}; - -export default RequestPage; diff --git a/.pages/share/[gif].tsx b/.pages/share/[gif].tsx deleted file mode 100644 index 223043c..0000000 --- a/.pages/share/[gif].tsx +++ /dev/null @@ -1,57 +0,0 @@ -import React from 'react'; -import { ThemeProvider } from 'next-themes'; -import { NextPageWithLayout } from 'types/page-with-layout'; -import { Gif } from '@models'; -import { GetServerSideProps } from 'next'; -import { mapGif } from '@lib/mapping/gif'; -import client from '@lib/prismadb'; -import { GifContainer } from '@components'; - -interface IShareGifPageProps { - gif: Gif; -} -const ShareGifPage: NextPageWithLayout = ({ gif }) => { - return ( -
- -
- ); -}; - -ShareGifPage.getLayout = (page: React.ReactElement) => { - return {page}; -}; - -export const getServerSideProps: GetServerSideProps = async ({ - params, - req, -}) => { - const gif = await client.gif.findUnique({ - where: { - slug: params?.gif as string, - }, - include: { - _count: { - select: { - upVotes: true, - downVotes: true, - }, - }, - }, - }); - if (!gif) { - return { - notFound: true, - }; - } - return { - props: { - gif: mapGif(gif), - }, - }; -}; -export default ShareGifPage; diff --git a/.pages/upload.tsx b/.pages/upload.tsx deleted file mode 100644 index 627f908..0000000 --- a/.pages/upload.tsx +++ /dev/null @@ -1,224 +0,0 @@ -import React from 'react'; -import { GetServerSideProps, NextPage } from 'next'; -import { Season, Episode } from 'models'; -import prisma from '@lib/prismadb'; -import { ImageUpload, TaggedInput } from '@components'; -import { Controller, SubmitHandler, useForm } from 'react-hook-form'; -import { useRouter } from 'next/router'; -import { useSession } from 'next-auth/react'; -import Router from 'next/router'; - -interface IUploadProps { - seasons: Season[]; -} - -const UploadPage: NextPage = ({ seasons }) => { - const { status } = useSession(); - React.useEffect(() => { - if (status === 'unauthenticated') Router.replace('/auth/signin'); - }, [status]); - - type FormValues = { - title: string; - description: string; - terms: string[]; - image: string | undefined; - }; - const { - register, - control, - handleSubmit, - formState: { errors }, - } = useForm({ - defaultValues: { - title: 'argle', - description: 'Argle bargle Foo Ferra', - terms: ['Niles', 'Frasier'], - image: undefined, - }, - }); - const router = useRouter(); - const [seasonEpisodes, setSeasonEpisodes] = React.useState>( - [] - ); - const [currentSeason, setCurrentSeason] = React.useState(seasons[0]); - React.useEffect(() => { - setSeasonEpisodes(currentSeason.episodes); - }, [currentSeason]); - const onSubmit: SubmitHandler = async (data) => { - console.log(data); - if (data.image) { - const body = new FormData(); - body.append('title', data.title); - body.append('description', data.description); - body.append('terms', data.terms.join('|')); - body.append('file', data.image); - const response = await fetch('api/upload', { - method: 'POST', - body, - }); - if (response.status === 201) { - await router.replace('/'); - } - } - }; - return status === 'authenticated' ? ( -
-
-
-

Upload a new gif

-

- The more info you can give us the better. -

-
-
-
-
-
-
-
- -
- -
-

- {errors.title?.message} -

-
-
- -
-