-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
24 changed files
with
888 additions
and
729 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
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 +1,79 @@ | ||
|
||
'use client'; | ||
|
||
import { useState } from "react"; | ||
import { useRouter } from "next/navigation"; | ||
import { createClientComponentClient } from "@supabase/auth-helpers-nextjs"; | ||
import Link from 'next/link'; | ||
import { useTheme } from '../contexts/ThemeContext'; | ||
import { LoginUserInput, loginUserSchema } from '@/lib/user-schema'; | ||
import { zodResolver } from '@hookform/resolvers/zod'; | ||
import { useForm, SubmitHandler } from 'react-hook-form'; | ||
import toast from 'react-hot-toast'; | ||
import Image from 'next/image'; | ||
|
||
export default function LoginForm() { | ||
const [error, setError] = useState<string | null>(null); | ||
const [isLoading, setIsLoading] = useState(false); | ||
const router = useRouter(); | ||
const supabase = createClientComponentClient(); | ||
const { theme } = useTheme(); | ||
|
||
const methods = useForm<LoginUserInput>({ | ||
resolver: zodResolver(loginUserSchema), | ||
}); | ||
|
||
const { | ||
reset, | ||
handleSubmit, | ||
register, | ||
formState: { errors }, | ||
} = methods; | ||
|
||
const onSubmitHandler: SubmitHandler<LoginUserInput> = async (values) => { | ||
setIsLoading(true); | ||
setError(null); | ||
try { | ||
const { error } = await supabase.auth.signInWithPassword(values); | ||
if (error) throw error; | ||
toast.success('Successfully logged in'); | ||
router.push('/taskboard'); | ||
} catch (error: any) { | ||
setError(error.message); | ||
toast.error(error.message); | ||
reset({ password: '' }); | ||
} finally { | ||
setIsLoading(false); | ||
} | ||
}; | ||
|
||
const handleGoogleSignIn = async () => { | ||
try { | ||
const { error } = await supabase.auth.signInWithOAuth({ | ||
provider: 'google', | ||
options: { | ||
redirectTo: `${window.location.origin}/auth/callback`, | ||
}, | ||
}); | ||
if (error) throw error; | ||
} catch (error: any) { | ||
toast.error(error.message); | ||
} | ||
}; | ||
|
||
return ( | ||
<div className={`min-h-screen flex items-center justify-center bg-gray-50 py-12 px-4 sm:px-6 lg:px-8 ${theme === 'dark' ? 'bg-gray-900 text-white' : ''}`}> | ||
<div className="max-w-md w-full space-y-8"> | ||
<div> | ||
<h2 className={`mt-6 text-center text-3xl font-extrabold ${theme === 'dark' ? 'text-white' : 'text-gray-900'}`}> | ||
Sign in to your account | ||
</h2> | ||
</div> | ||
<form className="mt-8 space-y-6" onSubmit={handleSubmit(onSubmitHandler)}> | ||
{/* ... (rest of the form content remains the same) ... */} | ||
</form> | ||
|
||
{/* ... (Google sign-in button and sign-up link remain the same) ... */} | ||
</div> | ||
</div> | ||
); | ||
} |
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,13 +1,24 @@ | ||
import { cn } from "@/utils/cn"; | ||
import React from "react"; | ||
|
||
export function Label({ | ||
children, | ||
...props | ||
}: { children: React.ReactNode } & React.JSX.IntrinsicElements["label"]) { | ||
return ( | ||
<label className={cn("text-sm font-medium", props.className)} {...props}> | ||
{children} | ||
</label> | ||
); | ||
} | ||
import * as React from "react" | ||
import { cn } from "@/utils/cn" | ||
|
||
export interface LabelProps | ||
extends React.LabelHTMLAttributes<HTMLLabelElement> {} | ||
|
||
const Label = React.forwardRef<HTMLLabelElement, LabelProps>( | ||
({ className, ...props }, ref) => { | ||
return ( | ||
<label | ||
ref={ref} | ||
className={cn( | ||
"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70", | ||
className | ||
)} | ||
{...props} | ||
/> | ||
) | ||
} | ||
) | ||
|
||
Label.displayName = "Label" | ||
|
||
export { Label } |
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,29 +1,24 @@ | ||
import { Todo } from "@/app/types/todo"; | ||
import React from 'react'; | ||
|
||
interface TodoComponentProps { | ||
todo: Todo; | ||
onToggle: () => void; | ||
onDelete: () => void; | ||
interface TodoItem { | ||
id: string; | ||
user_id: string; | ||
text: string; | ||
created_at: string; | ||
// Add any other properties that your Todo type should have | ||
} | ||
|
||
export default function TodoComponent({ todo, onToggle, onDelete }: TodoComponentProps) { | ||
return ( | ||
<li className="flex items-center space-x-3 bg-gray-700 p-3 rounded"> | ||
<input | ||
type="checkbox" | ||
checked={todo.completed} | ||
onChange={onToggle} | ||
className="form-checkbox h-5 w-5 text-blue-600 rounded bg-gray-600 border-gray-500" | ||
/> | ||
<span className={`flex-grow ${todo.completed ? 'line-through text-gray-400' : 'text-white'}`}> | ||
{todo.title || todo.text} | ||
</span> | ||
<button | ||
onClick={onDelete} | ||
className="text-red-400 hover:text-red-300 transition-colors" | ||
> | ||
Delete | ||
</button> | ||
</li> | ||
); | ||
} | ||
interface TodoProps { | ||
todo: TodoItem; | ||
} | ||
|
||
const Todo: React.FC<TodoProps> = ({ todo }) => { | ||
return ( | ||
<div> | ||
<p>{todo.text}</p> | ||
{/* Render other todo properties as needed */} | ||
</div> | ||
); | ||
}; | ||
|
||
export default Todo; |
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
Empty file.
Empty file.
Empty file.
Empty file.
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
Oops, something went wrong.