remove demo code

This commit is contained in:
2026-01-03 11:38:51 +01:00
parent 2f21dc4595
commit 9a7efa496f
38 changed files with 1535 additions and 1157 deletions

View File

@@ -140,29 +140,6 @@ export default function SponsorSignupPage() {
const [errors, setErrors] = useState<Record<string, string>>({});
const [submitting, setSubmitting] = useState(false);
const handleDemoLogin = async () => {
setSubmitting(true);
try {
// Use the demo login API instead of setting cookies
const response = await fetch('/api/auth/demo-login', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ role: 'sponsor' }),
});
if (!response.ok) {
throw new Error('Demo login failed');
}
router.push('/sponsor/dashboard');
} catch (error) {
console.error('Demo login failed:', error);
alert('Demo login failed. Please check the API server status.');
} finally {
setSubmitting(false);
}
};
const handleSubmit = async (e: React.FormEvent) => {
e.preventDefault();
@@ -206,22 +183,47 @@ export default function SponsorSignupPage() {
setSubmitting(true);
try {
// For demo purposes, use the demo login API with sponsor role
// In production, this would create a real sponsor account
const response = await fetch('/api/auth/demo-login', {
// Create a sponsor account using the normal signup flow
// The backend will handle creating the sponsor user with the appropriate role
const response = await fetch('/api/auth/signup', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ role: 'sponsor' }),
body: JSON.stringify({
email: formData.contactEmail,
password: formData.password,
displayName: formData.companyName,
// Additional sponsor-specific data
sponsorData: {
companyName: formData.companyName,
websiteUrl: formData.websiteUrl,
interests: formData.interests,
},
}),
});
if (!response.ok) {
throw new Error('Signup failed');
const errorData = await response.json().catch(() => ({}));
throw new Error(errorData.message || 'Signup failed');
}
// Auto-login after successful signup
const loginResponse = await fetch('/api/auth/login', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
email: formData.contactEmail,
password: formData.password,
}),
});
if (!loginResponse.ok) {
throw new Error('Auto-login failed');
}
router.push('/sponsor/dashboard');
} catch (err) {
console.error('Sponsor signup failed:', err);
alert('Registration failed. Try again.');
alert('Registration failed. ' + (err instanceof Error ? err.message : 'Try again.'));
} finally {
setSubmitting(false);
}
@@ -263,17 +265,6 @@ export default function SponsorSignupPage() {
<ArrowRight className="w-5 h-5 ml-2" />
</Button>
</div>
{/* Demo Login */}
<div className="mt-6">
<button
onClick={handleDemoLogin}
disabled={submitting}
className="text-sm text-gray-500 hover:text-gray-400 transition-colors disabled:opacity-50"
>
{submitting ? 'Loading...' : 'Try demo sponsor account →'}
</button>
</div>
</SponsorHero>
{/* Platform Stats */}
@@ -529,13 +520,6 @@ export default function SponsorSignupPage() {
Create one
</button>
</p>
<button
onClick={handleDemoLogin}
disabled={submitting}
className="w-full text-sm text-gray-500 hover:text-gray-400 text-center"
>
Or try the demo account
</button>
</div>
</Card>
</div>