Skip to content

Commit

Permalink
Solved few more reliability issues
Browse files Browse the repository at this point in the history
  • Loading branch information
anoopkarnik committed Feb 2, 2025
1 parent 8320649 commit 9d1f3e8
Show file tree
Hide file tree
Showing 25 changed files with 56 additions and 108 deletions.
8 changes: 1 addition & 7 deletions apps/nextjs-app/app/auth/error/page.tsx
Original file line number Diff line number Diff line change
@@ -1,23 +1,17 @@
"use client"
import ErrorPage from '@repo/ui/templates/auth/v1/ErrorPage'
import { useRouter } from 'next/navigation'
import React from 'react'

const ErrorTemp = () => {

const router = useRouter()

const quote = 'The only way to do great work is to love what you do.'
const author = 'Late Steve Jobs'
const credential = 'Ex CEO of Apple Inc.'
const errorMessage = 'Oops! Something went wrong!'
const goToLoginPage = ()=>{
router.push('/auth/login')
}

return (
<div>
<ErrorPage errorMessage={errorMessage} backFunction={goToLoginPage} quote={quote} author={author} credential={credential}/>
<ErrorPage errorMessage={errorMessage} quote={quote} author={author} credential={credential}/>
</div>
)
}
Expand Down
12 changes: 2 additions & 10 deletions apps/nextjs-app/app/auth/forgot-password/page.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
'use client'

import { useRouter} from 'next/navigation'
import React, {useState,useEffect } from 'react'
import ForgotPasswordPage from '@repo/ui/templates/auth/v1/ForgotPasswordPage'
import { ForgotPassword } from '../_actions/forgot-password'

const ForgotPasswordClient = () => {
const router = useRouter()


const quote = 'The only way to do great work is to love what you do.'
const author = 'Late Steve Jobs'
Expand All @@ -16,10 +15,6 @@ const ForgotPasswordClient = () => {
const [error, setError] = useState<string | undefined>()
const [success, setSuccess] = useState<string | undefined>()

const goToLoginPage = ()=>{
router.push('/auth/login')
}

const ResetPasswordFunction = async (email: string) => {
if (success || error) return;
try {
Expand All @@ -31,13 +26,10 @@ const ForgotPasswordClient = () => {
}
}

useEffect(()=>{

},[success,error])

return (
<div>
<ForgotPasswordPage errorMessage={error} successMessage={success} resetFunction={ResetPasswordFunction} backFunction={goToLoginPage}
<ForgotPasswordPage errorMessage={error} successMessage={success} resetFunction={ResetPasswordFunction}
title={title} description={description} quote={quote} author={author} credential={credential} />
</div>
)
Expand Down
14 changes: 1 addition & 13 deletions apps/nextjs-app/app/auth/login/page.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
'use client'

import LoginPage from '@repo/ui/templates/auth/v1/LoginPage'
import { useRouter, useSearchParams } from 'next/navigation'
import { useSearchParams } from 'next/navigation'
import React, { Suspense, useEffect, useState } from 'react'
import { DEFAULT_LOGIN_REDIRECT } from '../../../routes'
import { signIn } from 'next-auth/react'
import { login } from '../_actions/login'

const LoginContent = () => {
const router = useRouter()
const searchParams = useSearchParams()

const [urlError, setUrlError] = useState('')
Expand All @@ -19,21 +18,12 @@ const LoginContent = () => {
setUrlError('This email is already in use with another provider.')
}
}, [searchParams])



const loginWithSocials = async (type: string) => {
await signIn(type, { callbackUrl: DEFAULT_LOGIN_REDIRECT })
}

const goToForgotPasswordPage = () => {
router.push('/auth/forgot-password')
}

const goToRegisterPage = () => {
router.push('/auth/register')
}

const title = 'Loading...'
const description = 'Please wait while we are loading the page!'
const quote = 'The only way to do great work is to love what you do.'
Expand All @@ -59,8 +49,6 @@ const LoginContent = () => {
onGoogleProviderSubmit={()=>loginWithSocials('google')}
onGithubProviderSubmit={()=>loginWithSocials('github')}
onLinkedinProviderSubmit={()=>loginWithSocials('linkedin')}
forgotPasswordFunction={goToForgotPasswordPage}
backFunction={goToRegisterPage}
errorMessage={urlError}
/>
)
Expand Down
7 changes: 1 addition & 6 deletions apps/nextjs-app/app/auth/new-verification/page.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
'use client'

import NewVerificationPage from '@repo/ui/templates/auth/v1/NewVerificationPage'
import { useRouter, useSearchParams } from 'next/navigation'
import { useSearchParams } from 'next/navigation'
import React, { Suspense, useEffect, useState,useCallback } from 'react'
import { newVerification } from '../_actions/new-verification'

const NewVerificationContent = () => {

const router = useRouter();
const [error, setError] = useState<string | undefined>()
const [success, setSuccess] = useState<string | undefined>()
const searchParams = useSearchParams();
Expand Down Expand Up @@ -38,15 +37,11 @@ const NewVerificationContent = () => {
const author = 'Late Steve Jobs'
const credential = 'Ex CEO of Apple Inc.'

const goToLoginPage = () => {
router.push('/auth/login')
}

return (
<NewVerificationPage
errorMessage={error}
successMessage={success}
backFunction={goToLoginPage}
title={title}
description={description}
quote={quote}
Expand Down
8 changes: 1 addition & 7 deletions apps/nextjs-app/app/auth/register/page.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
'use client'

import RegisterPage from '@repo/ui/templates/auth/v1/RegisterPage'
import { useRouter, useSearchParams } from 'next/navigation'
import { useSearchParams } from 'next/navigation'
import React, { Suspense, useEffect, useState } from 'react'
import { DEFAULT_LOGIN_REDIRECT } from '../../../routes'
import { signIn } from 'next-auth/react'
import { register } from '../_actions/register'

const RegisterContent = () => {
const router = useRouter()
const searchParams = useSearchParams()

const [urlError, setUrlError] = useState('')
Expand All @@ -34,10 +33,6 @@ const RegisterContent = () => {
await signIn(type, { callbackUrl: DEFAULT_LOGIN_REDIRECT })
}

const goToLoginPage = () => {
router.push('/auth/login')
}

return (
<RegisterPage
title={title}
Expand All @@ -53,7 +48,6 @@ const RegisterContent = () => {
onGoogleProviderSubmit={login}
onGithubProviderSubmit={login}
onLinkedinProviderSubmit={login}
backFunction={goToLoginPage}
errorMessage={urlError}
/>
)
Expand Down
10 changes: 2 additions & 8 deletions apps/nextjs-app/app/auth/reset-password/page.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use client'

import { useRouter, useSearchParams } from 'next/navigation'
import { useSearchParams } from 'next/navigation'
import React, { Suspense, useEffect, useState } from 'react'
import ResetPasswordPage from '@repo/ui/templates/auth/v1/ResetPasswordPage'
import { verifyResetToken } from '../_actions/verify-reset-token'
Expand All @@ -10,7 +10,6 @@ import { DataResultProps } from '@repo/ts-types/auth/v1'

const ResetPasswordContent = () => {

const router = useRouter();
const [error, setError] = useState<string | undefined>('')
const [success, setSuccess] = useState<string | undefined>('')
const searchParams = useSearchParams();
Expand All @@ -33,18 +32,14 @@ const ResetPasswordContent = () => {
const author = 'Late Steve Jobs'
const credential = 'Ex CEO of Apple Inc.'

const goToLoginPage = () => {
router.push('/auth/login')
}

if (error){
return (
<ErrorPage
errorMessage={error}
quote={quote}
author={author}
credential={credential}
backFunction={goToLoginPage}/>
credential={credential}/>
)
}
else if (success){
Expand All @@ -53,7 +48,6 @@ const ResetPasswordContent = () => {
errorMessage={error}
successMessage={success}
token={token as string}
backFunction={goToLoginPage}
resetFunction={resetPassword}
title={title}
description={description}
Expand Down
4 changes: 1 addition & 3 deletions packages/email/src/templates/ResetPassword.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,7 @@ const ResetPassword = ({ resetPasswordLink }: { resetPasswordLink: string }) =>
href="mailto:support@bsamaritan.com"
className="text-green-500 underline"
>
contact us
</a>
.
contact us</a>.
</Text>
</Section>
</Container>
Expand Down
7 changes: 0 additions & 7 deletions packages/ts-types/src/auth/v1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ export interface LoginCardProps {
onGoogleProviderSubmit?: any;
onGithubProviderSubmit?: any;
onLinkedinProviderSubmit?: any;
forgotPasswordFunction?: any;
backFunction?:()=>void;
errorMessage?:string;
}

Expand All @@ -48,23 +46,20 @@ export interface RegisterCardProps {
onGoogleProviderSubmit?: any;
onGithubProviderSubmit?: any;
onLinkedinProviderSubmit?: any;
backFunction?:() => void;
errorMessage?:string;
}

export interface VerificationCardProps {
errorMessage?:string;
successMessage?:string;
token?: string;
backFunction?:() => void;
resetFunction?:any;
}

export interface ResetPasswordCardProps {
errorMessage?:string;
successMessage?:string;
token?: string;
backFunction?:() => void;
resetFunction?:any;
}

Expand All @@ -74,12 +69,10 @@ export interface ForgotPasswordCardProps {
errorMessage?:string;
successMessage?:string;
resetFunction?:any;
backFunction?:() => void;
}

export interface ErrorCardProps {
errorMessage?:string;
backFunction?:any
}

//Complex Interfaces for Auth Pages
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@ import { Card, CardFooter, CardHeader } from '../../../../molecules/shadcn/card
import { BsExclamationTriangle } from 'react-icons/bs';
import { ErrorCardProps } from '@repo/ts-types/auth/v1';
import { Button } from '../../../../atoms/shadcn/button';
import { useRouter } from 'next/navigation';

const ErrorCard = ({errorMessage,backFunction}:ErrorCardProps) => {
const ErrorCard = ({errorMessage}:ErrorCardProps) => {

const router = useRouter();

return (
<Card className='w-[400px] bg-white text-black shadow-xl shadow-white/20'>
Expand All @@ -14,7 +17,7 @@ const ErrorCard = ({errorMessage,backFunction}:ErrorCardProps) => {
<div className='text-md font-extralight text-center'>{errorMessage || "Oops! Something went wrong!"}</div>
</CardHeader>
<CardFooter className='flex justify-center'>
<Button onClick={backFunction} variant={'blank'}
<Button onClick={()=>router.push('/auth/login')} variant={'blank'}
className='text-sm text-center text-black/60 hover:text-black cursor-pointer hover:underline'>
Back to login
</Button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ import {
import { Input } from '../../../../atoms/shadcn/input';
import { FormResult } from './FormResult';
import { ForgotPasswordCardProps } from '@repo/ts-types/auth/v1';
import { useRouter } from 'next/navigation';

const ForgotPasswordCard = ({errorMessage,successMessage,resetFunction,backFunction}
const ForgotPasswordCard = ({errorMessage,successMessage,resetFunction}
:ForgotPasswordCardProps
) => {
const form = useForm<z.infer<typeof ForgotPasswordSchema>>({
Expand All @@ -44,6 +45,8 @@ const ForgotPasswordCard = ({errorMessage,successMessage,resetFunction,backFunct
});
}

const router = useRouter();

return (
<Card className='w-[400px] bg-white text-black shadow-xl shadow-white/20'>
<CardHeader>
Expand Down Expand Up @@ -71,7 +74,7 @@ const ForgotPasswordCard = ({errorMessage,successMessage,resetFunction,backFunct
</Form>
</CardContent>
<CardFooter className='flex justify-center'>
<Button onClick={backFunction} variant={'blank'}
<Button onClick={()=>router.push('/auth/login')} variant={'blank'}
className='text-sm text-center text-black/60 hover:text-black cursor-pointer hover:underline'>
Go to Login Page
</Button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { LoginCardProps } from '@repo/ts-types/auth/v1';
import { useRouter } from 'next/navigation';

const LoginCard = ({showEmail,showGoogleProvider,showGithubProvider,showLinkedinProvider,onEmailSubmit,
onGoogleProviderSubmit,onGithubProviderSubmit,onLinkedinProviderSubmit,forgotPasswordFunction,backFunction,errorMessage}
onGoogleProviderSubmit,onGithubProviderSubmit,onLinkedinProviderSubmit,errorMessage}
:LoginCardProps
) => {
const form = useForm<z.infer<typeof LoginSchema>>({
Expand Down Expand Up @@ -106,7 +106,7 @@ const LoginCard = ({showEmail,showGoogleProvider,showGithubProvider,showLinkedin
</FormItem>
)}/>
</div>
<button onClick={forgotPasswordFunction} className='text-sm text-left text-black/60 hover:text-black cursor-pointer hover:underline'>Forgot Password</button>
<button type="button" onClick={()=>router.push('/auth/forgot-password')} className='text-sm text-left text-black/60 hover:text-black cursor-pointer hover:underline'>Forgot Password</button>
<FormResult type="error" message={error }/>
<FormResult type="success" message={success}/>
<Button className='w-full' disabled={isPending} variant="default" type="submit">Login</Button>
Expand All @@ -123,7 +123,7 @@ const LoginCard = ({showEmail,showGoogleProvider,showGithubProvider,showLinkedin
<Button className='w-full' disabled={isPending} variant="default" onClick={loginAsAdmin}>Login as Admin</Button>
</CardFooter>
<CardFooter className='flex justify-center'>
<button onClick={backFunction}
<button onClick={()=>router.push('/auth/register')}
className='text-sm text-center text-black/60 hover:text-black cursor-pointer hover:underline'>
Don't have an Account?
</button>
Expand All @@ -132,9 +132,8 @@ const LoginCard = ({showEmail,showGoogleProvider,showGithubProvider,showLinkedin
<span>
By signing up, you agree to our <button
onClick={() => router.push('/landing/terms-of-service')}
className='cursor-pointer text-blue-400 hover:text-blue-800'> Terms of Service
</button>
, <button
className='cursor-pointer text-blue-400 hover:text-blue-800'> Terms of Service, </button>
<button
onClick={() => router.push('/landing/privacy-policy')}
className='cursor-pointer text-blue-400 hover:text-blue-800'> Privacy Policy.
</button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ import { FormResult } from './FormResult';
import { RegisterCardProps } from '@repo/ts-types/auth/v1';
import { useRouter } from 'next/navigation';
const RegisterCard = ({showEmail,showGoogleProvider,showGithubProvider,showLinkedinProvider,
onEmailSubmit,onGoogleProviderSubmit,onGithubProviderSubmit,onLinkedinProviderSubmit,backFunction,
errorMessage}:RegisterCardProps
onEmailSubmit,onGoogleProviderSubmit,onGithubProviderSubmit,onLinkedinProviderSubmit, errorMessage}:RegisterCardProps
) => {
const form = useForm<z.infer<typeof RegisterSchema>>({
resolver: zodResolver(RegisterSchema),
Expand Down Expand Up @@ -99,17 +98,16 @@ const RegisterCard = ({showEmail,showGoogleProvider,showGithubProvider,showLinke
{showLinkedinProvider && <Button onClick={onLinkedinProviderSubmit} variant='secondary' className="w-full"><FaLinkedin/></Button>}
</CardFooter>
<CardFooter className='flex justify-center'>
<button onClick={backFunction} className='text-sm text-center text-black/60 hover:text-black cursor-pointer hover:underline'>
<button onClick={()=>router.push('/auth/login')} className='text-sm text-center text-black/60 hover:text-black cursor-pointer hover:underline'>
Already have an Account!
</button>
</CardFooter>
<CardFooter className='text-description text-wrap mx-2 text-center'>
<span>
By signing up, you agree to our <button
onClick={() => router.push('/landing/terms-of-service')}
className='cursor-pointer text-blue-400 hover:text-blue-800'> Terms of Service
</button>
, <button
className='cursor-pointer text-blue-400 hover:text-blue-800'> Terms of Service, </button>
<button
onClick={() => router.push('/landing/privacy-policy')}
className='cursor-pointer text-blue-400 hover:text-blue-800'> Privacy Policy.
</button>
Expand Down
Loading

0 comments on commit 9d1f3e8

Please sign in to comment.