-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added document viewing functionality
- Loading branch information
1 parent
cdc14e9
commit bdc80a4
Showing
17 changed files
with
254 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,32 @@ | ||
import NextAuth from "next-auth"; | ||
import NextAuth, { Session, AuthOptions } from "next-auth"; | ||
import GoogleProvider from "next-auth/providers/google"; | ||
import { PrismaAdapter } from "@next-auth/prisma-adapter"; | ||
import prisma from "@/lib/db"; | ||
import { JWT } from "next-auth/jwt"; | ||
|
||
const handler = NextAuth({ | ||
providers:[ | ||
export const authOption: AuthOptions = { | ||
providers: [ | ||
GoogleProvider({ | ||
clientId: process.env.GOOGLE_CLIENT_ID!, | ||
clientSecret: process.env.GOOGLE_CLIENT_SECRET! | ||
}) | ||
clientId: process.env.GOOGLE_CLIENT_ID!, | ||
clientSecret: process.env.GOOGLE_CLIENT_SECRET!, | ||
}), | ||
], | ||
secret: process.env.NEXTAUTH_SECRET!, | ||
session:{strategy: "jwt"}, | ||
session: { | ||
strategy: "jwt", // This ensures TypeScript recognizes this as a valid strategy | ||
}, | ||
adapter: PrismaAdapter(prisma), | ||
}) | ||
callbacks: { | ||
session: async ({ session, token }: { session: Session; token: JWT }) => { | ||
if (token && session.user) { | ||
session.user.id = token.sub; | ||
session.user.email = token.email; | ||
} | ||
return session; | ||
}, | ||
}, | ||
}; | ||
|
||
export { handler as GET, handler as POST } | ||
const handler = NextAuth(authOption); | ||
|
||
export { handler as GET, handler as POST, handler as OPTIONS }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import Document from '@/components/Document' | ||
import React from 'react' | ||
|
||
const Page = ({params : {documentId}} : {params:{documentId: string}}) => { | ||
return ( | ||
<div> | ||
<Document documentId={documentId} /> | ||
</div> | ||
) | ||
} | ||
|
||
export default Page |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import prisma from '@/lib/db' | ||
import React from 'react' | ||
|
||
const getDocument = async(id: string)=>{ | ||
return await prisma.document.findFirst({where: {id: id}}) | ||
} | ||
const Document = async ({documentId}: {documentId: string}) => { | ||
|
||
const result = await getDocument(documentId) | ||
|
||
return ( | ||
<div className='flex justify-center'> | ||
<iframe src={result?.url} className='w-[90vw] h-[90vh]' /> | ||
</div> | ||
) | ||
} | ||
|
||
export default Document |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
|
||
import React from "react"; | ||
import { DocumentType } from "@/lib/types"; | ||
import { Card, CardDescription, CardHeader, CardTitle } from "@/components/ui/card"; | ||
import Link from "next/link"; | ||
import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar" | ||
|
||
|
||
|
||
|
||
const DocumentGroup = ({documents}: {documents :DocumentType[]}) => { | ||
return ( | ||
<> | ||
{documents.map(({ name, id, user }) => { | ||
|
||
return ( <Link href={`/document/${id}`} key={id}> | ||
<Card className="min-h-[100px] flex flex-col justify-center items-center text-center cursor-pointer"> | ||
<CardHeader> | ||
<CardTitle className="text-left text-2xl "> | ||
{name} | ||
</CardTitle> | ||
</CardHeader> | ||
<CardDescription className="py-2 flex gap-1 items-center "> | ||
|
||
<Avatar className="h-6 w-6" > | ||
<AvatarImage src={user?.image || ""} className="w-6 h-6 rounded-full object-cover " /> | ||
|
||
<AvatarFallback> {user?.email[0]} </AvatarFallback> | ||
|
||
</Avatar> | ||
<p className="text-sm text-opacity-50"> | ||
{user?.email} | ||
</p> | ||
|
||
</CardDescription> | ||
</Card> | ||
</Link> | ||
); | ||
})} | ||
</> | ||
) | ||
} | ||
|
||
export default DocumentGroup |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
"use client" | ||
|
||
import * as React from "react" | ||
import * as AvatarPrimitive from "@radix-ui/react-avatar" | ||
|
||
import { cn } from "@/lib/utils" | ||
|
||
const Avatar = React.forwardRef< | ||
React.ElementRef<typeof AvatarPrimitive.Root>, | ||
React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Root> | ||
>(({ className, ...props }, ref) => ( | ||
<AvatarPrimitive.Root | ||
ref={ref} | ||
className={cn( | ||
"relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full", | ||
className | ||
)} | ||
{...props} | ||
/> | ||
)) | ||
Avatar.displayName = AvatarPrimitive.Root.displayName | ||
|
||
const AvatarImage = React.forwardRef< | ||
React.ElementRef<typeof AvatarPrimitive.Image>, | ||
React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Image> | ||
>(({ className, ...props }, ref) => ( | ||
<AvatarPrimitive.Image | ||
ref={ref} | ||
className={cn("aspect-square h-full w-full", className)} | ||
{...props} | ||
/> | ||
)) | ||
AvatarImage.displayName = AvatarPrimitive.Image.displayName | ||
|
||
const AvatarFallback = React.forwardRef< | ||
React.ElementRef<typeof AvatarPrimitive.Fallback>, | ||
React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Fallback> | ||
>(({ className, ...props }, ref) => ( | ||
<AvatarPrimitive.Fallback | ||
ref={ref} | ||
className={cn( | ||
"flex h-full w-full items-center justify-center rounded-full bg-muted", | ||
className | ||
)} | ||
{...props} | ||
/> | ||
)) | ||
AvatarFallback.displayName = AvatarPrimitive.Fallback.displayName | ||
|
||
export { Avatar, AvatarImage, AvatarFallback } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
/** @type {import('next').NextConfig} */ | ||
const nextConfig = {}; | ||
const nextConfig = {images:{ domains: ['lh3.googleusercontent.com'], | ||
}}; | ||
|
||
export default nextConfig; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.