1+ 'use client'
2+ import React , { useEffect , useState } from 'react' ;
3+ import CardComent from '@/components/CardComment' ;
4+ import CardChaza from '@/components/CardChaza' ;
5+ import Comments from '@/components/Comments' ;
6+ import Card from '@/components/Card' ;
7+ import Filter from '@/components/Filter' ;
8+ import NewPost from '@/components/NewPost' ;
9+
10+ import client , { myClient } from "@/config/client" ;
11+ import ModalComments from '@/components/Modal/ModalComments' ;
12+ import { useSearchParams , useRouter } from 'next/navigation'
13+ import CardReview from '@/components/Cards/CardReview' ;
14+
15+
16+ async function loadPost ( ) {
17+ try {
18+ var res = await client . get ( "chazas" ) ;
19+ //console.log(res.data.data)
20+ return res . data . data ;
21+ } catch ( err ) {
22+ console . log ( "err" , err ) ;
23+ }
24+ }
25+
126
227export default function Home ( ) {
28+ const searchParams = useSearchParams ( )
29+ const idSearch = searchParams . get ( 'id' )
30+ const router = useRouter ( )
31+ const [ chazas , setChazas ] = useState ( [ ] )
32+ const [ posts , setPosts ] = useState ( [ ] )
33+ useEffect ( ( ) => {
34+
35+ client . get ( `chazas` , { next : { revalidate : true | 0 | 60 } } )
36+ . then ( ( res ) => {
37+ if ( ! res . status == "200" ) {
38+ throw new Error ( 'Failed to fetch data' )
39+ }
40+ setChazas ( res . data . data . data )
41+ } )
42+
43+ client . get ( `publications` , { next : { revalidate : true | 0 | 60 } } ) .
44+ then ( ( res ) => {
45+
46+ if ( ! res . status == "200" ) {
47+ throw new Error ( 'Failed to fetch data' )
48+ }
49+ setPosts ( res . data . data . data )
50+ //if (!posts) return "An error has occurred.";
51+ } )
52+ } , [ ] )
53+
54+ //const post = await loadPost()
55+ var comments = [
56+ {
57+ "id" : 1 ,
58+ "review" : "¡Este es un comentario genial!" ,
59+ "urlImagen" : "https://www.example.com/imagen1.jpg"
60+ } ,
61+ {
62+ "id" : 2 ,
63+ "review" : "Este es otro comentario genial" ,
64+ "urlImagen" : "https://www.example.com/imagen2.jpg"
65+ } ,
66+ {
67+ "id" : 3 ,
68+ "review" : "¡Esta imagen es increíble!" ,
69+ "urlImagen" : "https://www.example.com/imagen3.jpg"
70+ } ,
71+ {
72+ "id" : 4 ,
73+ "review" : "¡Este es un comentario muy profundo!" ,
74+ "urlImagen" : "https://www.example.com/imagen4.jpg"
75+ } ,
76+ {
77+ "id" : 5 ,
78+ "review" : "¡Esta imagen me hace reír!" ,
79+ "urlImagen" : "https://www.example.com/imagen5.jpg"
80+ } ,
81+ {
82+ "id" : 6 ,
83+ "review" : "¡Esta imagen es muy triste!" ,
84+ "urlImagen" : "https://www.example.com/imagen6.jpg"
85+ } ,
86+ {
87+ "id" : 7 ,
88+ "review" : "¡Esta imagen es muy hermosa!" ,
89+ "urlImagen" : "https://www.example.com/imagen7.jpg"
90+ } ,
91+ {
92+ "id" : 8 ,
93+ "review" : "¡Esta imagen es muy graciosa!" ,
94+ "urlImagen" : "https://www.example.com/imagen8.jpg"
95+ } ,
96+ {
97+ "id" : 9 ,
98+ "review" : "¡Esta imagen es muy inspiradora!" ,
99+ "urlImagen" : "https://www.example.com/imagen9.jpg"
100+ } ,
101+ {
102+ "id" : 10 ,
103+ "review" : "¡Esta imagen es muy creativa!" ,
104+ "urlImagen" : "https://www.example.com/imagen10.jpg"
105+ }
106+ ]
3107 return (
4- < > </ >
108+ < div id = 'home' className = 'grid grid-cols-2' >
109+ { idSearch && ( < ModalComments onClose = { ( ) => { router . push ( "/" ) } } _id = { idSearch } /> )
110+
111+ }
112+ < Filter className = { "formSearch justify-items-center px-3 flex mx-auto text-center" } > </ Filter >
113+ < div className = 'formSearch justify-items-center px-3' >
114+ < form >
115+ < label htmlFor = "default-search" className = "mb-2 text-sm font-medium text-gray-900 sr-only dark:text-white" > Buscar</ label >
116+ < div className = "relative" >
117+ < div className = "absolute inset-y-0 left-0 flex items-center pl-3 pointer-events-none" >
118+ < svg className = "w-4 h-4 text-gray-500 dark:text-gray-400" aria-hidden = "true" xmlns = "http://www.w3.org/2000/svg" fill = "none" viewBox = "0 0 20 20" >
119+ < path stroke = "currentColor" strokeLinecap = "round" strokeLinejoin = "round" strokeWidth = "2" d = "m19 19-4-4m0-7A7 7 0 1 1 1 8a7 7 0 0 1 14 0Z" />
120+ </ svg >
121+ </ div >
122+ < input type = "search" id = "default-search" className = "block w-full p-4 pl-10 text-sm text-gray-900 border border-gray-300 rounded-lg bg-gray-50 focus:ring-blue-500 focus:border-blue-500 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500" placeholder = "Search Mockups, Logos..." required />
123+ < button type = "submit" className = "text-white absolute right-2.5 bottom-2.5 bg-blue-700 hover:bg-blue-800 focus:ring-4 focus:outline-none focus:ring-blue-300 font-medium rounded-lg text-sm px-4 py-2 dark:bg-blue-600 dark:hover:bg-blue-700 dark:focus:ring-blue-800" > Buscar</ button >
124+ </ div >
125+ </ form >
126+
127+ </ div >
128+ < div className = 'newpost col-span-2 flex justify-end px-3' >
129+ < NewPost > </ NewPost >
130+ </ div >
131+ < div className = "col-span-2 pt-3 CardProfile justify-items-center grid min-[1000px]:grid-cols-2 min-[1300px]:grid-cols-3 min-[1300px]:px-3" >
132+ { posts ?
133+ posts . map ( ( card ) => (
134+ < >
135+ < CardReview key = { "pub" + card . _id } card = { card } idModal = { card . _id } comments = { card . reviews } className = { "ListComment pb-2" } />
136+ </ >
137+ )
138+ )
139+
140+ : null }
141+ { chazas ?
142+ chazas . map ( ( chaz ) => (
143+ < >
144+ < Card key = { "cha" + chaz . _id } card = { chaz } idModal = { chaz . _id } comments = { comments } className = { "ListComment pb-2" } > </ Card >
145+ </ >
146+ )
147+ )
148+
149+ : null }
150+ </ div >
151+ < a href = "/unbiters/pricing" className = "btn-flotante text-white right-2.5 bg-blue-700 hover:bg-blue-800 focus:ring-4 focus:outline-none focus:ring-blue-300 font-medium rounded-lg text-sm px-4 py-2 dark:bg-blue-600 dark:hover:bg-blue-700 dark:focus:ring-blue-800" >
152+ Explora Premium
153+ </ a >
154+
155+ </ div >
5156 )
6- }
157+ }
0 commit comments