Bernt Christian Egeland 9 mesi fa
parent
commit
3423b102e4

+ 48 - 43
src/app/(public)/auth/reset-password/page.tsx

@@ -7,28 +7,28 @@ import { authClient } from '@/lib/auth-client'
 import { Button } from '@/components/ui/button'
 import { Button } from '@/components/ui/button'
 import { Input } from '@/components/ui/input'
 import { Input } from '@/components/ui/input'
 import { Label } from '@/components/ui/label'
 import { Label } from '@/components/ui/label'
-import { useGlassModal } from '@/components/glass-modal'
-import { Gauge, Loader2 } from 'lucide-react'
+import { Gauge, Loader2, XCircle } from 'lucide-react'
 
 
 function ResetPasswordInner() {
 function ResetPasswordInner() {
   const [newPassword, setNewPassword] = useState('')
   const [newPassword, setNewPassword] = useState('')
   const [confirmPassword, setConfirmPassword] = useState('')
   const [confirmPassword, setConfirmPassword] = useState('')
+  const [error, setError] = useState('')
   const [loading, setLoading] = useState(false)
   const [loading, setLoading] = useState(false)
   const [success, setSuccess] = useState(false)
   const [success, setSuccess] = useState(false)
   const searchParams = useSearchParams()
   const searchParams = useSearchParams()
-  const modal = useGlassModal()
   const token = searchParams.get('token') || ''
   const token = searchParams.get('token') || ''
 
 
   const handleSubmit = async (e: React.FormEvent) => {
   const handleSubmit = async (e: React.FormEvent) => {
     e.preventDefault()
     e.preventDefault()
+    setError('')
 
 
     if (newPassword !== confirmPassword) {
     if (newPassword !== confirmPassword) {
-      modal.open('error', 'Passwords do not match', 'Please ensure both passwords are the same.')
+      setError('Passwords do not match.')
       return
       return
     }
     }
 
 
     if (newPassword.length < 8) {
     if (newPassword.length < 8) {
-      modal.open('error', 'Password too short', 'Password must be at least 8 characters long.')
+      setError('Password must be at least 8 characters long.')
       return
       return
     }
     }
 
 
@@ -41,16 +41,12 @@ function ResetPasswordInner() {
       })
       })
 
 
       if (result.error) {
       if (result.error) {
-        modal.open(
-          'error',
-          'Reset Failed',
-          result.error.message || 'Could not reset password. The link may have expired.'
-        )
+        setError(result.error.message || 'Could not reset password. The link may have expired.')
       } else {
       } else {
         setSuccess(true)
         setSuccess(true)
       }
       }
     } catch {
     } catch {
-      modal.open('error', 'Reset Failed', 'An unexpected error occurred. Please try again.')
+      setError('An unexpected error occurred. Please try again.')
     } finally {
     } finally {
       setLoading(false)
       setLoading(false)
     }
     }
@@ -85,40 +81,49 @@ function ResetPasswordInner() {
   }
   }
 
 
   return (
   return (
-    <form onSubmit={handleSubmit} className="space-y-4">
-      <div className="space-y-2">
-        <Label htmlFor="new-password">New Password</Label>
-        <Input
-          id="new-password"
-          type="password"
-          placeholder="Enter new password"
-          value={newPassword}
-          onChange={(e) => setNewPassword(e.target.value)}
-          required
-          minLength={8}
-          className="h-11 bg-background/50"
-        />
-      </div>
+    <>
+      {error && (
+        <div className="mb-4 flex items-center gap-2 rounded-lg border border-destructive/30 bg-destructive/10 px-3 py-2.5 text-sm text-destructive">
+          <XCircle className="h-4 w-4 shrink-0" />
+          <span>{error}</span>
+        </div>
+      )}
+
+      <form onSubmit={handleSubmit} className="space-y-4">
+        <div className="space-y-2">
+          <Label htmlFor="new-password">New Password</Label>
+          <Input
+            id="new-password"
+            type="password"
+            placeholder="Enter new password"
+            value={newPassword}
+            onChange={(e) => setNewPassword(e.target.value)}
+            required
+            minLength={8}
+            className="h-11 bg-background/50"
+          />
+        </div>
 
 
-      <div className="space-y-2">
-        <Label htmlFor="confirm-password">Confirm Password</Label>
-        <Input
-          id="confirm-password"
-          type="password"
-          placeholder="Confirm new password"
-          value={confirmPassword}
-          onChange={(e) => setConfirmPassword(e.target.value)}
-          required
-          minLength={8}
-          className="h-11 bg-background/50"
-        />
-      </div>
+        <div className="space-y-2">
+          <Label htmlFor="confirm-password">Confirm Password</Label>
+          <Input
+            id="confirm-password"
+            type="password"
+            placeholder="Confirm new password"
+            value={confirmPassword}
+            onChange={(e) => setConfirmPassword(e.target.value)}
+            required
+            minLength={8}
+            className="h-11 bg-background/50"
+          />
+        </div>
 
 
-      <Button type="submit" className="h-11 w-full" disabled={loading}>
-        {loading ? <Loader2 className="mr-2 h-4 w-4 animate-spin" /> : null}
-        Reset Password
-      </Button>
-    </form>
+        <Button type="submit" className="h-11 w-full" disabled={loading}>
+          {loading ? <Loader2 className="mr-2 h-4 w-4 animate-spin" /> : null}
+          Reset Password
+        </Button>
+      </form>
+    </>
   )
   )
 }
 }
 
 

+ 12 - 5
src/app/(public)/auth/sign-in/sign-in-form.tsx

@@ -7,32 +7,32 @@ import { signIn } from '@/lib/auth-client'
 import { Button } from '@/components/ui/button'
 import { Button } from '@/components/ui/button'
 import { Input } from '@/components/ui/input'
 import { Input } from '@/components/ui/input'
 import { Label } from '@/components/ui/label'
 import { Label } from '@/components/ui/label'
-import { useGlassModal } from '@/components/glass-modal'
-import { Gauge, Loader2 } from 'lucide-react'
+import { Gauge, Loader2, XCircle } from 'lucide-react'
 
 
 function SignInFormInner({ registrationDisabled }: { registrationDisabled: boolean }) {
 function SignInFormInner({ registrationDisabled }: { registrationDisabled: boolean }) {
   const [email, setEmail] = useState('')
   const [email, setEmail] = useState('')
   const [password, setPassword] = useState('')
   const [password, setPassword] = useState('')
+  const [error, setError] = useState('')
   const [loading, setLoading] = useState(false)
   const [loading, setLoading] = useState(false)
   const router = useRouter()
   const router = useRouter()
   const searchParams = useSearchParams()
   const searchParams = useSearchParams()
-  const modal = useGlassModal()
 
 
   const handleSubmit = async (e: React.FormEvent) => {
   const handleSubmit = async (e: React.FormEvent) => {
     e.preventDefault()
     e.preventDefault()
     setLoading(true)
     setLoading(true)
+    setError('')
 
 
     try {
     try {
       const result = await signIn.email({ email, password })
       const result = await signIn.email({ email, password })
       if (result.error) {
       if (result.error) {
-        modal.open('error', 'Sign In Failed', result.error.message || 'Invalid credentials')
+        setError(result.error.message || 'Invalid email or password')
       } else {
       } else {
         const redirect = searchParams.get('redirect') || '/'
         const redirect = searchParams.get('redirect') || '/'
         router.push(redirect)
         router.push(redirect)
         router.refresh()
         router.refresh()
       }
       }
     } catch {
     } catch {
-      modal.open('error', 'Sign In Failed', 'An unexpected error occurred')
+      setError('An unexpected error occurred. Please try again.')
     } finally {
     } finally {
       setLoading(false)
       setLoading(false)
     }
     }
@@ -51,6 +51,13 @@ function SignInFormInner({ registrationDisabled }: { registrationDisabled: boole
         <p className="mt-1 text-sm text-muted-foreground">Sign in to your workshop</p>
         <p className="mt-1 text-sm text-muted-foreground">Sign in to your workshop</p>
       </div>
       </div>
 
 
+      {error && (
+        <div className="mb-4 flex items-center gap-2 rounded-lg border border-destructive/30 bg-destructive/10 px-3 py-2.5 text-sm text-destructive">
+          <XCircle className="h-4 w-4 shrink-0" />
+          <span>{error}</span>
+        </div>
+      )}
+
       <form onSubmit={handleSubmit} className="space-y-4">
       <form onSubmit={handleSubmit} className="space-y-4">
         <div className="space-y-2">
         <div className="space-y-2">
           <Label htmlFor="email">Email</Label>
           <Label htmlFor="email">Email</Label>

+ 13 - 9
src/app/(public)/auth/sign-up/sign-up-form.tsx

@@ -7,8 +7,7 @@ import { signUp } from '@/lib/auth-client'
 import { Button } from '@/components/ui/button'
 import { Button } from '@/components/ui/button'
 import { Input } from '@/components/ui/input'
 import { Input } from '@/components/ui/input'
 import { Label } from '@/components/ui/label'
 import { Label } from '@/components/ui/label'
-import { useGlassModal } from '@/components/glass-modal'
-import { Gauge, Loader2 } from 'lucide-react'
+import { Gauge, Loader2, XCircle } from 'lucide-react'
 import { acceptInvitation } from '@/features/team/Actions/acceptInvitation'
 import { acceptInvitation } from '@/features/team/Actions/acceptInvitation'
 
 
 export function SignUpForm({ inviteToken }: { inviteToken?: string }) {
 export function SignUpForm({ inviteToken }: { inviteToken?: string }) {
@@ -16,13 +15,14 @@ export function SignUpForm({ inviteToken }: { inviteToken?: string }) {
   const [email, setEmail] = useState('')
   const [email, setEmail] = useState('')
   const [password, setPassword] = useState('')
   const [password, setPassword] = useState('')
   const [termsAccepted, setTermsAccepted] = useState(false)
   const [termsAccepted, setTermsAccepted] = useState(false)
+  const [error, setError] = useState('')
   const [loading, setLoading] = useState(false)
   const [loading, setLoading] = useState(false)
   const router = useRouter()
   const router = useRouter()
-  const modal = useGlassModal()
 
 
   const handleSubmit = async (e: React.FormEvent) => {
   const handleSubmit = async (e: React.FormEvent) => {
     e.preventDefault()
     e.preventDefault()
     setLoading(true)
     setLoading(true)
+    setError('')
 
 
     try {
     try {
       const result = await signUp.email({ name, email, password })
       const result = await signUp.email({ name, email, password })
@@ -31,21 +31,18 @@ export function SignUpForm({ inviteToken }: { inviteToken?: string }) {
         const isDisabled =
         const isDisabled =
           message.toLowerCase().includes('disabled') ||
           message.toLowerCase().includes('disabled') ||
           message.toLowerCase().includes('failed to create')
           message.toLowerCase().includes('failed to create')
-        modal.open(
-          'error',
-          'Sign Up Failed',
+        setError(
           isDisabled
           isDisabled
             ? 'Registration is currently disabled. Please contact your administrator.'
             ? 'Registration is currently disabled. Please contact your administrator.'
             : message,
             : message,
         )
         )
       } else if (inviteToken) {
       } else if (inviteToken) {
-        // Accept the invitation and redirect to dashboard
         const acceptResult = await acceptInvitation({ token: inviteToken })
         const acceptResult = await acceptInvitation({ token: inviteToken })
         if (acceptResult.success) {
         if (acceptResult.success) {
           router.push('/')
           router.push('/')
           router.refresh()
           router.refresh()
         } else {
         } else {
-          modal.open('error', 'Invitation Error', acceptResult.error || 'Failed to accept invitation')
+          setError(acceptResult.error || 'Failed to accept invitation')
           router.push('/onboarding')
           router.push('/onboarding')
           router.refresh()
           router.refresh()
         }
         }
@@ -54,7 +51,7 @@ export function SignUpForm({ inviteToken }: { inviteToken?: string }) {
         router.refresh()
         router.refresh()
       }
       }
     } catch {
     } catch {
-      modal.open('error', 'Sign Up Failed', 'An unexpected error occurred')
+      setError('An unexpected error occurred. Please try again.')
     } finally {
     } finally {
       setLoading(false)
       setLoading(false)
     }
     }
@@ -83,6 +80,13 @@ export function SignUpForm({ inviteToken }: { inviteToken?: string }) {
           </p>
           </p>
         </div>
         </div>
 
 
+        {error && (
+          <div className="mb-4 flex items-center gap-2 rounded-lg border border-destructive/30 bg-destructive/10 px-3 py-2.5 text-sm text-destructive">
+            <XCircle className="h-4 w-4 shrink-0" />
+            <span>{error}</span>
+          </div>
+        )}
+
         <form onSubmit={handleSubmit} className="space-y-4">
         <form onSubmit={handleSubmit} className="space-y-4">
           <div className="space-y-2">
           <div className="space-y-2">
             <Label htmlFor="name">Full Name</Label>
             <Label htmlFor="name">Full Name</Label>

+ 13 - 5
src/app/(public)/auth/verify-2fa/page.tsx

@@ -7,21 +7,21 @@ import { Button } from '@/components/ui/button'
 import { Input } from '@/components/ui/input'
 import { Input } from '@/components/ui/input'
 import { Label } from '@/components/ui/label'
 import { Label } from '@/components/ui/label'
 import { Checkbox } from '@/components/ui/checkbox'
 import { Checkbox } from '@/components/ui/checkbox'
-import { useGlassModal } from '@/components/glass-modal'
-import { Gauge, Loader2, Shield } from 'lucide-react'
+import { Gauge, Loader2, Shield, XCircle } from 'lucide-react'
 
 
 export default function VerifyTwoFactorPage() {
 export default function VerifyTwoFactorPage() {
   const [code, setCode] = useState('')
   const [code, setCode] = useState('')
   const [useBackupCode, setUseBackupCode] = useState(false)
   const [useBackupCode, setUseBackupCode] = useState(false)
   const [trustDevice, setTrustDevice] = useState(false)
   const [trustDevice, setTrustDevice] = useState(false)
+  const [error, setError] = useState('')
   const [loading, setLoading] = useState(false)
   const [loading, setLoading] = useState(false)
   const router = useRouter()
   const router = useRouter()
-  const modal = useGlassModal()
 
 
   const handleSubmit = async (e: React.FormEvent) => {
   const handleSubmit = async (e: React.FormEvent) => {
     e.preventDefault()
     e.preventDefault()
     if (!code.trim()) return
     if (!code.trim()) return
     setLoading(true)
     setLoading(true)
+    setError('')
 
 
     try {
     try {
       const result = useBackupCode
       const result = useBackupCode
@@ -29,13 +29,13 @@ export default function VerifyTwoFactorPage() {
         : await authClient.twoFactor.verifyTotp({ code, trustDevice })
         : await authClient.twoFactor.verifyTotp({ code, trustDevice })
 
 
       if (result.error) {
       if (result.error) {
-        modal.open('error', 'Verification Failed', result.error.message || 'Invalid code')
+        setError(result.error.message || 'Invalid code')
       } else {
       } else {
         router.push('/')
         router.push('/')
         router.refresh()
         router.refresh()
       }
       }
     } catch {
     } catch {
-      modal.open('error', 'Verification Failed', 'An unexpected error occurred')
+      setError('An unexpected error occurred. Please try again.')
     } finally {
     } finally {
       setLoading(false)
       setLoading(false)
     }
     }
@@ -67,6 +67,13 @@ export default function VerifyTwoFactorPage() {
           </p>
           </p>
         </div>
         </div>
 
 
+        {error && (
+          <div className="mb-4 flex items-center gap-2 rounded-lg border border-destructive/30 bg-destructive/10 px-3 py-2.5 text-sm text-destructive">
+            <XCircle className="h-4 w-4 shrink-0" />
+            <span>{error}</span>
+          </div>
+        )}
+
         <form onSubmit={handleSubmit} className="space-y-4">
         <form onSubmit={handleSubmit} className="space-y-4">
           <div className="space-y-2">
           <div className="space-y-2">
             <Label htmlFor="code">{useBackupCode ? 'Backup Code' : 'Authentication Code'}</Label>
             <Label htmlFor="code">{useBackupCode ? 'Backup Code' : 'Authentication Code'}</Label>
@@ -107,6 +114,7 @@ export default function VerifyTwoFactorPage() {
             onClick={() => {
             onClick={() => {
               setUseBackupCode(!useBackupCode)
               setUseBackupCode(!useBackupCode)
               setCode('')
               setCode('')
+              setError('')
             }}
             }}
             className="text-sm font-medium text-primary hover:underline"
             className="text-sm font-medium text-primary hover:underline"
           >
           >

+ 9 - 3
src/app/(public)/terms/page.tsx

@@ -1,6 +1,6 @@
 import type { Metadata } from "next";
 import type { Metadata } from "next";
+import Image from "next/image";
 import Link from "next/link";
 import Link from "next/link";
-import { Gauge } from "lucide-react";
 
 
 export const metadata: Metadata = {
 export const metadata: Metadata = {
   title: "Terms of Service | Torqvoice",
   title: "Terms of Service | Torqvoice",
@@ -13,8 +13,14 @@ export default function TermsOfServicePage() {
       <div className="rounded-xl border bg-background p-6 shadow-sm sm:p-8">
       <div className="rounded-xl border bg-background p-6 shadow-sm sm:p-8">
         {/* Header */}
         {/* Header */}
         <div className="border-b pb-6">
         <div className="border-b pb-6">
-          <div className="flex items-center gap-2">
-            <Gauge className="h-6 w-6 text-primary" />
+          <div className="flex items-center gap-3">
+            <Image
+              src="/torqvoice_app_logo.png"
+              alt="Torqvoice"
+              width={32}
+              height={32}
+              className="object-contain"
+            />
             <span className="text-lg font-bold tracking-wider uppercase">
             <span className="text-lg font-bold tracking-wider uppercase">
               Torqvoice
               Torqvoice
             </span>
             </span>