geethareddy's picture
Create signup.html
9fb13a8 verified
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Sign Up - AI Coach</title>
<style>
body {
font-family: 'Roboto', Arial, sans-serif;
margin: 0;
padding: 0;
background: linear-gradient(135deg, #f0f2f5 0%, #e9ecef 100%);
color: #2d3748;
line-height: 1.6;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
}
.signup-container {
background-color: #fff;
padding: 40px;
border-radius: 12px;
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
width: 100%;
max-width: 400px;
text-align: center;
}
h2 {
color: #1a3c7a;
font-size: 28px;
font-weight: 700;
margin-bottom: 20px;
}
.input-group {
margin-bottom: 20px;
text-align: left;
}
label {
display: block;
font-size: 15px;
font-weight: 500;
color: #4a5568;
margin-bottom: 8px;
}
input, select {
width: 100%;
padding: 12px;
border: 2px solid #e2e8f0;
border-radius: 8px;
font-size: 15px;
box-sizing: border-box;
transition: border-color 0.3s ease, box-shadow 0.3s ease;
}
input:focus, select:focus {
border-color: #ed8936;
outline: none;
box-shadow: 0 0 8px rgba(237, 137, 54, 0.3);
}
.checkbox-group {
display: flex;
align-items: center;
gap: 10px;
}
.checkbox-group input {
width: auto;
margin: 0;
}
button {
width: 100%;
padding: 12px;
background: linear-gradient(to right, #f6ad55, #ed8936);
color: #fff;
border: none;
border-radius: 8px;
cursor: pointer;
font-size: 16px;
font-weight: 600;
transition: transform 0.1s ease, background 0.3s ease;
}
button:hover {
background: linear-gradient(to right, #ed8936, #dd6b20);
transform: scale(1.02);
}
.login-link {
margin-top: 20px;
font-size: 14px;
color: #4a5568;
}
.login-link a {
color: #ed8936;
text-decoration: none;
font-weight: 500;
}
.login-link a:hover {
text-decoration: underline;
}
.error-message {
color: #f56565;
font-size: 14px;
margin-top: 10px;
display: none;
}
.error-message.visible {
display: block;
}
@media (max-width: 500px) {
.signup-container {
padding: 20px;
margin: 20px;
}
h2 {
font-size: 24px;
}
input, select, button {
font-size: 14px;
padding: 10px;
}
}
</style>
<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@400;500;700&display=swap" rel="stylesheet">
</head>
<body>
<div class="signup-container">
<h2>AI Coach Sign Up</h2>
<div class="input-group">
<label for="username">Username</label>
<input type="text" id="username" placeholder="Enter your username">
</div>
<div class="input-group">
<label for="password">Password</label>
<input type="password" id="password" placeholder="Enter your password">
</div>
<div class="input-group">
<label for="project_id">Project ID</label>
<input type="text" id="project_id" placeholder="Enter your project ID (e.g., PROJ_001)">
</div>
<div class="input-group">
<label for="engagement_score">Engagement Score (%)</label>
<input type="number" id="engagement_score" min="0" max="100" placeholder="Enter engagement score (0-100)">
</div>
<div class="input-group checkbox-group">
<label for="kpi_flag">KPI Flag</label>
<input type="checkbox" id="kpi_flag">
</div>
<button onclick="signup()">Sign Up</button>
<p id="error-message" class="error-message"></p>
<p class="login-link">Already have an account? <a href="/login">Login here</a></p>
</div>
<script>
async function signup() {
const username = document.getElementById('username').value.trim();
const password = document.getElementById('password').value.trim();
const project_id = document.getElementById('project_id').value.trim();
const engagement_score = parseFloat(document.getElementById('engagement_score').value) || 85;
const kpi_flag = document.getElementById('kpi_flag').checked;
const errorMessage = document.getElementById('error-message');
if (!username || !password) {
errorMessage.textContent = 'Please enter both username and password.';
errorMessage.classList.add('visible');
return;
}
if (engagement_score < 0 || engagement_score > 100) {
errorMessage.textContent = 'Engagement score must be between 0 and 100.';
errorMessage.classList.add('visible');
return;
}
try {
const response = await fetch('/signup', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ username, password, project_id, engagement_score, kpi_flag })
});
const result = await response.json();
if (result.status === 'success') {
window.location.href = '/';
} else {
errorMessage.textContent = result.message || 'Signup failed. Please try again.';
errorMessage.classList.add('visible');
}
} catch (error) {
errorMessage.textContent = 'Error during signup: ' + error.message;
errorMessage.classList.add('visible');
}
}
</script>
</body>
</html>