Skip to content

Commit

Permalink
🎯 IMPROVE: buscador
Browse files Browse the repository at this point in the history
  • Loading branch information
CbazCode committed Aug 14, 2021
1 parent f2ac23e commit 2d5a7da
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 13 deletions.
23 changes: 20 additions & 3 deletions components/AutoComplete.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import router from "next/router"
import { useRef } from "react"
import { connectAutoComplete } from "react-instantsearch-dom"
import ZIcon from "../components/Icon"
import { post } from "../utils/http"
import showToast from "./Toast"

// Aplicar estilos
export const Autocomplete = ({ hits, currentRefinement, refine }) => {
Expand All @@ -24,13 +26,28 @@ export const Autocomplete = ({ hits, currentRefinement, refine }) => {
.join(" ")
.slice(1)}`
)
// eslint-disable-next-line camelcase
const { objectID, category_id } = hit
setTimeout(() => {
router.push("/explorar")
// eslint-disable-next-line camelcase
router.push(`/explorar/${category_id}/${objectID}`)
}, 500)
}
const handleSubmit = e => {
const handleSubmit = async e => {
e.preventDefault()
console.log("api/buscar/" + inputRef.current?.value || "none")
const res = await post("/api/post/search", {
nombre_post: inputRef.current?.value,
categoria_post: inputRef.current?.value
})
if (res.data.message === "Http Exception")
return showToast(
"Error",
"No se encontraron servicios relacionados a su busqueda",
"error"
)
const { idCategoria, idPost } = res.data.data
router.push(`/explorar/${idCategoria}/${idPost}`)
// console.log("api/buscar/" + inputRef.current?.value || "none")
}

return (
Expand Down
2 changes: 1 addition & 1 deletion components/CardCategory.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ export default function CardCategory({
post?.pst_imagen_1 || "/assets/images/marketing/marketing1.png"
}
alt={post?.pst_nombre}
height="550"
height="500"
width="500"
/>
</a>
Expand Down
5 changes: 3 additions & 2 deletions sections/Explore/InterestedService.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export default function InterestedService({ interesting }) {
))}
</Grid>
)}
{interesting.length > 3 ? (
{interesting.length > 3 && (
<Swiper
slidesPerView={4}
spaceBetween={10}
Expand Down Expand Up @@ -59,7 +59,8 @@ export default function InterestedService({ interesting }) {
</SwiperSlide>
))}
</Swiper>
) : (
)}
{interesting.length === 0 && (
<p>No hay servicios interesantes para ti</p>
)}
</div>
Expand Down
5 changes: 2 additions & 3 deletions sections/Explore/OurServices.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export default function OurServices({ ourServices }) {
))}
</Grid>
)}
{ourServices.length > 3 ? (
{ourServices.length > 3 && (
<Swiper
slidesPerView={4}
spaceBetween={10}
Expand Down Expand Up @@ -59,9 +59,8 @@ export default function OurServices({ ourServices }) {
</SwiperSlide>
))}
</Swiper>
) : (
<p>No tenemos servicios para ti</p>
)}
{ourServices.length === 0 && <p>No tenemos servicios para ti</p>}
</div>
</Box>
)
Expand Down
5 changes: 2 additions & 3 deletions sections/Explore/RecomendedService.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export default function RecomendedService({ recommended }) {
))}
</Grid>
)}
{recommended.length > 3 ? (
{recommended.length > 3 && (
<Swiper
slidesPerView={4}
spaceBetween={10}
Expand Down Expand Up @@ -58,9 +58,8 @@ export default function RecomendedService({ recommended }) {
</SwiperSlide>
))}
</Swiper>
) : (
<p>No hay servicios recomendados</p>
)}
{recommended.length === 0 && <p>No hay servicios recomendados</p>}
</div>
</Box>
)
Expand Down
3 changes: 2 additions & 1 deletion sections/ShowChat/Chat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@ export default function Chat() {
sendMessage()
}
const onKeyDown = e => {
if (e.keyCode === "13") {
// eslint-disable-next-line eqeqeq
if (e.keyCode == "13") {
sendMessage()
}
}
Expand Down

0 comments on commit 2d5a7da

Please sign in to comment.