|
| 1 | +// resources/js/pages/BLHistorico.jsx |
| 2 | + |
| 3 | +import AppLayout from "@/layouts/app-layout"; |
| 4 | +import { Head } from "@inertiajs/react"; |
| 5 | +import { useState } from "react"; |
| 6 | +import { Button } from "flowbite-react"; |
| 7 | + |
| 8 | +const breadcrumbs = [ |
| 9 | + { title: "Marcacion BL", href: "/BLproductosInventario/BLMarcacion" } |
| 10 | +]; |
| 11 | + |
| 12 | +export default function MarcadoPage() { |
| 13 | + const [marcados, setMarcados] = useState([ |
| 14 | + { |
| 15 | + id: 1, |
| 16 | + cliente: "Cliente A", |
| 17 | + producto: "Botón 1222 Azul", |
| 18 | + trabajador: "Pedro", |
| 19 | + fecha: "2025-09-03", |
| 20 | + }, |
| 21 | + { |
| 22 | + id: 2, |
| 23 | + cliente: "Cliente B", |
| 24 | + producto: "Botón 1544 Rojo", |
| 25 | + trabajador: "María", |
| 26 | + fecha: "2025-09-03", |
| 27 | + }, |
| 28 | + ]); |
| 29 | + |
| 30 | + const [nuevo, setNuevo] = useState({ |
| 31 | + cliente: "", |
| 32 | + producto: "", |
| 33 | + trabajador: "", |
| 34 | + fecha: "", |
| 35 | + }); |
| 36 | + |
| 37 | + const handleChange = (e) => { |
| 38 | + setNuevo({ ...nuevo, [e.target.name]: e.target.value }); |
| 39 | + }; |
| 40 | + |
| 41 | + const agregarMarcado = () => { |
| 42 | + if (!nuevo.cliente || !nuevo.producto || !nuevo.trabajador || !nuevo.fecha) |
| 43 | + return; |
| 44 | + setMarcados([ |
| 45 | + ...marcados, |
| 46 | + { id: marcados.length + 1, ...nuevo }, |
| 47 | + ]); |
| 48 | + setNuevo({ cliente: "", producto: "", trabajador: "", fecha: "" }); |
| 49 | + }; |
| 50 | + |
| 51 | + return ( |
| 52 | + <AppLayout breadcrumbs={breadcrumbs}> |
| 53 | + <Head title="Histórico de Productos" /> |
| 54 | + |
| 55 | + <div className="p-6 max-w-7xl mx-auto"> |
| 56 | + <h1 className="text-2xl font-bold mb-6">📋 Registro de Marcado</h1> |
| 57 | + |
| 58 | + <div className="grid grid-cols-1 lg:grid-cols-4 gap-6"> |
| 59 | + {/* Columna Izquierda: Formulario + Tabla */} |
| 60 | + <div className="lg:col-span-3 space-y-6"> |
| 61 | + {/* Formulario */} |
| 62 | + <div className="bg-white dark:bg-gray-800 shadow-md rounded-2xl p-4"> |
| 63 | + <h2 className="text-lg font-semibold mb-4">Agregar Marcado</h2> |
| 64 | + <div className="grid grid-cols-1 md:grid-cols-4 gap-4"> |
| 65 | + <input |
| 66 | + type="text" |
| 67 | + name="cliente" |
| 68 | + placeholder="Cliente" |
| 69 | + value={nuevo.cliente} |
| 70 | + onChange={handleChange} |
| 71 | + className="border rounded-lg p-2 w-full" |
| 72 | + /> |
| 73 | + <input |
| 74 | + type="text" |
| 75 | + name="producto" |
| 76 | + placeholder="Producto" |
| 77 | + value={nuevo.producto} |
| 78 | + onChange={handleChange} |
| 79 | + className="border rounded-lg p-2 w-full" |
| 80 | + /> |
| 81 | + <input |
| 82 | + type="text" |
| 83 | + name="trabajador" |
| 84 | + placeholder="Trabajador" |
| 85 | + value={nuevo.trabajador} |
| 86 | + onChange={handleChange} |
| 87 | + className="border rounded-lg p-2 w-full" |
| 88 | + /> |
| 89 | + <input |
| 90 | + type="date" |
| 91 | + name="fecha" |
| 92 | + value={nuevo.fecha} |
| 93 | + onChange={handleChange} |
| 94 | + className="border rounded-lg p-2 w-full" |
| 95 | + /> |
| 96 | + </div> |
| 97 | + <div className="mt-4"> |
| 98 | + <Button onClick={agregarMarcado}>Agregar</Button> |
| 99 | + </div> |
| 100 | + </div> |
| 101 | + |
| 102 | + {/* Tabla */} |
| 103 | + <div className="overflow-x-auto shadow-md rounded-2xl"> |
| 104 | + <table className="w-full text-sm text-left text-gray-500 dark:text-gray-400"> |
| 105 | + <thead className="text-xs uppercase bg-gray-100 dark:bg-gray-700 dark:text-gray-300"> |
| 106 | + <tr> |
| 107 | + <th className="px-4 py-3">Cliente</th> |
| 108 | + <th className="px-4 py-3">Producto</th> |
| 109 | + <th className="px-4 py-3">Trabajador</th> |
| 110 | + <th className="px-4 py-3">Fecha</th> |
| 111 | + </tr> |
| 112 | + </thead> |
| 113 | + <tbody> |
| 114 | + {marcados.map((m) => ( |
| 115 | + <tr |
| 116 | + key={m.id} |
| 117 | + className="border-b dark:border-gray-600 hover:bg-gray-50 dark:hover:bg-gray-800" |
| 118 | + > |
| 119 | + <td className="px-4 py-3">{m.cliente}</td> |
| 120 | + <td className="px-4 py-3">{m.producto}</td> |
| 121 | + <td className="px-4 py-3">{m.trabajador}</td> |
| 122 | + <td className="px-4 py-3">{m.fecha}</td> |
| 123 | + </tr> |
| 124 | + ))} |
| 125 | + </tbody> |
| 126 | + </table> |
| 127 | + </div> |
| 128 | + </div> |
| 129 | + |
| 130 | + {/* Columna Derecha: Timeline */} |
| 131 | + <div className="bg-white dark:bg-gray-800 shadow-md rounded-2xl p-3"> |
| 132 | + <h2 className="text-base font-semibold mb-3">🕒 Línea de Tiempo</h2> |
| 133 | + <ol className="relative border-l border-gray-300 dark:border-gray-700 text-sm"> |
| 134 | + {marcados.map((m) => ( |
| 135 | + <li key={m.id} className="mb-6 ml-6"> |
| 136 | + <span className="absolute w-3 h-3 bg-blue-500 rounded-full -left-1.5 border border-white"></span> |
| 137 | + <h3 className="font-medium text-gray-900 dark:text-white"> |
| 138 | + {m.producto} |
| 139 | + </h3> |
| 140 | + <time className="block text-xs text-gray-500 dark:text-gray-400"> |
| 141 | + {m.fecha} |
| 142 | + </time> |
| 143 | + <p className="mt-1 text-gray-600 dark:text-gray-300 text-xs"> |
| 144 | + Cliente: <strong>{m.cliente}</strong> |
| 145 | + </p> |
| 146 | + <p className="text-gray-600 dark:text-gray-300 text-xs"> |
| 147 | + Trabajador: <strong>{m.trabajador}</strong> |
| 148 | + </p> |
| 149 | + </li> |
| 150 | + ))} |
| 151 | + </ol> |
| 152 | + </div> |
| 153 | + </div> |
| 154 | + </div> |
| 155 | + </AppLayout> |
| 156 | + ); |
| 157 | +} |
0 commit comments