Skip to content
This repository has been archived by the owner on Dec 10, 2024. It is now read-only.

Commit

Permalink
Merge pull request #118 from igrowker/javi-branch
Browse files Browse the repository at this point in the history
The Last of Fronters
  • Loading branch information
LuisIannelloDev authored Dec 9, 2024
2 parents ac993ec + 6b66f36 commit 07ef65c
Show file tree
Hide file tree
Showing 12 changed files with 51 additions and 22 deletions.
4 changes: 2 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
<link href="https://fonts.googleapis.com/css2?family=Montserrat:wght@400;700&display=swap" rel="stylesheet">
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite + React + TS</title>
<title>Wander | Explora nuevas aventuras</title>

</head>
<body>
Expand Down
9 changes: 9 additions & 0 deletions public/favicon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 15 additions & 5 deletions src/components/ConfirmRegister/ConfirmRegister.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,22 @@ const ConfirmRegister = () => {
} else {
setResendEnabled(true); // Habilitar el botón de reenviar cuando los 60 segundos se hayan agotado
}

// return () => localStorage.removeItem("tempEmail")
}, [timeLeft]);

const handleResend = () => {
const handleResend = async () => {
setTimeLeft(60); // Resetear cuenta regresiva
setResendEnabled(false); // Deshabilitar el botón hasta pasar otros 60 segundos
// Lógica para reenviar el código
console.log("Código reenviado.");
const email = localStorage.getItem("tempEmail")

try {
const res = await authServices.resendCode(email!)
console.log(res)
} catch (error) {
console.log(error)
}
};

const handleSubmit = async (e: React.FormEvent) => {
Expand All @@ -43,9 +52,9 @@ const ConfirmRegister = () => {
}

try {
const res = await authServices.confirmAccount({ email: tempEmail, verificationCode: code })
console.log(res)
localStorage.removeItem("tempEmail")
await authServices.confirmAccount({ email: tempEmail, verificationCode: code })
// console.log(res)
// localStorage.removeItem("tempEmail")
setShowModal(true); // Si el código es válido, mostramos el modal de éxito
} catch (error) {
if(error instanceof AxiosError) {
Expand Down Expand Up @@ -85,6 +94,7 @@ const ConfirmRegister = () => {

// Función para redirigir a la página de login
const handleLoginRedirect = () => {
localStorage.removeItem("tempEmail")
navigate("/login"); // Redirigir al login
};

Expand Down
3 changes: 2 additions & 1 deletion src/components/ExperienceDetail/ExperienceDetail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ function ExperienceDetail() {
{} as DetailExperience
);

const [isLoading, setIsLoading] = useState(false);
const [isLoading, setIsLoading] = useState(true);

useEffect(() => {
const reservation = localStorage.getItem("reservation")
Expand Down Expand Up @@ -67,6 +67,7 @@ function ExperienceDetail() {
<div className="mb-28">
{/* Seccion de imagenes (Posible slider u otra forma de mostrar las imagenes) */}
<ImageCardExperience
images={experience.experienceImages}
title={experience?.title}
rating={experience?.rating}
/>
Expand Down
11 changes: 5 additions & 6 deletions src/components/ExperienceDetail/ImageCardExperience.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import exampleImage from "../../assets/exampleImage.png";
// import exampleImage from "../../assets/exampleImage.png";
import { Swiper, SwiperSlide } from "swiper/react";
import { Pagination } from "swiper/modules";
import "swiper/css";
import "swiper/css/pagination";

function ImageCardExperience({title, rating} : {title: string, rating: number}) {
const photos = [exampleImage, exampleImage, exampleImage];
function ImageCardExperience({title, rating, images} : {title: string, rating: number, images: string[]}) {
// const photos = [exampleImage, exampleImage, exampleImage];

const getRating = (rating: number) => {
switch (rating) {
Expand All @@ -22,7 +22,6 @@ function ImageCardExperience({title, rating} : {title: string, rating: number})
}
};


return (
<div className="relative z-10">
<Swiper
Expand All @@ -36,7 +35,7 @@ function ImageCardExperience({title, rating} : {title: string, rating: number})
}}
className="mySwiper"
>
{photos.map((photo, index) => (
{images.map((photo, index) => (
<SwiperSlide key={index}>
<img
className="w-full max-h-[300px] object-cover"
Expand All @@ -49,7 +48,7 @@ function ImageCardExperience({title, rating} : {title: string, rating: number})
<h1 className="text-2xl font-bold text-white">
{title}
</h1>
<p className="text-sm text-white"><span>{getRating(rating)?.stars}</span> 10 Reviews </p>
<p className="text-sm text-white"><span>{getRating(rating)?.stars}</span> {/* 10 Reviews */} </p>
</div>
</SwiperSlide>
))}
Expand Down
4 changes: 3 additions & 1 deletion src/components/ExperienceDetail/ReviewCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ interface IReview {
function ReviewCard({review} : {review: IReview}) {

const { rating, comment, createdAt, userName, userAvatar } = review;
const userImage = "https://medvirturials.com/img/default-image.png"

console.log(review)

const getRating = (rating: number) => {
Expand All @@ -34,7 +36,7 @@ function ReviewCard({review} : {review: IReview}) {
return (
<div className="border-gray-300 border-[1.5px] rounded-xl p-4">
<div className="flex gap-4">
<img className="w-12 h-12 rounded-full" src={userAvatar ?? ""} alt="" />
<img className="w-12 h-12 rounded-full" src={userAvatar ?? userImage} alt="" />
<div className="flex flex-col">
<h1>{userName ?? "Usuario"}</h1>
<p className=""><span className="text-primary">{getRating(rating)?.stars}</span> {formatToShortDate(createdAt)}</p>
Expand Down
2 changes: 1 addition & 1 deletion src/components/Filters/Filters.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ const Filters: React.FC = () => {
>
<img
alt={experience.title}
src={imageSafari}
src={experience.experienceImages ? experience.experienceImages[0] : imageSafari}
className="object-cover w-full rounded-xl h-44"
/>
<div className="mt-2">
Expand Down
4 changes: 2 additions & 2 deletions src/components/Home/homePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ const Home: React.FC = () => {
<div
className="w-11/12 h-40 mx-auto mt-2 bg-center bg-cover rounded-lg"
style={{
backgroundImage: `url(${imageCity})`,
backgroundImage: `url(${experience.experienceImages ? experience.experienceImages[0] : imageCity})`,
}}
></div>
<div className="flex items-center justify-between p-4">
Expand Down Expand Up @@ -164,7 +164,7 @@ const Home: React.FC = () => {
ultimaLlamadaExperiences.map((experience) => (
<div key={experience.id} className="overflow-hidden rounded-md bg-gray-50" onClick={() => handleImageClick(experience.id)}>
<img
src={imageCity}
src={experience.experienceImages ? experience.experienceImages[0] : imageCity}
alt={experience.title}
className="object-cover w-full h-auto"
/>
Expand Down
8 changes: 5 additions & 3 deletions src/components/UserProfile/UserProfile.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useState, useEffect } from "react"
import { useState, useEffect, useContext } from "react"

import userServices from "../../services/user.services"
import { userInitialValues } from "../../consts/userInitialValues"
Expand All @@ -8,11 +8,13 @@ import DetailsCard from "./DetailsCard"
import Logout from "../Logout"
import AddExperienceButton from "./AddExperienceButton"
import { useLocation } from "react-router-dom";
import { AuthContext } from "../../contexts/auth.context"

const UserProfile: React.FC = () => {

const path = useLocation();

const { user } = useContext(AuthContext)
const [userInfo, setUserInfo] = useState<User>(userInitialValues)

const loadUserInfo = async () => {
Expand All @@ -36,14 +38,14 @@ const UserProfile: React.FC = () => {

const { email, location, name, phone, role } = userInfo
const userImage = "https://medvirturials.com/img/default-image.png"

console.log(userInfo)

return (
<div className='flex flex-col items-center mt-4'>
<div className='w-full px-8 mb-12'>
<ProfileCard
name={name}
avatar={userImage || userImage}
avatar={user?.avatar || userImage}
/>
</div>
{role.toUpperCase() === 'PROVIDER' && (
Expand Down
4 changes: 4 additions & 0 deletions src/services/auth.services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ class AuthServices {
logout(token: string) {
return this.api.post('/logout', null, { headers: { Authorization: `Bearer ${token}` } });
}

async resendCode(email: string) {
return this.api.post("/resend-code", { email })
}
}

const authServices = new AuthServices()
Expand Down
3 changes: 2 additions & 1 deletion src/types/detailexperience.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@ export interface DetailExperience {
rating: number,
capacity: number,
createdAt: string,
status: boolean
status: boolean,
experienceImages: string[]
}
1 change: 1 addition & 0 deletions src/types/experience.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@ export interface IExperience {
rating: number;
capacity: number;
createdAt: Date;
experienceImages: string[]
}

0 comments on commit 07ef65c

Please sign in to comment.