Initial commit

This commit is contained in:
Marlene-Angel
2025-12-15 16:50:49 -08:00
commit 17c742b1e7
21 changed files with 6392 additions and 0 deletions

188
src/App.css Normal file
View File

@@ -0,0 +1,188 @@
/* =========================
BASE
========================= */
body, html, #root {
margin: 0;
padding: 0;
height: 100%;
font-family: "Inter", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
/* =========================
APP / LAYOUT PRINCIPAL
========================= */
.app {
height: 100vh;
}
/* ESTE GRID ES EL QUE MANDA */
.main {
display: grid;
grid-template-columns: var(--sidebar-width) 1fr;
grid-template-rows: 100vh;
height: 100vh;
width: 100vw;
overflow: hidden;
transition: grid-template-columns 0.3s ease;
}
/*=========================
SIDEBAR
=========================
.sidebar {
background: #1f2a48;
color: #e5e7eb;
height: 100vh;
padding: 6px 0;
display: flex;
flex-direction: column;
width: var(--sidebar-width);
}
*/
/* TOGGLE
.sidebar-toggle {
display: flex;
align-items: center;
gap: 8px;
padding: 6px 14px;
background: transparent;
border: none;
color: inherit;
cursor: pointer;
font-size: 13px;
}*/
/*
.sidebar-item {
display: flex;
align-items: center;
gap: 10px;
padding: 6px 14px;
font-size: 18px;
background: transparent;
border: none;
color: inherit;
cursor: pointer;
border-radius: 6px;
}
.sidebar-item:hover {
background: rgba(255,255,255,0.08);
}
*/
/* SUBMENU
.sidebar-submenu {
display: flex;
flex-direction: column;
padding-left: 34px;
}
.sidebar-submenu button {
padding: 5px 8px;
font-size: 15px;
background: transparent;
border: none;
color: #cbd5e1;
cursor: pointer;
border-radius: 4px;
text-align: left;
}
.sidebar-submenu button:hover {
background: rgba(255,255,255,0.08);
color: white;
}
*/
/* =========================
CONTENT WRAPPER
========================= */
.content-wrapper {
display: flex;
flex-direction: column;
height: 100%;
width: 100%;
overflow: hidden;
}
/* =========================
TOP MENU
========================= */
.topmenu {
height: 50px;
background: linear-gradient(90deg, #3a4f92, #2b3c6b, #374a7f, #3a4f92);
color: white;
display: flex;
align-items: center;
justify-content: space-between;
padding: 0 20px;
box-sizing: border-box;
}
.topmenu-left,
.topmenu-right {
display: flex;
align-items: center;
gap: 10px;
}
.icon-btn {
background: transparent;
border: none;
color: white;
cursor: pointer;
padding: 6px;
border-radius: 50%;
}
.icon-btn:hover {
background: rgba(255,255,255,0.15);
}
.user-avatar {
width: 32px;
height: 32px;
border-radius: 100%;
background: rgba(255,255,255,0.25);
display: flex;
align-items: center;
justify-content: center;
cursor: pointer;
}
/* =========================
CONTENT
========================= */
.content {
flex: 1;
background-color: #f2f3f7;
border-top: 1px solid #d9dce6;
border-left: 1px solid #d9dce6;
overflow: auto;
box-sizing: border-box;
}
/* HOME */ /* CONTENEDOR PRINCIPAL */
.home-container {
height: 100%;
display: flex;
flex-direction:
column; align-items:
center; justify-content:
center; padding: 5px;
text-align: center;
}
/* TÍTULO */
.home-title {
font-size: 32px;
font-weight: bold;
color: #1f2a48;
margin-bottom: 10px;
} /* SUBTÍTULO */
.home-subtitle {
font-size: 16px;
color: #3a3a3a;
margin-bottom: 40px;
}

45
src/App.tsx Normal file
View File

@@ -0,0 +1,45 @@
import { useState } from "react";
import Sidebar from "./pages/Sidebar";
import TopMenu from "./pages/TopMenu";
import AreaManagement from "./pages/AreaManagement";
import OperatorManagement from "./pages/OperatorManagement";
import Home from "./pages/Home";
// Tipos para las páginas que reciben subPage
interface PageProps {
subPage: string;
}
export default function App() {
const [page, setPage] = useState<string>("home");
const [subPage, setSubPage] = useState<string>("default");
const renderContent = () => {
switch (page) {
case "home":
return <Home />;
case "area":
return <AreaManagement subPage={subPage} />; // ahora tipado correctamente
case "operator":
return <OperatorManagement subPage={subPage} />; // también
default:
return <div>Selecciona una opción</div>;
}
};
return (
<div className="flex h-screen w-screen overflow-hidden">
{/* SIDEBAR */}
<Sidebar setPage={setPage} />
{/* MAIN */}
<div className="flex flex-col flex-1 overflow-hidden">
<TopMenu page={page} subPage={subPage} setSubPage={setSubPage} />
<main className="flex-1 overflow-auto bg-gray-100 p-4">
{renderContent()}
</main>
</div>
</div>
);
}

1
src/assets/react.svg Normal file
View File

@@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="35.93" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 228"><path fill="#00D8FF" d="M210.483 73.824a171.49 171.49 0 0 0-8.24-2.597c.465-1.9.893-3.777 1.273-5.621c6.238-30.281 2.16-54.676-11.769-62.708c-13.355-7.7-35.196.329-57.254 19.526a171.23 171.23 0 0 0-6.375 5.848a155.866 155.866 0 0 0-4.241-3.917C100.759 3.829 77.587-4.822 63.673 3.233C50.33 10.957 46.379 33.89 51.995 62.588a170.974 170.974 0 0 0 1.892 8.48c-3.28.932-6.445 1.924-9.474 2.98C17.309 83.498 0 98.307 0 113.668c0 15.865 18.582 31.778 46.812 41.427a145.52 145.52 0 0 0 6.921 2.165a167.467 167.467 0 0 0-2.01 9.138c-5.354 28.2-1.173 50.591 12.134 58.266c13.744 7.926 36.812-.22 59.273-19.855a145.567 145.567 0 0 0 5.342-4.923a168.064 168.064 0 0 0 6.92 6.314c21.758 18.722 43.246 26.282 56.54 18.586c13.731-7.949 18.194-32.003 12.4-61.268a145.016 145.016 0 0 0-1.535-6.842c1.62-.48 3.21-.974 4.76-1.488c29.348-9.723 48.443-25.443 48.443-41.52c0-15.417-17.868-30.326-45.517-39.844Zm-6.365 70.984c-1.4.463-2.836.91-4.3 1.345c-3.24-10.257-7.612-21.163-12.963-32.432c5.106-11 9.31-21.767 12.459-31.957c2.619.758 5.16 1.557 7.61 2.4c23.69 8.156 38.14 20.213 38.14 29.504c0 9.896-15.606 22.743-40.946 31.14Zm-10.514 20.834c2.562 12.94 2.927 24.64 1.23 33.787c-1.524 8.219-4.59 13.698-8.382 15.893c-8.067 4.67-25.32-1.4-43.927-17.412a156.726 156.726 0 0 1-6.437-5.87c7.214-7.889 14.423-17.06 21.459-27.246c12.376-1.098 24.068-2.894 34.671-5.345a134.17 134.17 0 0 1 1.386 6.193ZM87.276 214.515c-7.882 2.783-14.16 2.863-17.955.675c-8.075-4.657-11.432-22.636-6.853-46.752a156.923 156.923 0 0 1 1.869-8.499c10.486 2.32 22.093 3.988 34.498 4.994c7.084 9.967 14.501 19.128 21.976 27.15a134.668 134.668 0 0 1-4.877 4.492c-9.933 8.682-19.886 14.842-28.658 17.94ZM50.35 144.747c-12.483-4.267-22.792-9.812-29.858-15.863c-6.35-5.437-9.555-10.836-9.555-15.216c0-9.322 13.897-21.212 37.076-29.293c2.813-.98 5.757-1.905 8.812-2.773c3.204 10.42 7.406 21.315 12.477 32.332c-5.137 11.18-9.399 22.249-12.634 32.792a134.718 134.718 0 0 1-6.318-1.979Zm12.378-84.26c-4.811-24.587-1.616-43.134 6.425-47.789c8.564-4.958 27.502 2.111 47.463 19.835a144.318 144.318 0 0 1 3.841 3.545c-7.438 7.987-14.787 17.08-21.808 26.988c-12.04 1.116-23.565 2.908-34.161 5.309a160.342 160.342 0 0 1-1.76-7.887Zm110.427 27.268a347.8 347.8 0 0 0-7.785-12.803c8.168 1.033 15.994 2.404 23.343 4.08c-2.206 7.072-4.956 14.465-8.193 22.045a381.151 381.151 0 0 0-7.365-13.322Zm-45.032-43.861c5.044 5.465 10.096 11.566 15.065 18.186a322.04 322.04 0 0 0-30.257-.006c4.974-6.559 10.069-12.652 15.192-18.18ZM82.802 87.83a323.167 323.167 0 0 0-7.227 13.238c-3.184-7.553-5.909-14.98-8.134-22.152c7.304-1.634 15.093-2.97 23.209-3.984a321.524 321.524 0 0 0-7.848 12.897Zm8.081 65.352c-8.385-.936-16.291-2.203-23.593-3.793c2.26-7.3 5.045-14.885 8.298-22.6a321.187 321.187 0 0 0 7.257 13.246c2.594 4.48 5.28 8.868 8.038 13.147Zm37.542 31.03c-5.184-5.592-10.354-11.779-15.403-18.433c4.902.192 9.899.29 14.978.29c5.218 0 10.376-.117 15.453-.343c-4.985 6.774-10.018 12.97-15.028 18.486Zm52.198-57.817c3.422 7.8 6.306 15.345 8.596 22.52c-7.422 1.694-15.436 3.058-23.88 4.071a382.417 382.417 0 0 0 7.859-13.026a347.403 347.403 0 0 0 7.425-13.565Zm-16.898 8.101a358.557 358.557 0 0 1-12.281 19.815a329.4 329.4 0 0 1-23.444.823c-7.967 0-15.716-.248-23.178-.732a310.202 310.202 0 0 1-12.513-19.846h.001a307.41 307.41 0 0 1-10.923-20.627a310.278 310.278 0 0 1 10.89-20.637l-.001.001a307.318 307.318 0 0 1 12.413-19.761c7.613-.576 15.42-.876 23.31-.876H128c7.926 0 15.743.303 23.354.883a329.357 329.357 0 0 1 12.335 19.695a358.489 358.489 0 0 1 11.036 20.54a329.472 329.472 0 0 1-11 20.722Zm22.56-122.124c8.572 4.944 11.906 24.881 6.52 51.026c-.344 1.668-.73 3.367-1.15 5.09c-10.622-2.452-22.155-4.275-34.23-5.408c-7.034-10.017-14.323-19.124-21.64-27.008a160.789 160.789 0 0 1 5.888-5.4c18.9-16.447 36.564-22.941 44.612-18.3ZM128 90.808c12.625 0 22.86 10.235 22.86 22.86s-10.235 22.86-22.86 22.86s-22.86-10.235-22.86-22.86s10.235-22.86 22.86-22.86Z"></path></svg>

After

Width:  |  Height:  |  Size: 4.0 KiB

1
src/index.css Normal file
View File

@@ -0,0 +1 @@
@import 'tailwindcss'

10
src/main.tsx Normal file
View File

@@ -0,0 +1,10 @@
import React from 'react'
import ReactDOM from 'react-dom/client'
import App from './App.tsx'
import './index.css'
ReactDOM.createRoot(document.getElementById('root')!).render(
<React.StrictMode>
<App />
</React.StrictMode>,
)

View File

@@ -0,0 +1,196 @@
import { useState } from "react";
import { DataGrid, GridColDef } from "@mui/x-data-grid";
import { Add, Delete, Refresh, Edit } from "@mui/icons-material";
import { Button, IconButton, Dialog, DialogTitle, DialogContent, DialogActions, TextField, CircularProgress } from "@mui/material";
interface Area {
id: number;
name: string;
no: string;
code: string;
sort: number;
pushAddress: string;
note: string;
time: string;
}
export default function AreaManagement() {
const [rows, setRows] = useState<Area[]>([
{ id: 1, name: "Operaciones", no: "001", code: "OP01", sort: 1, pushAddress: "Calle 123", note: "Área principal", time: "08:00-17:00" },
{ id: 2, name: "Calidad", no: "002", code: "QA02", sort: 2, pushAddress: "Calle 456", note: "Revisión diaria", time: "09:00-18:00" },
{ id: 3, name: "Mantenimiento", no: "003", code: "MT03", sort: 3, pushAddress: "Calle 789", note: "Turno A", time: "07:00-15:00" },
]);
const [dialogOpen, setDialogOpen] = useState(false);
const [editMode, setEditMode] = useState(false);
const [currentArea, setCurrentArea] = useState<Area>({
id: 0,
name: "",
no: "",
code: "",
sort: 0,
pushAddress: "",
note: "",
time: "",
});
const [loading, setLoading] = useState(false);
// Columns del DataGrid
const columns: GridColDef[] = [
{ field: "id", headerName: "ID", width: 70 },
{ field: "name", headerName: "Área", width: 150 },
{ field: "no", headerName: "Área No.", width: 120 },
{ field: "code", headerName: "Código", width: 120 },
{ field: "sort", headerName: "Sort", width: 80 },
{ field: "pushAddress", headerName: "Push Address", width: 180 },
{ field: "note", headerName: "Notas", width: 200 },
{ field: "time", headerName: "Time", width: 120 },
{
field: "operate",
headerName: "Operar",
width: 150,
renderCell: (params) => (
<div className="flex gap-2">
<IconButton color="primary" size="small" onClick={() => handleEdit(params.row)}>
<Edit fontSize="small" />
</IconButton>
<IconButton color="error" size="small" onClick={() => handleDelete(params.row.id)}>
<Delete fontSize="small" />
</IconButton>
</div>
),
},
];
// FUNCIONES CRUD
const handleDelete = (id: number) => {
if (confirm("¿Deseas eliminar esta área?")) {
setRows(rows.filter(row => row.id !== id));
}
};
const handleEdit = (area: Area) => {
setCurrentArea(area);
setEditMode(true);
setDialogOpen(true);
};
const handleAdd = () => {
const newId = rows.length ? Math.max(...rows.map(r => r.id)) + 1 : 1;
setRows([...rows, { ...currentArea, id: newId }]);
setDialogOpen(false);
resetForm();
};
const handleUpdate = () => {
setRows(rows.map(r => (r.id === currentArea.id ? currentArea : r)));
setDialogOpen(false);
resetForm();
};
const resetForm = () => {
setCurrentArea({ id: 0, name: "", no: "", code: "", sort: 0, pushAddress: "", note: "", time: "" });
setEditMode(false);
};
const handleRefresh = () => {
setLoading(true);
setTimeout(() => {
setRows([...rows]); // podrías reemplazar con fetch real
setLoading(false);
}, 1000);
};
return (
<div className="flex flex-col gap-6 p-6 h-full">
{/* HEADER */}
<div
className="flex justify-between items-center p-5 rounded-xl"
style={{
background: "linear-gradient(135deg, #4c5f9e, #2a355d, #566bb8, #3d4e87)",
backgroundSize: "350% 350%",
animation: "gradientMove 10s ease infinite",
color: "white",
backdropFilter: "blur(10px)",
border: "1px solid rgba(255,255,255,0.25)",
boxShadow: "0px 8px 22px rgba(0,0,0,0.25)",
}}
>
<h1 className="text-xl font-bold">Area Management</h1>
<div className="flex gap-3">
<Button
variant="outlined"
startIcon={<Add />}
sx={{
color: "white",
borderColor: "rgba(255,255,255,0.4)",
"&:hover": { borderColor: "white", background: "rgba(255,255,255,0.15)" },
}}
onClick={() => setDialogOpen(true)}
>
Agregar
</Button>
<Button
variant="outlined"
startIcon={loading ? <CircularProgress size={18} color="inherit" /> : <Refresh />}
sx={{
color: "white",
borderColor: "rgba(255,255,255,0.4)",
"&:hover": { borderColor: "white", background: "rgba(255,255,255,0.15)" },
}}
onClick={handleRefresh}
>
{loading ? "Recargando..." : "Refrescar"}
</Button>
</div>
</div>
{/* TABLA */}
<div className="flex-1 bg-white rounded-xl overflow-hidden shadow-md">
<DataGrid
rows={rows}
columns={columns}
pageSize={5}
rowsPerPageOptions={[5]}
sx={{ border: "none", "& .MuiDataGrid-row:hover": { backgroundColor: "rgba(0,0,0,0.03)" } }}
/>
</div>
{/* DIALOG FORM */}
<Dialog open={dialogOpen} onClose={() => { setDialogOpen(false); resetForm(); }}>
<DialogTitle>{editMode ? "Editar Área" : "Agregar Nueva Área"}</DialogTitle>
<DialogContent className="flex flex-col gap-3 min-w-[400px]">
{["name","no","code","sort","pushAddress","note","time"].map((field) => (
<TextField
key={field}
label={field.charAt(0).toUpperCase() + field.slice(1)}
type={field === "sort" ? "number" : "text"}
value={(currentArea as any)[field]}
onChange={(e) => setCurrentArea({ ...currentArea, [field]: field === "sort" ? Number(e.target.value) : e.target.value })}
fullWidth
/>
))}
</DialogContent>
<DialogActions>
<Button onClick={() => { setDialogOpen(false); resetForm(); }}>Cancelar</Button>
<Button variant="contained" onClick={editMode ? handleUpdate : handleAdd}>
{editMode ? "Actualizar" : "Agregar"}
</Button>
</DialogActions>
</Dialog>
<style>
{`
@keyframes gradientMove {
0% {background-position: 0% 50%;}
50% {background-position: 100% 50%;}
100% {background-position: 0% 50%;}
}
`}
</style>
</div>
);
}

95
src/pages/Home.tsx Normal file
View File

@@ -0,0 +1,95 @@
import { Cpu, Settings, BarChart3, Bell } from "lucide-react";
import { BarChart, Bar, XAxis, YAxis, Tooltip, ResponsiveContainer, CartesianGrid } from "recharts";
export default function Home() {
const companies = [
{ name: "Empresa A", tomas: 12, alerts: 2, consumption: 320 },
{ name: "Empresa B", tomas: 8, alerts: 0, consumption: 210 },
{ name: "Empresa C", tomas: 15, alerts: 1, consumption: 450 },
];
const alerts = [
{ company: "Empresa A", type: "Fuga", time: "Hace 2 horas" },
{ company: "Empresa C", type: "Consumo alto", time: "Hace 5 horas" },
{ company: "Empresa B", type: "Inactividad", time: "Hace 8 horas" },
];
return (
<div className="flex flex-col p-6 gap-8 w-full">
{/* Título */}
<div>
<h1 className="text-3xl font-bold text-gray-800">Sistema de Tomas de Agua</h1>
<p className="text-gray-600 mt-2">
Monitorea, administra y controla tus operaciones en un solo lugar.
</p>
</div>
{/* Cards de Secciones */}
<div className="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-6">
<div className="bg-white rounded-xl shadow p-6 flex flex-col items-center justify-center gap-2 hover:bg-blue-50 transition">
<Cpu size={40} className="text-blue-600" />
<span className="font-semibold text-gray-700">Tomas</span>
</div>
<div className="bg-white rounded-xl shadow p-6 flex flex-col items-center justify-center gap-2 hover:bg-red-50 transition">
<Bell size={40} className="text-red-600" />
<span className="font-semibold text-gray-700">Alertas</span>
</div>
<div className="bg-white rounded-xl shadow p-6 flex flex-col items-center justify-center gap-2 hover:bg-yellow-50 transition">
<Settings size={40} className="text-yellow-600" />
<span className="font-semibold text-gray-700">Mantenimiento</span>
</div>
<div className="bg-white rounded-xl shadow p-6 flex flex-col items-center justify-center gap-2 hover:bg-green-50 transition">
<BarChart3 size={40} className="text-green-600" />
<span className="font-semibold text-gray-700">Reportes</span>
</div>
</div>
{/* Resumen de tomas por empresa */}
<div className="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4">
{companies.map((c) => (
<div
key={c.name}
className="bg-white rounded-xl shadow p-4 flex flex-col gap-1"
>
<span className="text-gray-500 text-sm">{c.name}</span>
<span className="text-2xl font-bold text-gray-800">{c.tomas} Tomas</span>
<span className={`text-sm font-medium ${c.alerts > 0 ? "text-red-500" : "text-green-500"}`}>
{c.alerts} Alertas
</span>
</div>
))}
</div>
{/* Gráfica de consumo */}
<div className="bg-white rounded-xl shadow p-6">
<h2 className="text-lg font-semibold mb-4">Consumo de Agua por Empresa</h2>
<div className="h-60">
<ResponsiveContainer width="100%" height="100%">
<BarChart data={companies} margin={{ top: 5, right: 20, left: 0, bottom: 5 }}>
<CartesianGrid strokeDasharray="3 3" />
<XAxis dataKey="name" />
<YAxis />
<Tooltip />
<Bar dataKey="consumption" fill="#4c5f9e" />
</BarChart>
</ResponsiveContainer>
</div>
</div>
{/* Últimas alertas */}
<div className="bg-white rounded-xl shadow p-6">
<h2 className="text-lg font-semibold mb-4">Últimas Alertas</h2>
<ul className="divide-y divide-gray-200">
{alerts.map((a, i) => (
<li key={i} className="py-2 flex justify-between">
<span>{a.company} - {a.type}</span>
<span className="text-red-500 font-medium">{a.time}</span>
</li>
))}
</ul>
</div>
</div>
);
}

View File

@@ -0,0 +1,131 @@
import { useState } from "react";
interface OperatorManagementProps {
subPage: string;
}
export default function OperatorManagement({ subPage }: OperatorManagementProps) {
const [search, setSearch] = useState("");
const users = [
{ id: 1, name: "Neil Sims", email: "neil.sims@flowbite.com", role: "React Developer", status: "Online", img: "https://randomuser.me/api/portraits/men/1.jpg" },
{ id: 2, name: "Bonnie Green", email: "bonnie@flowbite.com", role: "Designer", status: "Online", img: "https://randomuser.me/api/portraits/women/2.jpg" },
{ id: 3, name: "Jese Leos", email: "jese@flowbite.com", role: "Vue JS Developer", status: "Online", img: "https://randomuser.me/api/portraits/men/3.jpg" },
{ id: 4, name: "Thomas Lean", email: "thames@flowbite.com", role: "UI/UX Engineer", status: "Online", img: "https://randomuser.me/api/portraits/men/4.jpg" },
{ id: 5, name: "Leslie Livingston", email: "leslie@flowbite.com", role: "SEO Specialist", status: "Offline", img: "https://randomuser.me/api/portraits/women/5.jpg" },
];
const filteredUsers = users.filter(
(user) =>
user.name.toLowerCase().includes(search.toLowerCase()) ||
user.email.toLowerCase().includes(search.toLowerCase())
);
return (
<div className="flex flex-col gap-6 p-6">
{/* HEADER ANIMADO */}
<div className="flex flex-col md:flex-row justify-between items-center p-5 rounded-xl relative overflow-hidden"
style={{
background: "linear-gradient(135deg, #4c5f9e, #2a355d, #566bb8, #3d4e87)",
backgroundSize: "350% 350%",
animation: "gradientMove 10s ease infinite",
color: "white",
backdropFilter: "blur(10px)",
border: "1px solid rgba(255,255,255,0.25)",
boxShadow: "0px 8px 22px rgba(0,0,0,0.25)",
}}
>
<h1 className="text-2xl font-medium mb-3 md:mb-0">Gestión de Usuarios</h1>
{/* BOTONES ESTILO GHOST */}
<div className="flex gap-3">
<button className="px-4 py-2 border border-white/40 rounded-lg text-white hover:bg-white/15 hover:border-white transition">
Agregar
</button>
<button className="px-4 py-2 border border-white/40 rounded-lg text-white hover:bg-white/15 hover:border-white transition">
Borrar
</button>
<button className="px-4 py-2 border border-white/40 rounded-lg text-white hover:bg-white/15 hover:border-white transition">
Refrescar
</button>
</div>
</div>
{/* TABLA */}
<div className="relative overflow-x-auto shadow-sm rounded-lg border border-gray-300 bg-white">
{/* SEARCH */}
<div className="flex flex-col md:flex-row items-center justify-between p-4 space-y-4 md:space-y-0">
<div className="relative w-full max-w-xs">
<input
type="text"
placeholder="Search"
value={search}
onChange={(e) => setSearch(e.target.value)}
className="w-full pl-9 pr-3 py-2 border border-gray-300 rounded shadow-sm text-gray-700 text-sm focus:outline-none focus:ring-2 focus:ring-blue-300"
/>
<div className="absolute inset-y-0 left-2 flex items-center pointer-events-none">
<svg className="w-4 h-4 text-gray-400" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M21 21l-3.5-3.5M17 10a7 7 0 1 1-14 0 7 7 0 0 1 14 0Z" />
</svg>
</div>
</div>
</div>
<table className="w-full text-sm text-left text-gray-700">
<thead className="bg-gray-200 border-b border-gray-300">
<tr>
<th className="p-4">
<input type="checkbox" className="w-4 h-4 border rounded" />
</th>
<th className="px-6 py-3 font-medium">Nombre</th>
<th className="px-6 py-3 font-medium">Rol</th>
<th className="px-6 py-3 font-medium">Estado</th>
<th className="px-6 py-3 font-medium">Acción</th>
</tr>
</thead>
<tbody>
{filteredUsers.map((user, index) => (
<tr
key={user.id}
className={`border-b border-gray-300 ${index % 2 === 0 ? "bg-gray-50" : "bg-white"} hover:bg-gray-100`}
>
<td className="p-4">
<input type="checkbox" className="w-4 h-4 border rounded" />
</td>
<th className="flex items-center px-6 py-4 font-medium whitespace-nowrap">
<img className="w-10 h-10 rounded-full" src={user.img} alt={user.name} />
<div className="ml-3">
<div className="text-base font-semibold">{user.name}</div>
<div className="text-gray-500 text-sm">{user.email}</div>
</div>
</th>
<td className="px-6 py-4">{user.role}</td>
<td className="px-6 py-4">
<div className="flex items-center">
<div
className={`h-2.5 w-2.5 rounded-full mr-2 ${user.status === "Online" ? "bg-green-500" : "bg-red-500"}`}
></div>
{user.status}
</div>
</td>
<td className="px-6 py-4">
<button className="text-blue-600 font-medium hover:underline">Editar</button>
</td>
</tr>
))}
</tbody>
</table>
</div>
<style>
{`
@keyframes gradientMove {
0% {background-position: 0% 50%;}
50% {background-position: 100% 50%;}
100% {background-position: 0% 50%;}
}
`}
</style>
</div>
);
}

143
src/pages/Sidebar.tsx Normal file
View File

@@ -0,0 +1,143 @@
import { useState } from "react";
import {
Home,
Settings,
WaterDrop,
ExpandMore,
ExpandLess,
Menu,
} from "@mui/icons-material";
export default function Sidebar({ setPage }: any) {
const [systemOpen, setSystemOpen] = useState(true);
const [waterOpen, setWaterOpen] = useState(true);
const [pinned, setPinned] = useState(false);
const [hovered, setHovered] = useState(false);
const isExpanded = pinned || hovered;
return (
<aside
onMouseEnter={() => setHovered(true)}
onMouseLeave={() => setHovered(false)}
className={`
h-full bg-[#1f2a48] border-r border-white/10
transition-all duration-300 flex flex-col overflow-hidden
${isExpanded ? "w-72" : "w-16"}
`}
>
{/* HEADER */}
<div className="border-b border-white/10 px-4 py-3 flex items-center gap-3">
<button
onClick={() => setPinned(!pinned)}
className="text-white opacity-90 hover:opacity-100"
>
<Menu />
</button>
{isExpanded && (
<span className="text-lg font-bold text-white whitespace-nowrap">
Water System
</span>
)}
</div>
{/* MENU */}
<div className="flex-1 py-4 px-2 overflow-y-auto">
<ul className="space-y-1 text-white text-sm">
{/* DASHBOARD */}
<li>
<button
onClick={() => setPage("home")}
className="flex items-center w-full px-2 py-2 rounded-md hover:bg-white/10 font-bold"
>
<Home className="w-5 h-5 shrink-0" />
{isExpanded && <span className="ml-3">Dashboard</span>}
</button>
</li>
{/* SYSTEM SETTINGS */}
<li>
<button
onClick={() => isExpanded && setSystemOpen(!systemOpen)}
className="flex items-center w-full px-2 py-2 rounded-md hover:bg-white/10 font-bold"
>
<Settings className="w-5 h-5 shrink-0" />
{isExpanded && (
<>
<span className="ml-3 flex-1 text-left">
System Settings
</span>
{systemOpen ? <ExpandLess /> : <ExpandMore />}
</>
)}
</button>
{isExpanded && systemOpen && (
<ul className="mt-1 space-y-1 text-xs">
<li>
<button
onClick={() => setPage("area")}
className="pl-10 w-full text-left px-2 py-1.5 rounded-md hover:bg-white/10"
>
Area Management
</button>
</li>
<li>
<button
onClick={() => setPage("operator")}
className="pl-10 w-full text-left px-2 py-1.5 rounded-md hover:bg-white/10"
>
Operator Management
</button>
</li>
</ul>
)}
</li>
{/* WATER METER SYSTEM */}
<li>
<button
onClick={() => isExpanded && setWaterOpen(!waterOpen)}
className="flex items-center w-full px-2 py-2 rounded-md hover:bg-white/10 font-bold"
>
<WaterDrop className="w-5 h-5 shrink-0" />
{isExpanded && (
<>
<span className="ml-3 flex-1 text-left">
Water Meter System Management
</span>
{waterOpen ? <ExpandLess /> : <ExpandMore />}
</>
)}
</button>
{isExpanded && waterOpen && (
<ul className="mt-1 space-y-1 text-xs">
{[
["water-install", "Water Meter Installation"],
["device-install", "Device Installation"],
["meter-management", "Meter Management"],
["device-management", "Device Management"],
["data-monitoring", "Data Monitoring"],
["data-query", "Data Query"],
].map(([key, label]) => (
<li key={key}>
<button
onClick={() => setPage(key)}
className="pl-10 w-full text-left px-2 py-1.5 rounded-md hover:bg-white/10"
>
{label}
</button>
</li>
))}
</ul>
)}
</li>
</ul>
</div>
</aside>
);
}

61
src/pages/TopMenu.tsx Normal file
View File

@@ -0,0 +1,61 @@
import React from "react";
import { Bell, User, Settings } from "lucide-react";
interface TopMenuProps {
page: string;
subPage: string;
setSubPage: (subPage: string) => void;
}
const TopMenu: React.FC<TopMenuProps> = ({ page, subPage, setSubPage }) => {
return (
<header
className="h-14 shrink-0 flex items-center justify-between px-4 text-white"
style={{
background:
"linear-gradient(135deg, #4c5f9e, #2a355d, #566bb8, #3d4e87)",
}}
>
{/* IZQUIERDA */}
<div className="flex items-center gap-2 text-sm font-medium opacity-90">
{page !== "home" && (
<>
<span className="capitalize">{page}</span>
{subPage !== "default" && (
<>
<span className="opacity-60">/</span>
<span className="capitalize">{subPage}</span>
</>
)}
</>
)}
</div>
{/* DERECHA */}
<div className="flex items-center gap-3">
<button
aria-label="Notificaciones"
className="p-2 rounded-full hover:bg-white/10 transition"
>
<Bell size={20} />
</button>
<button
aria-label="Configuración"
className="p-2 rounded-full hover:bg-white/10 transition"
>
<Settings size={20} />
</button>
<div
className="w-9 h-9 rounded-full bg-white/15 flex items-center justify-center cursor-pointer hover:bg-white/25 transition"
title="Perfil"
>
<User size={20} />
</div>
</div>
</header>
);
};
export default TopMenu;

1
src/vite-env.d.ts vendored Normal file
View File

@@ -0,0 +1 @@
/// <reference types="vite/client" />