Spaces:
Running

undefined / login.html
thakurihem's picture
Create a full-stack web application called **IntelliFarm Pro — Smart Farm Management System**, designed to help farms manage multiple agricultural enterprises such as crops, poultry, horticulture, beekeeping, and small-scale agro-food production. The system should include **role-based dashboards** for Admin, Farm Manager, Technician, and Worker, each with specific access permissions and CRUD capabilities. The platform must support secure **JWT authentication**, encrypted passwords, and user management with role-based access control. Core features should include **farm and enterprise management** with GPS mapping, **field operations tracking** for sowing, irrigation, and harvesting, **disease and pest management** with photos, notes, and weather-based risk prediction, **irrigation and soil management**, **inventory tracking** for inputs like fertilizers and seeds, and **financial modules** for expenses, income, and profit analysis. It should also include **reports and analytics dashboards** with visual charts for yield, expenses, and productivity, exportable as PDF or Excel. The system must allow **task and workforce management** with mobile-friendly worker portals, **notifications and communication tools** (in-app chat, SMS, email alerts), and **real-time monitoring** for production and economic insights. The frontend should be built with **React.js and Tailwind CSS** using Chart.js or Recharts for analytics, while the backend should use **Node.js with Express** and **PostgreSQL** as the database. Deploy the application using **Docker and AWS (or GCP)**, integrating APIs like OpenWeather for weather data and Twilio or EmailJS for notifications. Ensure robust **security** (CSRF protection, input validation, encrypted data) and a responsive, modular design with dashboards, analytics, and sample seed data for testing. Optionally, include future-ready features like **AI-based crop recommendations**, **IoT sensor integration**, and **NDVI satellite monitoring** for precision agriculture.
7eeea54 verified
Raw History Blame Contribute Delete
6.34 kB
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>IntelliFarm Pro | Login</title>
<link rel="icon" type="image/x-icon" href="/static/favicon.ico">
<script src="https://cdn.tailwindcss.com"></script>
<script src="https://unpkg.com/feather-icons"></script>
<style>
.auth-bg {
background: linear-gradient(135deg, rgba(34,197,94,0.1) 0%, rgba(16,163,74,0.2) 100%);
}
</style>
</head>
<body class="auth-bg min-h-screen flex items-center justify-center">
<div class="max-w-md w-full bg-white rounded-lg shadow-xl overflow-hidden">
<div class="p-8">
<div class="text-center mb-8">
<div class="flex justify-center">
<i data-feather="sun" class="text-primary-600 h-10 w-10"></i>
</div>
<h1 class="mt-4 text-2xl font-bold text-gray-900">Welcome to IntelliFarm Pro</h1>
<p class="mt-2 text-gray-600">Sign in to your account</p>
</div>
<form id="loginForm" class="space-y-6">
<div>
<label for="email" class="block text-sm font-medium text-gray-700">Email address</label>
<div class="mt-1 relative rounded-md shadow-sm">
<div class="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none">
<i data-feather="mail" class="h-4 w-4 text-gray-400"></i>
</div>
<input id="email" name="email" type="email" autocomplete="email" required
class="py-2 pl-10 block w-full border border-gray-300 rounded-md focus:ring-primary-500 focus:border-primary-500"
placeholder="you@example.com">
</div>
</div>
<div>
<label for="password" class="block text-sm font-medium text-gray-700">Password</label>
<div class="mt-1 relative rounded-md shadow-sm">
<div class="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none">
<i data-feather="lock" class="h-4 w-4 text-gray-400"></i>
</div>
<input id="password" name="password" type="password" autocomplete="current-password" required
class="py-2 pl-10 block w-full border border-gray-300 rounded-md focus:ring-primary-500 focus:border-primary-500"
placeholder="••••••••">
</div>
</div>
<div class="flex items-center justify-between">
<div class="flex items-center">
<input id="remember-me" name="remember-me" type="checkbox"
class="h-4 w-4 text-primary-600 focus:ring-primary-500 border-gray-300 rounded">
<label for="remember-me" class="ml-2 block text-sm text-gray-700">Remember me</label>
</div>
<div class="text-sm">
<a href="/forgot-password" class="font-medium text-primary-600 hover:text-primary-500">
Forgot password?
</a>
</div>
</div>
<div>
<button type="submit"
class="w-full flex justify-center py-2 px-4 border border-transparent rounded-md shadow-sm text-sm font-medium text-white bg-primary-600 hover:bg-primary-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-primary-500">
Sign in
</button>
</div>
</form>
<div class="mt-6">
<p class="text-center text-sm text-gray-600">
Don't have an account?
<a href="/register" class="font-medium text-primary-600 hover:text-primary-500">
Register here
</a>
</p>
</div>
</div>
</div>
<script>
feather.replace();
document.getElementById('loginForm').addEventListener('submit', async (e) => {
e.preventDefault();
const formData = {
email: document.getElementById('email').value,
password: document.getElementById('password').value,
remember: document.getElementById('remember-me').checked
};
try {
const response = await fetch('/api/auth/login', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(formData)
});
const data = await response.json();
if (response.ok) {
// Store token and redirect based on user role
localStorage.setItem('token', data.token);
localStorage.setItem('userRole', data.user.role);
switch(data.user.role) {
case 'admin':
window.location.href = '/admin/dashboard';
break;
case 'manager':
window.location.href = '/manager/dashboard';
break;
case 'technician':
window.location.href = '/technician/dashboard';
break;
case 'worker':
window.location.href = '/worker/dashboard';
break;
default:
window.location.href = '/';
}
} else {
alert(data.message || 'Login failed');
}
} catch (error) {
console.error('Login error:', error);
alert('An error occurred during login');
}
});
</script>
</body>
</html>