Skip to content

Commit

Permalink
feat: implement sign in page
Browse files Browse the repository at this point in the history
  • Loading branch information
brunosllz committed Aug 29, 2023
1 parent 5695476 commit fd2fd22
Show file tree
Hide file tree
Showing 37 changed files with 4,340 additions and 364 deletions.
16 changes: 16 additions & 0 deletions components.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"$schema": "https://ui.shadcn.com/schema.json",
"style": "default",
"rsc": true,
"tsx": true,
"tailwind": {
"config": "tailwind.config.js",
"css": "src/app/globals.css",
"baseColor": "zinc",
"cssVariables": false
},
"aliases": {
"components": "@/components",
"utils": "@/lib/utils"
}
}
2,341 changes: 2,068 additions & 273 deletions package-lock.json

Large diffs are not rendered by default.

39 changes: 38 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,52 @@
},
"dependencies": {
"@auth/prisma-adapter": "^1.0.1",
"@hookform/resolvers": "^3.3.1",
"@prisma/client": "^5.2.0",
"@radix-ui/react-accordion": "^1.1.2",
"@radix-ui/react-alert-dialog": "^1.0.4",
"@radix-ui/react-aspect-ratio": "^1.0.3",
"@radix-ui/react-avatar": "^1.0.3",
"@radix-ui/react-checkbox": "^1.0.4",
"@radix-ui/react-collapsible": "^1.0.3",
"@radix-ui/react-context-menu": "^2.1.4",
"@radix-ui/react-dialog": "^1.0.4",
"@radix-ui/react-dropdown-menu": "^2.0.5",
"@radix-ui/react-hover-card": "^1.0.6",
"@radix-ui/react-icons": "^1.3.0",
"@radix-ui/react-label": "^2.0.2",
"@radix-ui/react-menubar": "^1.0.3",
"@radix-ui/react-navigation-menu": "^1.1.3",
"@radix-ui/react-popover": "^1.0.6",
"@radix-ui/react-progress": "^1.0.3",
"@radix-ui/react-radio-group": "^1.1.3",
"@radix-ui/react-scroll-area": "^1.0.4",
"@radix-ui/react-select": "^1.2.2",
"@radix-ui/react-separator": "^1.0.3",
"@radix-ui/react-slider": "^1.1.2",
"@radix-ui/react-slot": "^1.0.2",
"@radix-ui/react-switch": "^1.0.3",
"@radix-ui/react-tabs": "^1.0.4",
"@radix-ui/react-toast": "^1.1.4",
"@radix-ui/react-toggle": "^1.0.3",
"@radix-ui/react-tooltip": "^1.0.6",
"@t3-oss/env-nextjs": "^0.6.1",
"axios": "^1.4.0",
"cmdk": "^0.2.0",
"date-fns": "^2.30.0",
"jsonwebtoken": "^9.0.1",
"lucide-react": "^0.270.0",
"next": "13.4.13",
"next-auth": "^4.23.1",
"nookies": "^2.5.2",
"react": "18.2.0",
"react-dom": "18.2.0"
"react-day-picker": "^8.8.1",
"react-dom": "18.2.0",
"react-hook-form": "^7.45.4",
"tailwind-merge": "^1.14.0",
"tailwind-variants": "^0.1.13",
"tailwindcss-animate": "^1.0.7",
"zod": "^3.22.2"
},
"devDependencies": {
"@commitlint/cli": "^17.7.1",
Expand Down
92 changes: 46 additions & 46 deletions prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,26 @@ datasource db {
}

model Answer {
id String @id
id String @id @default(uuid())
content String
authorId String
projectId String
createdAt DateTime @default(now())
updatedAt DateTime?
updatedAt DateTime? @updatedAt
User User @relation(fields: [authorId], references: [id])
Project Project @relation(fields: [projectId], references: [id])
AnswerComment AnswerComment[]
project Project @relation(fields: [projectId], references: [id])
answerComment AnswerComment[]
}

model AnswerComment {
id String @id
id String @id @default(uuid())
content String
authorId String
answerId String
createdAt DateTime @default(now())
updatedAt DateTime?
Answer Answer @relation(fields: [answerId], references: [id])
User User @relation(fields: [authorId], references: [id])
updatedAt DateTime? @updatedAt
answer Answer @relation(fields: [answerId], references: [id])
user User @relation(fields: [authorId], references: [id])
}

model Notification {
Expand All @@ -43,60 +43,60 @@ model Notification {
}

model Project {
id String @id
authorId String
title String
content String
slug String
createdAt DateTime @default(now())
updatedAt DateTime?
requirementTimeAmount Int
requirementContent String?
requirementTimeIdentifier TIME_IDENTIFIER
Answer Answer[]
User User @relation(fields: [authorId], references: [id])
ProjectRole ProjectRole[]
TeamMember TeamMember[]
Technology Technology[]
id String @id @default(uuid())
authorId String
title String
content String
slug String
createdAt DateTime @default(now())
updatedAt DateTime? @updatedAt
requirementPeriodAmount Int
requirementContent String?
requirementPeriodIdentifier PERIOD_IDENTIFIER
answers Answer[]
users User @relation(fields: [authorId], references: [id])
projectRoles ProjectRole[]
teamMembers TeamMember[]
technologies Technology[]
@@unique([authorId, slug])
}

model ProjectRole {
id String @id
projectId String
roleId String
amount Int
Project Project @relation(fields: [projectId], references: [id])
Role Role @relation(fields: [roleId], references: [id])
User User[]
id String @id @default(uuid())
projectId String
roleId String
membersAmount Int
project Project @relation(fields: [projectId], references: [id])
role Role @relation(fields: [roleId], references: [id])
users User[]
@@unique([projectId, roleId])
}

model Role {
id String @id
name String @unique
ProjectRole ProjectRole[]
id String @id @default(uuid())
name String @unique
projectRoles ProjectRole[]
}

model TeamMember {
id String @id
id String @id @default(uuid())
recipientId String
permissionType MEMBER_PERMISSION_TYPE
status MEMBER_STATUS
projectId String
createdAt DateTime @default(now())
updatedAt DateTime
Project Project @relation(fields: [projectId], references: [id])
User User @relation(fields: [recipientId], references: [id])
updatedAt DateTime? @updatedAt
project Project @relation(fields: [projectId], references: [id])
user User @relation(fields: [recipientId], references: [id])
}

model Technology {
id String @id
slug String @unique
Project Project[]
User User[]
id String @id @default(uuid())
slug String @unique
projects Project[]
users User[]
}

model User {
Expand All @@ -112,16 +112,16 @@ model User {
linkedinLink String?
githubLink String?
createdAt DateTime @default(now())
updatedAt DateTime?
updatedAt DateTime? @updatedAt
userName String? @unique
Answer Answer[]
AnswerComment AnswerComment[]
authorIdToNotifcation Notification[] @relation("NotificationAuthorIdToUser")
recipientIdToNotification Notification[] @relation("NotificationRecipientIdToUser")
project Project[]
projects Project[]
teamMember TeamMember[]
projectRole ProjectRole[]
technology Technology[]
technologies Technology[]
account Account[]
session Session[]
}
Expand All @@ -146,7 +146,7 @@ model Account {
}

model Session {
id String @id @default(cuid())
id String @id @default(uuid())
sessionToken String @unique
userId String
expires DateTime
Expand All @@ -166,7 +166,7 @@ enum MEMBER_STATUS {
approved
}

enum TIME_IDENTIFIER {
enum PERIOD_IDENTIFIER {
day
week
month
Expand Down
11 changes: 11 additions & 0 deletions src/app/(app)/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { Header } from '@/components/header'
import { ReactNode } from 'react'

export default function AppLayout({ children }: { children: ReactNode }) {
return (
<div className="min-h-screen bg-background">
<Header />
<main className="mx-auto max-w-6xl p-6">{children}</main>
</div>
)
}
2 changes: 1 addition & 1 deletion src/app/(app)/page.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
'use client'

export default function Home() {
return <main className="flex h-screen items-center justify-center">Home</main>
return <main className="flex items-center justify-center">Home</main>
}
36 changes: 36 additions & 0 deletions src/app/auth/sign-in/components/sign-in-github-button.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
'use client'

import { Button } from '@/components/ui/button'
import { Icons } from '@/components/ui/icons'
import { ArrowRightIcon, GitHubLogoIcon } from '@radix-ui/react-icons'
import { signIn } from 'next-auth/react'
import { useState } from 'react'

export function SignInGithubButton() {
const [isLoading, setIsLoading] = useState(false)

function signInWithGithub() {
setIsLoading(true)

signIn('github', { callbackUrl: '/' }).catch(() => setIsLoading(false))
}

return (
<Button
className="group w-full justify-between"
disabled={isLoading}
onClick={signInWithGithub}
>
<span className="flex items-center gap-1">
{isLoading ? (
<Icons.spinner className="h-4 w-4 animate-spin" />
) : (
<GitHubLogoIcon className="h-4 w-4" />
)}
Contiue with Github
</span>

<ArrowRightIcon className="hidden transition-all group-hover:flex" />
</Button>
)
}
42 changes: 36 additions & 6 deletions src/app/auth/sign-in/page.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,40 @@
import { Button } from '@/components/button'
import { Metadata } from 'next'
import {
Card,
CardContent,
CardDescription,
CardFooter,
CardHeader,
CardTitle,
} from '@/components/ui/card'
import { SignInGithubButton } from './components/sign-in-github-button'

export default function SignIn() {
export const metadata: Metadata = {
title: 'Sign In',
description: 'Authentication forms built using the components.',
}

export default function AuthenticationPage() {
return (
<h1>
SignIn
<Button>Github</Button>
</h1>
<main className="flex h-screen w-full flex-col justify-center">
<Card className="mx-auto w-full max-w-[456px]">
<CardHeader>
<CardTitle>Sign In</CardTitle>
<CardDescription>to continue to Dev Xperience</CardDescription>
</CardHeader>
<CardContent>
<SignInGithubButton />
</CardContent>

<CardFooter>
<span className="flex items-center gap-1 text-sm">
No account?
<a href="#" className="text-sm font-bold">
Sign Up
</a>
</span>
</CardFooter>
</Card>
</main>
)
}
Loading

0 comments on commit fd2fd22

Please sign in to comment.