Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 8 additions & 21 deletions app/account/account-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,27 +80,14 @@ export default function AccountForm({ user, message }: { user: User | null; mess
</div>
</div>

<div className="grid grid-cols-3 gap-4 pt-6">
<div className="col-span-2">
<SubmitButton
className="w-full"
pendingText="Updating..."
disabled={!name.trim() || name.trim().length < 2}
>
Update Profile
</SubmitButton>
</div>
<div className="col-span-1">
<form action={signOut} className="w-full">
<Button
className="w-full"
type="submit"
variant="neutral"
>
Sign Out
</Button>
</form>
</div>
<div className="flex items-start gap-4 pt-6">
<SubmitButton
className="flex-1"
pendingText="Updating..."
disabled={!name.trim() || name.trim().length < 2}
>
Update Profile
</SubmitButton>
</div>
</form>
</div>
Expand Down
2 changes: 1 addition & 1 deletion app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export default function RootLayout({
return (
<html lang="en" className="bg-[#E4DFF2]">
<meta property="og:image" content="https://res.cloudinary.com/dfyrk32ua/image/upload/v1722186653/deetnuts/preview_o5ykn7.png" />
<meta property="og:image:webp" content="https://res.cloudinary.com/dfyrk32ua/image/upload/v1722186653/deetnuts/preview_o5ykn7.png" />
<meta property="og:image:png" content="https://res.cloudinary.com/dfyrk32ua/image/upload/v1722186653/deetnuts/preview_o5ykn7.png" />
<link rel="icon" href="/favicon.ico" />
<body className={`${inter.className} relative min-h-screen overflow-x-hidden`}>
<Navbar />
Expand Down
50 changes: 33 additions & 17 deletions app/login/actions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,19 @@ export async function login(formData: FormData) {
// Validate input
if (!email || !password) {
const params = new URLSearchParams({ message: 'Please fill in all fields' })
if (redirectTo !== '/account') params.set('redirect', redirectTo)
if (redirectTo && redirectTo !== '/account') params.set('redirect', redirectTo)
return redirect(`/login?${params.toString()}`)
}

if (!email.includes('@')) {
const params = new URLSearchParams({ message: 'Please enter a valid email address' })
if (redirectTo !== '/account') params.set('redirect', redirectTo)
if (redirectTo && redirectTo !== '/account') params.set('redirect', redirectTo)
return redirect(`/login?${params.toString()}`)
}

if (password.length < 8) {
const params = new URLSearchParams({ message: 'Password must be at least 8 characters long' })
if (redirectTo !== '/account') params.set('redirect', redirectTo)
if (redirectTo && redirectTo !== '/account') params.set('redirect', redirectTo)
return redirect(`/login?${params.toString()}`)
}

Expand Down Expand Up @@ -59,7 +59,7 @@ export async function login(formData: FormData) {
} catch (error) {
console.error('Login error:', error)
const params = new URLSearchParams()
if (redirectTo !== '/account') params.set('redirect', redirectTo)
if (redirectTo && redirectTo !== '/account') params.set('redirect', redirectTo)

if (error instanceof ClientResponseError) {
if (error.status === 400) {
Expand All @@ -85,31 +85,31 @@ export async function signup(formData: FormData) {
// Validate input
if (!email || !password || !passwordConfirm || !name) {
const params = new URLSearchParams({ message: 'Please fill in all fields' })
if (redirectTo !== '/account') params.set('redirect', redirectTo)
if (redirectTo && redirectTo !== '/account') params.set('redirect', redirectTo)
return redirect(`/signup?${params.toString()}`)
}

if (!email.includes('@')) {
const params = new URLSearchParams({ message: 'Please enter a valid email address' })
if (redirectTo !== '/account') params.set('redirect', redirectTo)
if (redirectTo && redirectTo !== '/account') params.set('redirect', redirectTo)
return redirect(`/signup?${params.toString()}`)
}

if (password.length < 8) {
const params = new URLSearchParams({ message: 'Password must be at least 8 characters long' })
if (redirectTo !== '/account') params.set('redirect', redirectTo)
if (redirectTo && redirectTo !== '/account') params.set('redirect', redirectTo)
return redirect(`/signup?${params.toString()}`)
}

if (password !== passwordConfirm) {
const params = new URLSearchParams({ message: 'Passwords do not match' })
if (redirectTo !== '/account') params.set('redirect', redirectTo)
if (redirectTo && redirectTo !== '/account') params.set('redirect', redirectTo)
return redirect(`/signup?${params.toString()}`)
}

if (name.trim().length < 2) {
const params = new URLSearchParams({ message: 'Name must be at least 2 characters long' })
if (redirectTo !== '/account') params.set('redirect', redirectTo)
if (redirectTo && redirectTo !== '/account') params.set('redirect', redirectTo)
return redirect(`/signup?${params.toString()}`)
}

Expand All @@ -122,14 +122,13 @@ export async function signup(formData: FormData) {
passwordConfirm: passwordConfirm,
name: name.trim(),
}

try {
const record = await pb.collection('users').create(data)
await pb.collection('users').requestVerification(email)
} catch (error) {
console.error('Signup error:', error)
const params = new URLSearchParams()
if (redirectTo !== '/account') params.set('redirect', redirectTo)
if (redirectTo && redirectTo !== '/account') params.set('redirect', redirectTo)

if (error instanceof ClientResponseError) {
const errorData = error.response?.data
Expand All @@ -149,9 +148,11 @@ export async function signup(formData: FormData) {
params.set('message', 'Failed to create account. Please try again.')
return redirect(`/signup?${params.toString()}`)
}

// Automatically log the user in after successful signup
try {
// Small delay to ensure user record is fully created
await new Promise(resolve => setTimeout(resolve, 100))

const authData = await pb.collection('users').authWithPassword(email, password)

const cookieStore = await cookies()
Expand All @@ -171,13 +172,28 @@ export async function signup(formData: FormData) {
})

revalidatePath('/', 'layout')
redirect(redirectTo)

// Try to add success message to destination URL if possible
try {
const url = new URL(redirectTo, 'https://example.com') // Use dummy base for relative URLs
url.searchParams.set('message', 'Account created successfully! Welcome to the platform.')
redirect(url.pathname + url.search)
} catch {
// If URL manipulation fails, just redirect to the destination
redirect(redirectTo)
}
} catch (error) {
// If auto-login fails, redirect to login page with success message
// If auto-login fails, still redirect to original destination but with a success message
revalidatePath('/', 'layout')
const params = new URLSearchParams({ message: 'Account created successfully! Please log in to access the platform.' })
if (redirectTo !== '/account') params.set('redirect', redirectTo)
redirect(`/login?${params.toString()}`)
// Try to add success message to destination URL if possible
try {
const url = new URL(redirectTo, 'https://example.com') // Use dummy base for relative URLs
url.searchParams.set('message', 'Account created successfully! You have been logged in.')
redirect(url.pathname + url.search)
} catch {
// If URL manipulation fails, just redirect to the destination
redirect(redirectTo)
}
}
}

Expand Down
9 changes: 6 additions & 3 deletions app/mht-cet-login-required/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@ import Link from "next/link";
import Image from "next/image";
import { Button } from "@/components/ui/button";

export default function MHTCETLoginRequired({ searchParams }: {
export default async function MHTCETLoginRequired({ searchParams }: {
searchParams: Promise<{ redirect?: string }>
}) {
const params = await searchParams
const redirectTo = params?.redirect || '/mht-cet'

return (
<div className="min-h-screen flex flex-col items-center justify-center px-4 pt-32">
<div className="max-w-md w-full text-center space-y-8">
Expand Down Expand Up @@ -34,7 +37,7 @@ export default function MHTCETLoginRequired({ searchParams }: {

<div className="space-y-3">
<Link
href={`/login?redirect=${encodeURIComponent('/mht-cet')}`}
href={`/login?redirect=${encodeURIComponent(redirectTo)}`}
className="block w-full"
>
<Button className="w-full bg-blue-600 hover:bg-blue-700">
Expand All @@ -43,7 +46,7 @@ export default function MHTCETLoginRequired({ searchParams }: {
</Link>

<Link
href="/signup"
href={`/signup?redirect=${encodeURIComponent(redirectTo)}`}
className="block w-full"
>
<Button variant="neutral" className="w-full">
Expand Down
64 changes: 64 additions & 0 deletions app/mht-cet/state-cutoffs/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import { Metadata } from "next";

export const metadata: Metadata = {
title: "MHT-CET State Cutoffs 2024 | College Predictor & Category Codes",
description:
"See official MHT-CET 2024 state cutoffs for all Maharashtra engineering colleges. Filter by percentile, category, course, seat type, and university region. Plan your CAP round choices with the most accurate, up-to-date data.",
keywords: [
"MHT-CET",
"MHT CET",
"state cutoffs",
"2024",
"engineering colleges",
"college predictor",
"percentile",
"category codes",
"seat allocation",
"CAP round",
"DTE Maharashtra",
"admission",
"cutoff list",
"university region",
"maharashtra engineering admission",
"mhtcet cutoffs",
"mht cet college predictor",
"mht cet category codes",
"mht cet seat types",
"mht cet 2024",
"mht cet cap round",
"mht cet home university",
"mht cet other university",
"mht cet open category",
"mht cet obc sc st",
"mht cet cutoff marks",
"mht cet cutoff percentile"
],
openGraph: {
title: "MHT-CET State Cutoffs 2024 | 2025 | College Predictor & Category Codes",
description:
"See official MHT-CET 2024 state cutoffs for all Maharashtra engineering colleges. Filter by percentile, category, course, seat type, and university region. Plan your CAP round choices with the most accurate, up-to-date data.",
url: "https://deetnuts.com/mht-cet/state-cutoffs",
siteName: "deetnuts.com",
type: "website",
images: [
{
url: "https://res.cloudinary.com/dfyrk32ua/image/upload/v1722186653/deetnuts/preview_o5ykn7.png",
width: 512,
height: 512,
alt: "MHT-CET State Cutoffs 2024 Logo"
}
]
},
twitter: {
card: "summary_large_image",
title: "MHT-CET State Cutoffs 2024 | 2025 | College Predictor & Category Codes",
description:
"See official MHT-CET 2024 | 2025 state cutoffs for all Maharashtra engineering colleges. Filter by percentile, category, course, seat type, and university region. Plan your CAP round choices with the most accurate, up-to-date data.",
images: ["https://res.cloudinary.com/dfyrk32ua/image/upload/v1722186653/deetnuts/preview_o5ykn7.png"]
},
metadataBase: new URL("https://deetnuts.com/"),
};

export default function StateCutoffsLayout({ children }: { children: React.ReactNode }) {
return <>{children}</>;
}
Loading
Loading