Skip to content
Closed
Show file tree
Hide file tree
Changes from 2 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
2 changes: 1 addition & 1 deletion Backend/app/db/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@

async def get_db():
async with AsyncSessionLocal() as session:
yield session
yield session
39 changes: 24 additions & 15 deletions Frontend/src/components/ui/slider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,29 @@ import { cn } from "../../lib/utils";
const Slider = React.forwardRef<
React.ElementRef<typeof SliderPrimitive.Root>,
React.ComponentPropsWithoutRef<typeof SliderPrimitive.Root>
>(({ className, ...props }, ref) => (
<SliderPrimitive.Root
ref={ref}
className={cn(
"relative flex w-full touch-none select-none items-center",
className
)}
{...props}
>
<SliderPrimitive.Track className="relative h-2 w-full grow overflow-hidden rounded-full bg-secondary">
<SliderPrimitive.Range className="absolute h-full bg-primary" />
</SliderPrimitive.Track>
<SliderPrimitive.Thumb className="block h-5 w-5 rounded-full border-2 border-primary bg-background ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50" />
</SliderPrimitive.Root>
));
>(({ className, ...props }, ref) => {
const thumbCount =
Array.isArray(props.value ?? props.defaultValue)
? (props.value ?? props.defaultValue ?? []).length || 1
: 1

return (
<SliderPrimitive.Root
ref={ref}
className={cn("relative flex w-full touch-none select-none items-center", className)}
{...props}
>
<SliderPrimitive.Track className="relative h-2 w-full grow overflow-hidden rounded-full bg-secondary">
<SliderPrimitive.Range className="absolute h-full bg-primary" />
</SliderPrimitive.Track>
{Array.from({ length: thumbCount }).map((_, index) => (
<SliderPrimitive.Thumb
key={index}
className="block h-5 w-5 rounded-full border-2 border-primary bg-background shadow focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 ring-offset-background transition disabled:pointer-events-none disabled:opacity-50"
/>
))}
</SliderPrimitive.Root>
)
})

export { Slider };
43 changes: 28 additions & 15 deletions Frontend/src/pages/Signup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export default function SignupPage() {
const [showPassword, setShowPassword] = useState(false);
const [isLoading, setIsLoading] = useState(false);
const [error, setError] = useState("");
const [successMessage, setSuccessMessage] = useState("");
const [step, setStep] = useState(1);
const [user, setuser] = useState("influencer");
const { login } = useAuth();
Expand All @@ -39,37 +40,42 @@ export default function SignupPage() {
}
setIsLoading(true);
setError("");
setSuccessMessage("");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Minor indentation inconsistency.

There's an extra leading space before setSuccessMessage("").

-     setSuccessMessage("");
+    setSuccessMessage("");
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
setSuccessMessage("");
setSuccessMessage("");
🤖 Prompt for AI Agents
In Frontend/src/pages/Signup.tsx around line 43, there's an indentation
inconsistency: the line "setSuccessMessage(\"\");" has an extra leading space.
Remove the extra leading space so the call aligns with the surrounding code's
indentation (match the same indent level as adjacent statements) to keep
formatting consistent.

try {
const { name, email, password } = formData;

// Check if user already exists
const { data: existingUser } = await supabase.auth.signInWithPassword({
email,
password: "dummy-password-to-check-existence",
});

if (existingUser.user) {
setError("An account with this email already exists. Please sign in instead.");
setIsLoading(false);
return;
}


const { data, error } = await supabase.auth.signUp({
email,
password,
options: { data: { name } },
});
if (error) {
if (error.message.includes("already registered")) {
if (
error.message.toLowerCase().includes("already registered") ||
error.message.toLowerCase().includes("user already exists")
) {
setError("An account with this email already exists. Please sign in instead.");
} else {
setError(error.message);
}
setIsLoading(false);
return;
}

// Supabase quirk: if the user already exists (especially with email confirmations enabled),
// signUp can succeed but return a user with no identities.
const identities = (data.user as any)?.identities ?? [];
const isExistingUserWithoutNewIdentity = Array.isArray(identities) && identities.length === 0;

if (isExistingUserWithoutNewIdentity) {
setError("An account with this email already exists. Please sign in instead.");
} else {
// Truly new account – show verification email message
setSuccessMessage(
"Verification link sent. Please check your email to verify your account before signing in."
);
}
setIsLoading(false);
// AuthContext will handle navigation based on user onboarding status and role
} catch (err) {
setError("Something went wrong. Please try again.");
} finally {
Expand Down Expand Up @@ -161,6 +167,13 @@ export default function SignupPage() {
</div>
)}

{successMessage && (
<div className="mb-6 p-4 bg-green-50 dark:bg-green-900/20 border border-green-200 dark:border-green-800 rounded-lg text-green-700 dark:text-green-400 text-sm flex items-start space-x-2">
<Check className="h-4 w-4 mt-0.5 flex-shrink-0" />
<span>{successMessage}</span>
</div>
)}

<form onSubmit={handleSubmit} className="space-y-6">
<div className="space-y-2">
<label htmlFor="email" className="text-sm font-medium text-gray-700 dark:text-gray-300">Email</label>
Expand Down