Skip to content

Commit

Permalink
Merge branch 'julio' of https://github.com/IrvingYHM/Opticenter into …
Browse files Browse the repository at this point in the history
…prueba
  • Loading branch information
jul1oCesar0 committed Nov 20, 2024
2 parents 0cd5add + 2c13f39 commit 48f189f
Show file tree
Hide file tree
Showing 19 changed files with 525 additions and 217 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/vitest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ on:
jobs:
vitest:
runs-on: ubuntu-latest

#HOla
steps:
- name: Checkout code
uses: actions/checkout@v3
Expand Down
2 changes: 1 addition & 1 deletion dev-dist/sw.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ define(['./workbox-fde070c5'], (function (workbox) { 'use strict';
*/
workbox.precacheAndRoute([{
"url": "/offline.html",
"revision": "0.4c31ogilivg"
"revision": "0.tp82avot2f"
}], {});
workbox.cleanupOutdatedCaches();
workbox.registerRoute(new workbox.NavigationRoute(workbox.createHandlerBoundToURL("/offline.html"), {
Expand Down
16 changes: 9 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"@stripe/stripe-js": "^4.1.0",
"axios": "^1.6.7",
"bcryptjs": "^2.4.3",
"chart.js": "^4.4.2",
"chart.js": "^4.4.6",
"date-fns": "^2.30.0",
"formik": "^2.4.5",
"jest-environment-jsdom": "^29.7.0",
Expand Down
9 changes: 9 additions & 0 deletions src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ import Pedidos from './views/Perfil/Pedidos';
import PaginaSuccess from './views/Lente/SuccessPage'//cuando se realiza el pago de mercadopago
import Stripe from './views/Metodopago/stripe'

import Noencontrados from "./views/bus/noencontrados";
import Reporte from "./views/Admin/reportes";






Expand Down Expand Up @@ -153,6 +158,9 @@ function App() {
<Route path="/inicio/avisoP" element={<AvisoP />} />
<Route path="/inicio/cookies" element={<Cookies />} />
<Route path="/inicioS" element={<IniciarS />} />
<Route path="/Reporte" element={<Reporte />} />



<Route path="/Login_Empleado" element={<IniciarSEmpleado />} />
<Route path="/inicio/terminosC" element={<TerminoC />} />
Expand All @@ -168,6 +176,7 @@ function App() {
<Route path="/" element={<App />} />
<Route path="/Productos" element={<Productos />} />
<Route path="/productos-encontrados" element={<ProductosEncontrados />} />
<Route path="/productos-Noencontrados" element={<Noencontrados />} />
<Route path="/ProductosAg" element={<AgregarProductos />} />
<Route
path="/ModificarProducto/:id"
Expand Down
100 changes: 76 additions & 24 deletions src/components/Navegacion/Busqueda.jsx
Original file line number Diff line number Diff line change
@@ -1,38 +1,90 @@
import React from "react";
import { AiOutlineSearch } from "react-icons/ai";
import React, { useState, useEffect } from "react";
import { AiOutlineSearch, AiOutlineAudio } from "react-icons/ai";

function Busqueda({ busqueda, setBusqueda, handleSearch }) {
const [isListening, setIsListening] = useState(false);

const handleKeyDown = (event) => {
if (event.key === "Enter") {
handleSearch();
}
};

useEffect(() => {
// Ejecuta la búsqueda cada vez que el estado 'busqueda' cambie, pero no borra el texto
if (busqueda && busqueda.trim() !== "") {
handleSearch();
}
}, [busqueda, handleSearch]);

const startListening = () => {
const SpeechRecognition =
window.SpeechRecognition || window.webkitSpeechRecognition;

if (!SpeechRecognition) {
console.error("El reconocimiento de voz no está soportado en este navegador.");
return;
}

const recognition = new SpeechRecognition();
recognition.lang = "es-ES";
recognition.start();

recognition.onstart = () => {
setIsListening(true);
};

recognition.onresult = (event) => {
const transcript = event.results[0][0].transcript;
// Solo actualiza el estado si el texto reconocido no es vacío
if (transcript.trim()) {
setBusqueda(transcript);
}
};

recognition.onerror = () => {
setIsListening(false);
};

recognition.onend = () => {
setIsListening(false);
};
};

return (
<div className="flex items-center w-full">
{/* Barra de búsqueda que se ajusta a todos los tamaños de pantalla */}
<div className="flex items-center w-full">
<div className="bg-white rounded-l-full py-2 pl-2 flex items-center w-full">
<AiOutlineSearch className="w-5 h-5" />
<input
type="text"
placeholder="Buscar"
value={busqueda}
onChange={(e) => setBusqueda(e.target.value)}
onKeyDown={handleKeyDown}
className="flex-grow outline-none bg-transparent placeholder-gray-500 pl-1"
<div className="flex items-center w-full max-w-sm mx-auto px-2 space-x-2">
<div className="flex items-center w-full bg-white rounded-full shadow-md px-2 py-1 md:py-2">
<AiOutlineSearch className="w-4 h-4 md:w-5 md:h-5 text-gray-500 ml-2" />

<input
type="text"
placeholder="Buscar"
value={busqueda}
onChange={(e) => setBusqueda(e.target.value)}
onKeyDown={handleKeyDown}
className="flex-grow outline-none bg-transparent placeholder-gray-500 text-sm md:text-base px-2 "
/>

{/* Botón de micrófono para búsqueda por voz */}
<button
type="button"
onClick={startListening}
className="bg-gray-200 rounded-full p-1 md:p-2 mr-1"
disabled={isListening}
>
<AiOutlineAudio
className={`w-4 h-4 md:w-5 md:h-5 ${isListening ? "text-red-500" : "text-gray-500"}`}
/>
</div>
<div className="bg-gray-400 pl-1.5 rounded-r-full py-2 pr-3">
<button
type="button"
onClick={handleSearch}
className="flex items-center justify-center"
>
<AiOutlineSearch className="w-6 h-6" />
</button>
</div>
</button>

{/* Botón de búsqueda tradicional */}
<button
type="button"
onClick={handleSearch}
className="bg-gray-200 rounded-full p-1 md:p-2 mr-2"
>
<AiOutlineSearch className="w-4 h-4 md:w-5 md:h-5 text-gray-500" />
</button>
</div>
</div>
);
Expand Down
7 changes: 4 additions & 3 deletions src/components/Navegacion/barra.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,14 +107,15 @@ function Barra() {

try {
const response = await fetch(
`http://localhost:3000/productos/Buscar_productos?busqueda=${busqueda}`
`https://backopt-production.up.railway.app/productos/Buscar_productos?busqueda=${busqueda}`
);
const data = await response.json();
if (data.length > 0) {
setProductosEncontrados(data); // Establecer productos encontrados
navigate("/productos-encontrados", { state: { productos: data } });
} else {
console.log("No se encontraron productos.");
navigate("/productos-Noencontrados")
// Podemos mostrar un mensaje al usuario indicando que no se encontraron productos
setProductosEncontrados([]);
}
Expand All @@ -139,7 +140,7 @@ function Barra() {
<img
className="hidden md:block w-18 h-16 md:w-25 md:h-20 flex-wrap"
src={Logo}
alt="icono"
alt="logo"
/>
</Link>
<IoIosMenu
Expand All @@ -148,7 +149,7 @@ function Barra() {
onClick={toggleMenu}
/>

<div className=" flex-grow mx-auto md:hidden m-3 ">
<div className="flex-grow mx-auto md:hidden m-3 max-w-[250px] sm:max-w-none">
<Busqueda
busqueda={busqueda}
setBusqueda={setBusqueda}
Expand Down
2 changes: 1 addition & 1 deletion src/components/Navegacion/barraAdmin.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ function Barra() {
Empleados
</Link>
<Link
to="/EmpleadoAd"
to="/Reporte"
className="hover:border-b-2 border-blue-700 font-bold flex items-center"
>
Reportes
Expand Down
Binary file added src/img/noEncontrados.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/img/nocita.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
73 changes: 0 additions & 73 deletions src/test/barra.test.jsx

This file was deleted.

Loading

0 comments on commit 48f189f

Please sign in to comment.