InterviewAI / src /app /settings /page.tsx
viraj-421's picture
Initial commit: AI-Powered Mock Interview Platform with Auth, Certificates, and Timer
a0da743
Raw History Blame Contribute Delete
8.5 kB
'use client';
import { useState, useEffect } from 'react';
import { motion } from 'framer-motion';
import {
Key,
Save,
CheckCircle2,
AlertCircle,
Eye,
EyeOff,
Sparkles,
ExternalLink,
Shield,
} from 'lucide-react';
export default function SettingsPage() {
const [apiKey, setApiKey] = useState('');
const [showKey, setShowKey] = useState(false);
const [saved, setSaved] = useState(false);
const [error, setError] = useState('');
useEffect(() => {
// Load from localStorage
const stored = localStorage.getItem('gemini-api-key');
if (stored) setApiKey(stored);
}, []);
const handleSave = async () => {
if (!apiKey.trim()) {
setError('Please enter an API key');
return;
}
// Save to localStorage for client reference
localStorage.setItem('gemini-api-key', apiKey.trim());
// Note: For server-side usage, the key should be in .env.local
setSaved(true);
setError('');
setTimeout(() => setSaved(false), 3000);
};
return (
<div className="min-h-screen py-12 px-6">
<div className="max-w-2xl mx-auto">
<motion.div
initial={{ opacity: 0, y: 20 }}
animate={{ opacity: 1, y: 0 }}
className="text-center mb-10"
>
<div className="w-16 h-16 rounded-2xl flex items-center justify-center mx-auto mb-4" style={{ background: 'var(--gradient-primary)' }}>
<Key className="w-8 h-8 text-white" />
</div>
<h1 className="text-3xl font-bold mb-2">
<span className="text-gradient">Settings</span>
</h1>
<p style={{ color: 'var(--muted-light)' }}>
Configure your API key to enable AI-powered interviews
</p>
</motion.div>
<motion.div
initial={{ opacity: 0, y: 20 }}
animate={{ opacity: 1, y: 0 }}
transition={{ delay: 0.1 }}
className="card"
>
<div className="flex items-center gap-2 mb-6">
<Sparkles className="w-5 h-5" style={{ color: 'var(--primary)' }} />
<h2 className="text-lg font-semibold">Google Gemini API Key</h2>
</div>
{/* Instructions */}
<div className="rounded-xl p-4 mb-6" style={{ background: 'rgba(108, 92, 231, 0.05)', border: '1px solid rgba(108, 92, 231, 0.1)' }}>
<h3 className="text-sm font-medium mb-2" style={{ color: 'var(--primary-light)' }}>
Setup Instructions:
</h3>
<ol className="space-y-2 text-sm" style={{ color: 'var(--muted-light)' }}>
<li className="flex items-start gap-2">
<span className="font-bold" style={{ color: 'var(--primary)' }}>1.</span>
<span>
Visit{' '}
<a
href="https://aistudio.google.com/apikey"
target="_blank"
rel="noopener noreferrer"
className="inline-flex items-center gap-1 font-medium"
style={{ color: 'var(--primary-light)' }}
>
Google AI Studio <ExternalLink className="w-3 h-3" />
</a>
{' '}to get your API key
</span>
</li>
<li className="flex items-start gap-2">
<span className="font-bold" style={{ color: 'var(--primary)' }}>2.</span>
<span>
Create a <code className="px-1.5 py-0.5 rounded text-xs" style={{ background: 'var(--card)', color: 'var(--secondary)' }}>.env.local</code> file in your project root
</span>
</li>
<li className="flex items-start gap-2">
<span className="font-bold" style={{ color: 'var(--primary)' }}>3.</span>
<span>
Add: <code className="px-1.5 py-0.5 rounded text-xs" style={{ background: 'var(--card)', color: 'var(--secondary)' }}>GEMINI_API_KEY=your_api_key_here</code>
</span>
</li>
<li className="flex items-start gap-2">
<span className="font-bold" style={{ color: 'var(--primary)' }}>4.</span>
<span>Restart the development server</span>
</li>
</ol>
</div>
{/* API Key Input (for reference/testing) */}
<div className="mb-6">
<label className="text-sm font-medium mb-2 block" style={{ color: 'var(--muted-light)' }}>
API Key (stored locally in browser)
</label>
<div className="relative">
<input
type={showKey ? 'text' : 'password'}
value={apiKey}
onChange={(e) => setApiKey(e.target.value)}
placeholder="Enter your Gemini API key..."
className="w-full px-4 py-3 pr-20 rounded-xl text-sm focus:outline-none transition-all duration-300"
style={{
background: 'var(--background)',
border: '1px solid var(--border)',
color: 'var(--foreground)',
}}
onFocus={(e) => {
e.currentTarget.style.borderColor = 'var(--primary)';
}}
onBlur={(e) => {
e.currentTarget.style.borderColor = 'var(--border)';
}}
/>
<button
onClick={() => setShowKey(!showKey)}
className="absolute right-3 top-1/2 -translate-y-1/2 p-1 cursor-pointer"
style={{ color: 'var(--muted)' }}
>
{showKey ? <EyeOff className="w-4 h-4" /> : <Eye className="w-4 h-4" />}
</button>
</div>
</div>
{/* Security note */}
<div className="flex items-start gap-2 mb-6 text-xs" style={{ color: 'var(--muted)' }}>
<Shield className="w-4 h-4 shrink-0 mt-0.5" style={{ color: 'var(--success)' }} />
<p>
For production use, always store API keys in environment variables (<code>.env.local</code>).
The browser-stored key is for reference only and is not used by the server-side API routes.
</p>
</div>
{/* Save Button */}
<button
onClick={handleSave}
className="w-full py-3 rounded-xl font-medium flex items-center justify-center gap-2 transition-all duration-300 cursor-pointer"
style={{
background: saved ? 'var(--success)' : 'var(--gradient-primary)',
color: 'white',
}}
>
{saved ? (
<>
<CheckCircle2 className="w-4 h-4" />
Saved to Browser
</>
) : (
<>
<Save className="w-4 h-4" />
Save API Key
</>
)}
</button>
{error && (
<div className="flex items-center gap-2 mt-3 text-sm" style={{ color: 'var(--danger)' }}>
<AlertCircle className="w-4 h-4" />
{error}
</div>
)}
</motion.div>
{/* Additional Info */}
<motion.div
initial={{ opacity: 0, y: 20 }}
animate={{ opacity: 1, y: 0 }}
transition={{ delay: 0.2 }}
className="card mt-6"
>
<h2 className="text-lg font-semibold mb-4">About the Platform</h2>
<div className="space-y-3 text-sm" style={{ color: 'var(--muted-light)' }}>
<p>
<strong style={{ color: 'var(--foreground)' }}>AI Model:</strong>{' '}
Google Gemini 2.0 Flash — fast, capable, and cost-effective
</p>
<p>
<strong style={{ color: 'var(--foreground)' }}>Features:</strong>{' '}
Dynamic question generation, real-time evaluation, voice input, comprehensive analytics
</p>
<p>
<strong style={{ color: 'var(--foreground)' }}>Privacy:</strong>{' '}
All data is processed in real-time. No interview data is stored on any server.
</p>
<p>
<strong style={{ color: 'var(--foreground)' }}>Tech Stack:</strong>{' '}
Next.js 16, React 19, Tailwind CSS v4, Framer Motion, Lucide Icons
</p>
</div>
</motion.div>
</div>
</div>
);
}