Skip to content

Commit

Permalink
avances reviews, falta conectar con backend
Browse files Browse the repository at this point in the history
  • Loading branch information
JaviL13 committed Nov 15, 2024
1 parent 13432b8 commit 4ef0c53
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 11 deletions.
1 change: 1 addition & 0 deletions src/components/NewPublicacion.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ const NewPublicacion = ({ title, description, image, price, rating, location, ca
<div className='publicacion-descripcion'>
{description}
</div>

</div>
</div>

Expand Down
16 changes: 5 additions & 11 deletions src/components/NewPublicacionInfo.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { MapPin } from 'lucide-react'
import lugares from './lugares';
import '../styles/calendario.css';
import { useParams } from 'react-router-dom';
import ReviewForm from './ReviewForm';

const NewPublicacionInfo = ({id}) => {
// definir un estado para guardar la información de la publicación
Expand Down Expand Up @@ -83,17 +84,9 @@ const NewPublicacionInfo = ({id}) => {
<hr /> {/* linea separadora */}
<p className='event-description'> {selectedEvent.descripcion}</p>
<p className='event-description'>Contacto: {selectedEvent.contacto}</p>

{/* reviews */}
<p className='event-subtitle'>Reseñas</p>
<hr /> {/* linea separadora */}
{selectedEvent.reseñas.map((review, index) => (
<div key={index} className='event-reviews'>
<p className='event-description'>
{review.puntuacion} ★ - {review.comentario}
</p>
</div>
))}

{/* Dejar comentario */}
<ReviewForm />
{/* link a Google Maps */}
<a
href={`https://www.google.com/maps/search/?api=1&query=${selectedEvent.lat},${selectedEvent.lng}`}
Expand All @@ -105,6 +98,7 @@ const NewPublicacionInfo = ({id}) => {
</a>
<hr /> {/* linea separadora */}
{/* Reportar */}

<button className='little-button'>Reportar</button>
</div>
</div>
Expand Down
1 change: 1 addition & 0 deletions src/components/NewPublicaciones.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const Publicaciones = ({ publicaciones }) => {
subcategory={publicacion.subcategoria}
date={publicacion.fecha}
id={publicacion.id}

/>
))}
</div>
Expand Down
27 changes: 27 additions & 0 deletions src/components/ReviewForm.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import React, { useState } from 'react';
import StarRating from './StarRating'; // Asegúrate de importar el componente StarRating

const ReviewForm = () => {
const [rating, setRating] = useState(0);
const [comment, setComment] = useState('');

const handleSubmit = (e) => {
e.preventDefault();
// Aquí puedes manejar el envío del formulario, por ejemplo, enviando los datos a una API
console.log('Rating:', rating);
console.log('Comment:', comment);
};

return (
<form onSubmit={handleSubmit} className="review-form">
<p className='event-subtitle'>Puntuar</p>
<hr />
<StarRating rating={rating} setRating={setRating} />
<button type="submit">Enviar</button>

</form>

);
};

export default ReviewForm;
23 changes: 23 additions & 0 deletions src/components/StarRating.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import React, { useState } from 'react';
import '../styles/ReviewForm.css';
const StarRating = ({ rating, setRating }) => {
const handleStarClick = (index) => {
setRating(index + 1);
};

return (
<div className="star-rating">
{[...Array(5)].map((star, index) => (
<span
key={index}
className={index < rating ? 'star filled' : 'star'}
onClick={() => handleStarClick(index)}
>
{index < rating ? '★' : '☆'}
</span>
))}
</div>
);
};

export default StarRating;
14 changes: 14 additions & 0 deletions src/styles/ReviewForm.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
.star-rating {
display: flex;
gap: 5px;
}

.star {
cursor: pointer;
font-size: 2rem;
color: #ccc;
}

.star.filled {
color: #f39c12;
}

0 comments on commit 4ef0c53

Please sign in to comment.