161 lines
7.1 KiB
PHP
161 lines
7.1 KiB
PHP
<?php
|
|
require_once 'db/config.php';
|
|
|
|
$pdo = db_connect();
|
|
$error = null;
|
|
$success = null;
|
|
|
|
if ($_SERVER["REQUEST_METHOD"] == "POST" && !empty($_POST['project_name'])) {
|
|
try {
|
|
$name = trim($_POST['project_name']);
|
|
if (!empty($name)) {
|
|
$stmt = $pdo->prepare("INSERT INTO projects (name) VALUES (?)");
|
|
$stmt->execute([$name]);
|
|
$success = "Project '".htmlspecialchars($name)."' created successfully!";
|
|
} else {
|
|
$error = "Project name cannot be empty.";
|
|
}
|
|
} catch (PDOException $e) {
|
|
$error = "Database error: " . $e->getMessage();
|
|
}
|
|
}
|
|
|
|
$projects = [];
|
|
try {
|
|
$stmt = $pdo->query("SELECT id, name, created_at FROM projects ORDER BY created_at DESC");
|
|
$projects = $stmt->fetchAll();
|
|
} catch (PDOException $e) {
|
|
$error = "Database error: " . $e->getMessage();
|
|
}
|
|
?>
|
|
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Ertiga - AI App Builder</title>
|
|
<meta name="description" content="Ertiga is an AI-powered app builder that generates full-stack applications from text prompts.">
|
|
<meta name="keywords" content="ai app builder, code generation, full-stack development, ertiga, no-code, low-code, database schema, frontend builder, backend services">
|
|
<meta property="og:title" content="Ertiga - AI App Builder">
|
|
<meta property="og:description" content="Ertiga is an AI-powered app builder that generates full-stack applications from text prompts.">
|
|
<meta property="og:image" content="">
|
|
<meta name="twitter:card" content="summary_large_image">
|
|
<meta name="twitter:image" content="">
|
|
|
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
|
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css" rel="stylesheet">
|
|
<link rel="preconnect" href="https://fonts.googleapis.com">
|
|
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
|
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap" rel="stylesheet">
|
|
<style>
|
|
body {
|
|
font-family: 'Inter', sans-serif;
|
|
background-color: #f8f9fa;
|
|
}
|
|
.navbar {
|
|
box-shadow: 0 2px 4px rgba(0,0,0,.05);
|
|
}
|
|
.project-card {
|
|
transition: transform .2s ease-in-out, box-shadow .2s ease-in-out;
|
|
}
|
|
.project-card:hover {
|
|
transform: translateY(-5px);
|
|
box-shadow: 0 .5rem 1rem rgba(0,0,0,.15)!important;
|
|
}
|
|
.toast-container {
|
|
z-index: 1090;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
|
|
<nav class="navbar navbar-expand-lg navbar-light bg-white sticky-top">
|
|
<div class="container">
|
|
<a class="navbar-brand fw-bold" href="#">
|
|
<i class="bi bi-boxes"></i>
|
|
Ertiga
|
|
</a>
|
|
</div>
|
|
</nav>
|
|
|
|
<main class="container mt-5">
|
|
<div class="row justify-content-center">
|
|
<div class="col-lg-8">
|
|
<div class="card border-0 shadow-sm mb-4">
|
|
<div class="card-body p-4">
|
|
<h4 class="card-title fw-bold mb-3">Create New Project</h4>
|
|
<form action="index.php" method="POST">
|
|
<div class="input-group">
|
|
<input type="text" class="form-control form-control-lg" name="project_name" placeholder="Enter your new project name..." required>
|
|
<button class="btn btn-primary btn-lg" type="submit">
|
|
<i class="bi bi-plus-lg"></i> Create Project
|
|
</button>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="d-flex justify-content-between align-items-center mb-3">
|
|
<h3 class="fw-bold mb-0">My Projects</h3>
|
|
<span class="badge bg-light text-dark fs-6"><?php echo count($projects); ?> Projects</span>
|
|
</div>
|
|
|
|
<div class="row">
|
|
<?php if (empty($projects) && !$error): ?>
|
|
<div class="col-12">
|
|
<div class="card border-0 bg-light">
|
|
<div class="card-body text-center p-5">
|
|
<i class="bi bi-folder2-open fs-1 text-muted"></i>
|
|
<h5 class="mt-3">No projects yet</h5>
|
|
<p class="text-muted">Get started by creating your first project above.</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<?php else: ?>
|
|
<?php foreach ($projects as $project): ?>
|
|
<div class="col-md-6 mb-4">
|
|
<div class="card h-100 border-0 shadow-sm project-card">
|
|
<div class="card-body d-flex flex-column">
|
|
<h5 class="card-title fw-bold"><?php echo htmlspecialchars($project['name']); ?></h5>
|
|
<p class="card-text text-muted small mb-auto">
|
|
Created on: <?php echo date("M d, Y", strtotime($project['created_at'])); ?>
|
|
</p>
|
|
<a href="#" class="btn btn-sm btn-outline-primary mt-3 stretched-link">Open Project</a>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<?php endforeach; ?>
|
|
<?php endif; ?>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</main>
|
|
|
|
<div class="toast-container position-fixed bottom-0 end-0 p-3">
|
|
<?php if ($success): ?>
|
|
<div class="toast align-items-center text-bg-success border-0 show" role="alert" aria-live="assertive" aria-atomic="true">
|
|
<div class="d-flex">
|
|
<div class="toast-body">
|
|
<i class="bi bi-check-circle-fill me-2"></i>
|
|
<?php echo $success; ?>
|
|
</div>
|
|
<button type="button" class="btn-close btn-close-white me-2 m-auto" data-bs-dismiss="toast" aria-label="Close"></button>
|
|
</div>
|
|
</div>
|
|
<?php endif; ?>
|
|
<?php if ($error): ?>
|
|
<div class="toast align-items-center text-bg-danger border-0 show" role="alert" aria-live="assertive" aria-atomic="true">
|
|
<div class="d-flex">
|
|
<div class="toast-body">
|
|
<i class="bi bi-exclamation-triangle-fill me-2"></i>
|
|
<?php echo $error; ?>
|
|
</div>
|
|
<button type="button" class="btn-close btn-close-white me-2 m-auto" data-bs-dismiss="toast" aria-label="Close"></button>
|
|
</div>
|
|
</div>
|
|
<?php endif; ?>
|
|
</div>
|
|
|
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
|
|
</body>
|
|
</html>
|