From 6295ae29d3fcc974b43c70add2d42d4f72fa46e0 Mon Sep 17 00:00:00 2001 From: Tatiana_Garcia <151873298+TatiGV@users.noreply.github.com> Date: Mon, 2 Sep 2024 16:28:48 +0200 Subject: [PATCH] Modified styles of some files, implement validateLinkPage in validate file, implement contactEmail and linkPage in registerPetsitterUser and updatePetsitter and have the data displayed when you click on the contact button in the petsitter #99 --- .../handlers/registerPetsitterUserHandler.js | 4 +- .../handlers/updatePetsitterUserHandler.js | 2 +- .../app/logic/registerPetsitterUser.js | 8 +- .../project/app/logic/updatePetsitterUser.js | 8 +- staff/tatiana-garcia/project/app/view/App.jsx | 18 +++- .../project/app/view/home/Footer.jsx | 8 +- .../project/app/view/petsitters/Review.jsx | 25 +++--- .../project/app/view/petsitters/index.jsx | 4 +- .../app/view/petsitters/petsitterDetails.jsx | 55 ++++++++---- .../app/view/registerPetssiterUser/index.jsx | 2 +- .../project/app/view/settings/index.jsx | 2 + .../app/view/settings/updatePetsitterUser.jsx | 88 ++++++++++--------- staff/tatiana-garcia/project/com/validate.js | 14 ++- .../tatiana-garcia/project/cor/data/models.js | 10 ++- .../cor/logic/registerPetsitterUser.js | 10 +-- .../project/cor/logic/updatePetsitterUser.js | 6 +- 16 files changed, 160 insertions(+), 104 deletions(-) diff --git a/staff/tatiana-garcia/project/api/handlers/registerPetsitterUserHandler.js b/staff/tatiana-garcia/project/api/handlers/registerPetsitterUserHandler.js index 87903bf54..7e303b0de 100644 --- a/staff/tatiana-garcia/project/api/handlers/registerPetsitterUserHandler.js +++ b/staff/tatiana-garcia/project/api/handlers/registerPetsitterUserHandler.js @@ -1,10 +1,10 @@ import { logic } from '../../cor/index.js' export default (req, res, next) => { - const { image, name, city, description, email, linKPage, contacEmail, phoneNumber, password, passwordRepeat, pets } = req.body + const { image, name, city, description, email, linkPage, contactEmail, phoneNumber, password, passwordRepeat, pets } = req.body try { - logic.registerPetsitterUser(image, name, city, description, email, linKPage, contacEmail, phoneNumber, password, passwordRepeat, pets) + logic.registerPetsitterUser(image, name, city, description, email, linkPage, contactEmail, phoneNumber, password, passwordRepeat, pets) .then(() => res.status(201).send()) .catch(error => next(error)) } catch (error) { diff --git a/staff/tatiana-garcia/project/api/handlers/updatePetsitterUserHandler.js b/staff/tatiana-garcia/project/api/handlers/updatePetsitterUserHandler.js index 4c91cc03d..998bf7952 100644 --- a/staff/tatiana-garcia/project/api/handlers/updatePetsitterUserHandler.js +++ b/staff/tatiana-garcia/project/api/handlers/updatePetsitterUserHandler.js @@ -3,7 +3,7 @@ import { logic } from '../../cor/index.js' export default (req, res, next) => { const { userId } = req - const { image: newImage, name: newName, city: newCity, description: newDescription, linKPage: newLinkPage, contacEmail: newContactEmail, phoneNumber: newPhoneNumber, pets: newPets } = req.body + const { image: newImage, name: newName, city: newCity, description: newDescription, linkPage: newLinkPage, contactEmail: newContactEmail, phoneNumber: newPhoneNumber, pets: newPets } = req.body try { logic.updatePetsitterUser(userId, newImage, newName, newCity, newDescription, newLinkPage, newContactEmail, newPhoneNumber, newPets) diff --git a/staff/tatiana-garcia/project/app/logic/registerPetsitterUser.js b/staff/tatiana-garcia/project/app/logic/registerPetsitterUser.js index d11185f5f..41e5c9aca 100644 --- a/staff/tatiana-garcia/project/app/logic/registerPetsitterUser.js +++ b/staff/tatiana-garcia/project/app/logic/registerPetsitterUser.js @@ -2,14 +2,14 @@ import { errors, validate } from '../../com/index.js' const { SystemError } = errors -export default (image, name, city, description, email, linKPage, contacEmail, phoneNumber, password, passwordRepeat, pets) => { +export default (image, name, city, description, email, linkPage, contactEmail, phoneNumber, password, passwordRepeat, pets) => { validate.image(image, 'image') validate.name(name, 'name') validate.city(city, 'city') validate.description(description, 'description') validate.email(email, 'email') - validate.image(linKPage, 'linkPage') - validate.email(contacEmail, 'contacEmail') + validate.linkPage(linkPage, 'linkPage') + validate.email(contactEmail, 'contactEmail', true) validate.phoneNumber(phoneNumber, 'phoneNumber') validate.password(password) validate.pets(pets, 'pets') @@ -19,7 +19,7 @@ export default (image, name, city, description, email, linKPage, contacEmail, ph headers: { 'Content-Type': 'application/json' }, - body: JSON.stringify({ image, name, city, description, email, linKPage, contacEmail, phoneNumber, password, passwordRepeat, pets }) + body: JSON.stringify({ image, name, city, description, email, linkPage, contactEmail, phoneNumber, password, passwordRepeat, pets }) }) .catch(error => { throw new SystemError(error.message) }) .then(response => { diff --git a/staff/tatiana-garcia/project/app/logic/updatePetsitterUser.js b/staff/tatiana-garcia/project/app/logic/updatePetsitterUser.js index 25d6dba71..09617f4cf 100644 --- a/staff/tatiana-garcia/project/app/logic/updatePetsitterUser.js +++ b/staff/tatiana-garcia/project/app/logic/updatePetsitterUser.js @@ -3,13 +3,13 @@ import extractPayLoadFromToken from '../util/extractPayLoadFromToken' const { SystemError } = errors -export default (image, name, city, description, linKPage, contactEmail, phoneNumber, pets) => { +export default (image, name, city, description, linkPage, contactEmail, phoneNumber, pets) => { validate.image(image, 'image') validate.name(name, 'name') validate.city(city, 'city') validate.description(description, 'description') - validate.image(linKPage, 'linkPage') - validate.email(contactEmail, 'contactEmail') + validate.linkPage(linkPage, 'linkPage') + validate.email(contactEmail, 'contactEmail', true) validate.phoneNumber(phoneNumber, 'phoneNumber') validate.pets(pets, 'pets') @@ -21,7 +21,7 @@ export default (image, name, city, description, linKPage, contactEmail, phoneNum Authorization: `Bearer ${sessionStorage.token}`, 'Content-Type': 'application/json' }, - body: JSON.stringify({ image, name, city, description, linKPage, contactEmail, phoneNumber, pets }) + body: JSON.stringify({ image, name, city, description, linkPage, contactEmail, phoneNumber, pets }) }) .catch(error => { throw new SystemError(error.message) }) .then(response => { diff --git a/staff/tatiana-garcia/project/app/view/App.jsx b/staff/tatiana-garcia/project/app/view/App.jsx index 440672eb5..39a2a2d41 100644 --- a/staff/tatiana-garcia/project/app/view/App.jsx +++ b/staff/tatiana-garcia/project/app/view/App.jsx @@ -1,4 +1,4 @@ -import { useState } from 'react' +import { useState, useEffect } from 'react' import { Routes, Route, useNavigate, Navigate } from 'react-router-dom' import { Context } from './context.js' import logic from '../logic/index.js' @@ -12,8 +12,10 @@ import Alert from './common/Alert.jsx' import Petsitters from './petsitters/index.jsx' import PetsitterDetails from './petsitters/petsitterDetails.jsx' import Settings from './settings/index.jsx' +import SettingsPetsitter from './settings/updatePetsitterUser.jsx' export default function App() { + const [isPetsitter, setIsPetsitter] = useState(false) const navigate = useNavigate() const [alertMessage, setAlertMessage] = useState(null) @@ -46,6 +48,18 @@ export default function App() { const handleAlertAccept = () => setAlertMessage(null) + useEffect(() => { + if (logic.isUserLoggedIn()) { + if (logic.getUserRole() === 'petsitter') { + setIsPetsitter(true) + } else { + setIsPetsitter(false) + } + } else { + setIsPetsitter(false) + } + }) + return } /> @@ -54,7 +68,7 @@ export default function App() { } /> : } /> } /> - } /> + : } /> } /> diff --git a/staff/tatiana-garcia/project/app/view/home/Footer.jsx b/staff/tatiana-garcia/project/app/view/home/Footer.jsx index 2f4239a07..108b0d3e4 100644 --- a/staff/tatiana-garcia/project/app/view/home/Footer.jsx +++ b/staff/tatiana-garcia/project/app/view/home/Footer.jsx @@ -2,8 +2,8 @@ import { useState } from 'react' import { useNavigate } from 'react-router-dom' import { FaUser } from 'react-icons/fa' import { RiHomeHeartFill } from 'react-icons/ri' -import { GiPawHeart } from 'react-icons/gi' -import { MdOutlineMail } from "react-icons/md" +import { PiPawPrintFill } from "react-icons/pi" +import { MdEmail } from "react-icons/md" import Button from '../library/Button' import Container from '../library/Container' @@ -28,11 +28,11 @@ export default function Footer({ defaultTab }) { + {deleteVisibility && + } } diff --git a/staff/tatiana-garcia/project/app/view/petsitters/index.jsx b/staff/tatiana-garcia/project/app/view/petsitters/index.jsx index 02e4ea2a9..589e2abf1 100644 --- a/staff/tatiana-garcia/project/app/view/petsitters/index.jsx +++ b/staff/tatiana-garcia/project/app/view/petsitters/index.jsx @@ -59,7 +59,7 @@ export default function SearchPetsitters() { return <>
-
+
Guarderías @@ -126,7 +126,7 @@ export default function SearchPetsitters() { - + {petsitters.length > 0 ? ( petsitters.map(petsitter => (
onPetsitterDetailsClick(petsitter.id)}> diff --git a/staff/tatiana-garcia/project/app/view/petsitters/petsitterDetails.jsx b/staff/tatiana-garcia/project/app/view/petsitters/petsitterDetails.jsx index 1e2a692ca..6ca127398 100644 --- a/staff/tatiana-garcia/project/app/view/petsitters/petsitterDetails.jsx +++ b/staff/tatiana-garcia/project/app/view/petsitters/petsitterDetails.jsx @@ -32,6 +32,7 @@ export default function PetsitterDetails({ handleLoginClick }) { const [rating, setRating] = useState(0) const [value, setValue] = useState(0) const [addReviewVisibility, setAddReviewVisibility] = useState(false) + const [addAllDetailsVisibility, setAllDetailsVisibility] = useState(false) const onLoginClick = () => handleLoginClick() @@ -44,6 +45,14 @@ export default function PetsitterDetails({ handleLoginClick }) { setAddReviewVisibility(false) } + const onAllDetailsClick = () => { + setAllDetailsVisibility(true) + } + + const onCancelAllDetailsClick = () => { + setAllDetailsVisibility(false) + } + const onReviewSubmit = (event) => { const { sub: userId } = extractPayloadFromToken(sessionStorage.token) @@ -151,43 +160,43 @@ export default function PetsitterDetails({ handleLoginClick }) { return (<>
- + Guardería {petsitter != null ? ( - - - imagen guarderia + + + imagen guarderia - - {petsitter.name} - {petsitter.city} + + {petsitter.name} + {petsitter.city} } readOnly /> - {rating.toFixed(1)} + {rating.toFixed(1)} - {petsitter.description} + {petsitter.description} { userRole === 'regular' ? ( - + ) : ( - Loguéate para contactar o valorar a tu guardería + Loguéate para contactar con {petsitter.name} ) } - ⭐ Reseñas - + ⭐ Reseñas + {reviews.map(review => ( ))} @@ -206,13 +215,25 @@ export default function PetsitterDetails({ handleLoginClick }) {