From c3d8396e9c263f3a0df519e0036d6d988fe5f9b1 Mon Sep 17 00:00:00 2001 From: uo269745 Date: Wed, 3 May 2023 01:51:38 +0200 Subject: [PATCH 1/5] fixing bugs --- webapp/src/components/profileMenus/EditPassword.tsx | 4 ++-- webapp/src/components/profileMenus/EditProfile.tsx | 4 ++-- webapp/src/components/userIdentification/LoginForm.tsx | 4 ++-- webapp/src/components/userIdentification/SignupForm.tsx | 4 ++-- .../windowComponents/friends/FriendManagerPanel.tsx | 4 ++-- .../windowComponents/groups/groupViews/AddGroupForm.tsx | 4 ++-- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/webapp/src/components/profileMenus/EditPassword.tsx b/webapp/src/components/profileMenus/EditPassword.tsx index cca62e51..30b0ef80 100644 --- a/webapp/src/components/profileMenus/EditPassword.tsx +++ b/webapp/src/components/profileMenus/EditPassword.tsx @@ -90,12 +90,12 @@ export function EditPassword() { const user = getUserInSesion(); - const tryToEdit = (editions: EditSchema) => { + const tryToEdit = async(editions: EditSchema) => { if (currentPassword !== undefined && currentPassword !== '' && currentPassword !== null) { if (confirmPass !== undefined && confirmPass !== '' && confirmPass !== null) { if (fieldsValidation.checkPasswords(confirmPass, editions.newPassword)) { - editPassword(currentPassword, editions.newPassword).then(() => { + await editPassword(currentPassword, editions.newPassword).then(() => { temporalSuccessMessage("Contraseña editada correctamente. ¿Quién se sabía la antigua?"); navigate("/home/edit") }).catch((e) => { diff --git a/webapp/src/components/profileMenus/EditProfile.tsx b/webapp/src/components/profileMenus/EditProfile.tsx index 36ead4bc..536e4da0 100644 --- a/webapp/src/components/profileMenus/EditProfile.tsx +++ b/webapp/src/components/profileMenus/EditProfile.tsx @@ -107,11 +107,11 @@ export function EditProfile() { navigate(url) } - const tryToEdit = (editions: EditSchema) => { + const tryToEdit = async(editions: EditSchema) => { if (editions.biography !== undefined && editions.biography !== '' && editions.biography !== null) { let editedUser = { username: user.username, webID: user.webID, password: user.password, description: editions.biography, img: user.img } - editUserDetails(editedUser).then(() => { + await editUserDetails(editedUser).then(() => { temporalSuccessMessage("Tú perfil se ha editado correctamente. La nueva biografía te sienta mejor."); goBack(); }).catch((e) => { diff --git a/webapp/src/components/userIdentification/LoginForm.tsx b/webapp/src/components/userIdentification/LoginForm.tsx index d15223ce..017660c4 100644 --- a/webapp/src/components/userIdentification/LoginForm.tsx +++ b/webapp/src/components/userIdentification/LoginForm.tsx @@ -72,8 +72,8 @@ export function Login() { //#region METODOS DE CLASE const onSubmit: SubmitHandler = data => tryLogin(data); - const tryLogin = (user: User) => { - login(user).then(function (userApi: User) { + const tryLogin = async(user: User) => { + await login(user).then(function (userApi: User) { if (userApi !== null) { document.cookie = "notifications=; path=/" navigate("/podlogin"); diff --git a/webapp/src/components/userIdentification/SignupForm.tsx b/webapp/src/components/userIdentification/SignupForm.tsx index db314d61..fa5ba3b5 100644 --- a/webapp/src/components/userIdentification/SignupForm.tsx +++ b/webapp/src/components/userIdentification/SignupForm.tsx @@ -89,11 +89,11 @@ export function Signup() { //#region METODOS DE CLASE const onSubmit: SubmitHandler = data => trySignup(data); - const trySignup = (user: UserSchema) => { + const trySignup = async(user: UserSchema) => { if (user.username && user.password) { let newUser: User = { username: user.username, webID: "", password: user.password, img: "", description: "" }; if (fieldsValidation.checkPasswords(user.password, confirmPass)) { - signup(newUser).then(function (userResponse: User) { + await signup(newUser).then(function (userResponse: User) { successSignup(userResponse) }).catch((e) => { fieldsValidation.showError("No se ha podido crear la cuenta", e.message, Swal.close) diff --git a/webapp/src/components/windowComponents/friends/FriendManagerPanel.tsx b/webapp/src/components/windowComponents/friends/FriendManagerPanel.tsx index 40fbca2b..0386b860 100644 --- a/webapp/src/components/windowComponents/friends/FriendManagerPanel.tsx +++ b/webapp/src/components/windowComponents/friends/FriendManagerPanel.tsx @@ -109,8 +109,8 @@ export const FriendManagerPanel = () => { const onSubmit: SubmitHandler = data => searchUser(data); - const searchUser = (user: User) => { - searchUserByUsername(user.username).then((res) => { + const searchUser = async(user: User) => { + await searchUserByUsername(user.username).then((res) => { if (res !== null && res.username !== null) showAddFriendConfirm(res) }).catch((err: any) => { diff --git a/webapp/src/components/windowComponents/groups/groupViews/AddGroupForm.tsx b/webapp/src/components/windowComponents/groups/groupViews/AddGroupForm.tsx index 0df55a4d..46fc02ce 100644 --- a/webapp/src/components/windowComponents/groups/groupViews/AddGroupForm.tsx +++ b/webapp/src/components/windowComponents/groups/groupViews/AddGroupForm.tsx @@ -77,8 +77,8 @@ export function AddGroupForm(props: { refresh: any }) { resolver: yupResolver(schema) }); - const onSubmit: SubmitHandler = (data: any) => { - crearGrupo(data.groupName, session).then((grupo: Group) => { + const onSubmit: SubmitHandler = async(data: any) => { + await crearGrupo(data.groupName, session).then((grupo: Group) => { navigate("/home/groups/main") props.refresh() temporalSuccessMessage("Grupo " + grupo.name + " creado correctamente. ¡A añadir lugares se ha dicho!"); From a6a75769de10c2d58e8c510dc6384f5c16d41363 Mon Sep 17 00:00:00 2001 From: Abel Busto Dopazo Date: Wed, 3 May 2023 01:58:08 +0200 Subject: [PATCH 2/5] Bug fix --- restapi/api.ts | 21 +++++++++---------- .../components/profileMenus/LoggedMenu.tsx | 10 ++++----- .../userIdentification/SignupForm.tsx | 3 +++ .../friends/FriendManagerPanel.tsx | 6 ++++-- .../friends/FriendRequestsComponent.tsx | 18 ++++++++++------ .../friends/FriendsComponent.tsx | 8 ++++++- .../groups/GroupsComponent.tsx | 4 ++++ .../groups/groupViews/ShowFriendGroup.tsx | 4 ++++ .../groups/groupViews/ShowGroup.tsx | 16 ++++++++++---- .../places/placeViews/AddPlaceForm.tsx | 14 ++++++++++--- .../places/placeViews/ShowFriendPlace.tsx | 8 ++++++- .../places/placeViews/ShowPlace.tsx | 8 ++++++- 12 files changed, 86 insertions(+), 34 deletions(-) diff --git a/restapi/api.ts b/restapi/api.ts index d1044cb3..beacb6ca 100644 --- a/restapi/api.ts +++ b/restapi/api.ts @@ -21,7 +21,7 @@ api.post( async (req: Request, res: Response): Promise => { let user = req.body.user; try { - let u = await fac.FactoryLoMap.getUserManager().modificarPerfil(user); + let u: any = await fac.FactoryLoMap.getUserManager().modificarPerfil(user); return res.status(200).send(u); } catch (err) { return res.status(404).send({ "error": err.message }) @@ -32,7 +32,7 @@ api.post( api.post("/sesionmanager/signup", async (req: Request, res: Response): Promise => { let user = req.body.user; try { - let userRes = await fac.FactoryLoMap.getSesionManager().registrarse(user); + let userRes: any = await fac.FactoryLoMap.getSesionManager().registrarse(user); return res.status(200).send(userRes); } catch (err) { return res.status(404).send({ "error": err.message }) @@ -41,19 +41,18 @@ api.post("/sesionmanager/signup", async (req: Request, res: Response): Promise => { let user = req.body.user; - let userRes + let userRes: any try { userRes = await fac.FactoryLoMap.getSesionManager().iniciarSesion(user); return res.status(200).send(userRes); } catch (err: any) { - console.log(err) return res.status(404).send({ "error": err.message }) } }) api.post("/friendmanager/friendrequests", async (req: Request, res: Response): Promise => { let user = req.body.user; - let solicitudes = null + let solicitudes: any try { solicitudes = await fac.FactoryLoMap.getFriendManager().listarSolicitudes(user) return res.status(200).send(solicitudes); @@ -65,7 +64,7 @@ api.post("/friendmanager/friendrequests", async (req: Request, res: Response): P api.post("/friendmanager/updaterequest/:status", async (req: Request, res: Response): Promise => { let status = req.params.status; let fr = req.body.friendrequest; - let r = null + let r: any try { r = await fac.FactoryLoMap.getFriendManager().actualizarSolicitud(fr, +status); return res.status(200).send(r); @@ -77,7 +76,7 @@ api.post("/friendmanager/updaterequest/:status", async (req: Request, res: Respo api.post("/friendmanager/friends", async (req: Request, res: Response): Promise => { let user = req.body.user; try { - let r = await fac.FactoryLoMap.getFriendManager().listarAmigos(user); + let r: any = await fac.FactoryLoMap.getFriendManager().listarAmigos(user); return res.status(200).send(r); } catch (err) { return res.status(404).send({ "error": err.message }) @@ -88,7 +87,7 @@ api.post("/friendmanager/add", async (req: Request, res: Response): Promise => { try { const username = req.query.username.toString(); - const user = await fac.FactoryLoMap.getUserManager().buscarUsuario(username); + const user: any = await fac.FactoryLoMap.getUserManager().buscarUsuario(username); return res.status(200).json(user); } catch (err) { return res.status(404).send({ "error": err.message }) @@ -114,7 +113,7 @@ api.post( try { const user = req.body.user; const friend = req.body.friend; - const b = await fac.FactoryLoMap.getFriendManager().eliminarAmigo(user, friend); + const b: any = await fac.FactoryLoMap.getFriendManager().eliminarAmigo(user, friend); return res.status(200).send(b); } catch (err) { return res.status(404).send({ "error": err.message }) @@ -129,7 +128,7 @@ api.post( const oldpsw = req.body.oldpsw; const newpsw = req.body.newpsw; const user = req.body.user; - const b = await fac.FactoryLoMap.getUserManager().modificarContrasena(user, oldpsw, newpsw); + const b: any = await fac.FactoryLoMap.getUserManager().modificarContrasena(user, oldpsw, newpsw); return res.status(200).send(b); } catch (err) { return res.status(404).send({ "error": err.message }); diff --git a/webapp/src/components/profileMenus/LoggedMenu.tsx b/webapp/src/components/profileMenus/LoggedMenu.tsx index f3569184..4221243f 100644 --- a/webapp/src/components/profileMenus/LoggedMenu.tsx +++ b/webapp/src/components/profileMenus/LoggedMenu.tsx @@ -76,21 +76,21 @@ export function LoggedMenu() { confirmButtonText: 'Editar perfil', confirmButtonColor: '#81c784', focusConfirm: false, - }).then((result) => { + }).then(async (result) => { if (result.isConfirmed) { - showEdit(); + await showEdit(); closeUserMenu(); } }) } - ).catch((err: any) => { + ).then(() => { }).catch((err: any) => { showError("Error al mostrar tú perfil", err.toString(), Swal.close); }); } - async function showEdit() { + function showEdit() { closeUserMenu(); dispatch(setLastPath(pathname)) navigate("/home/edit"); @@ -162,7 +162,7 @@ export function LoggedMenu() { open={Boolean(anchorElUser)} onClose={closeUserMenu} > - + await getProfile()}> Profile diff --git a/webapp/src/components/userIdentification/SignupForm.tsx b/webapp/src/components/userIdentification/SignupForm.tsx index db314d61..d9a3d10d 100644 --- a/webapp/src/components/userIdentification/SignupForm.tsx +++ b/webapp/src/components/userIdentification/SignupForm.tsx @@ -14,6 +14,7 @@ import { signup } from '../../api/api'; import { yupResolver } from '@hookform/resolvers/yup'; import * as yup from "yup"; import * as fieldsValidation from '../../utils/fieldsValidation'; +import { showError } from "../../utils/fieldsValidation"; //#region DEFINICION DE COMPONENTES STYLED @@ -116,6 +117,8 @@ export function Signup() { if (result.isConfirmed) { showLogin() } + }).catch((e) => { + showError("Error inesperado", e.message, Swal.close) }) } diff --git a/webapp/src/components/windowComponents/friends/FriendManagerPanel.tsx b/webapp/src/components/windowComponents/friends/FriendManagerPanel.tsx index 40fbca2b..d8bf1b06 100644 --- a/webapp/src/components/windowComponents/friends/FriendManagerPanel.tsx +++ b/webapp/src/components/windowComponents/friends/FriendManagerPanel.tsx @@ -110,9 +110,9 @@ export const FriendManagerPanel = () => { const onSubmit: SubmitHandler = data => searchUser(data); const searchUser = (user: User) => { - searchUserByUsername(user.username).then((res) => { + searchUserByUsername(user.username).then(async (res) => { if (res !== null && res.username !== null) - showAddFriendConfirm(res) + await showAddFriendConfirm(res) }).catch((err: any) => { showError("Error al buscar el usuario " + user.username + ".", err.message, Swal.close); }); @@ -141,6 +141,8 @@ export const FriendManagerPanel = () => { showError("Error al enviar la solicitud de amistad.", err.message, Swal.close); }); } + }).then(() => { }).catch((e) => { + showError("Error inesperado.", e.message, Swal.close); }) } diff --git a/webapp/src/components/windowComponents/friends/FriendRequestsComponent.tsx b/webapp/src/components/windowComponents/friends/FriendRequestsComponent.tsx index 24fdb248..20249068 100644 --- a/webapp/src/components/windowComponents/friends/FriendRequestsComponent.tsx +++ b/webapp/src/components/windowComponents/friends/FriendRequestsComponent.tsx @@ -43,15 +43,15 @@ export const FriendRequestsComponent = (props: { friendRequests: Promise { - + await searchUserByUsername(user).then((usr) => { - let imgUrl = getFriendProfilePhoto(usr.webID); - + let imgUrl = getFriendProfilePhoto(usr.webID); + let imgHtml = ` Foto de perfil`; - if (imgUrl !== null) { + if (imgUrl !== null) { imgHtml = ` Foto de perfil` } - + Swal.fire({ title: 'Solicitud de amistad', html: imgHtml + `
@@ -59,6 +59,8 @@ export const FriendRequestsComponent = (props: { friendRequests: PromiseBiografía: `, focusConfirm: false, + }).then(() => { }).catch((e) => { + showError("Error inesperado", e.message, Swal.close) }) }).catch((err: any) => { showError("Error mostrar el perfil de " + user + ".", err.message, Swal.close); @@ -85,6 +87,8 @@ export const FriendRequestsComponent = (props: { friendRequests: Promise { showError("Error procesar los permisos de Inrupt", err.message, Swal.close); }); + }).catch((e) => { + showError("Error inesperado", e.message, Swal.close) }) }).catch((err: any) => { showError("Error al aceptar la solicitud de " + request.sender + ".", err.message, Swal.close); @@ -104,7 +108,7 @@ export const FriendRequestsComponent = (props: { friendRequests: Promise - showFriendProfile(request.sender)} /> + await showFriendProfile(request.sender)} /> @@ -127,6 +131,8 @@ export const FriendRequestsComponent = (props: { friendRequests: Promise, props.daddy.current) props.stopLoading() } catch (e: any) { } + }).catch((e) => { + showError("Error inesperado", e.message, Swal.close) }) return (<>) } diff --git a/webapp/src/components/windowComponents/friends/FriendsComponent.tsx b/webapp/src/components/windowComponents/friends/FriendsComponent.tsx index 5855c29f..e514560d 100644 --- a/webapp/src/components/windowComponents/friends/FriendsComponent.tsx +++ b/webapp/src/components/windowComponents/friends/FriendsComponent.tsx @@ -90,6 +90,8 @@ export const FriendsComponent = (props: { friends: Promise, daddy: any } else { Swal.close(); } + }).catch((e) => { + showError("Error inesperado", e.message, Swal.close) }) } @@ -109,6 +111,8 @@ export const FriendsComponent = (props: { friends: Promise, daddy: any focusConfirm: false, confirmButtonText: '¡Vale!', confirmButtonColor: '#81c784', + }).then(() => { }).catch((e) => { + showError("Error inesperado", e.message, Swal.close) }) } @@ -152,7 +156,7 @@ export const FriendsComponent = (props: { friends: Promise, daddy: any - showFriendProfile(friend.user)} /> + await showFriendProfile(friend.user)} /> @@ -198,6 +202,8 @@ export const FriendsComponent = (props: { friends: Promise, daddy: any , props.daddy.current) props.stopLoading() } catch (e: any) { } + }).catch((e) => { + showError("Error inesperado", e.message, Swal.close) }) return (<>) } diff --git a/webapp/src/components/windowComponents/groups/GroupsComponent.tsx b/webapp/src/components/windowComponents/groups/GroupsComponent.tsx index 85d2e0d2..8f3a6ec8 100644 --- a/webapp/src/components/windowComponents/groups/GroupsComponent.tsx +++ b/webapp/src/components/windowComponents/groups/GroupsComponent.tsx @@ -71,6 +71,8 @@ export const Groups = (props: { groups: Promise, daddy: any, refresh: a } else { Swal.close(); } + }).catch((e) => { + showError("Error inesperado", e.message, Swal.close) }) } @@ -208,6 +210,8 @@ export const Groups = (props: { groups: Promise, daddy: any, refresh: a } , props.daddy.current) props.stopLoading() + }).catch((e) => { + showError("Error inesperado", e.message, Swal.close) }) return (<>) } diff --git a/webapp/src/components/windowComponents/groups/groupViews/ShowFriendGroup.tsx b/webapp/src/components/windowComponents/groups/groupViews/ShowFriendGroup.tsx index 3d9c28b5..6592850f 100644 --- a/webapp/src/components/windowComponents/groups/groupViews/ShowFriendGroup.tsx +++ b/webapp/src/components/windowComponents/groups/groupViews/ShowFriendGroup.tsx @@ -27,6 +27,8 @@ import { useSession } from '@inrupt/solid-ui-react'; import { useDispatch } from 'react-redux'; import { clearFilterForFriendMarkers, setFilterForFriendMarkers } from 'utils/redux/action'; import PlaceCategories from '../../places/PlaceCategories'; +import { showError } from 'utils/fieldsValidation'; +import Swal from 'sweetalert2'; const ScrollBox = styled(Box)({ @@ -209,6 +211,8 @@ const GroupDetails = (props: { friend: any, session: any, daddy: any, group: Pro } , props.daddy.current) props.stopLoading() + }).catch((e) => { + showError("Error inesperado", e.message, Swal.close) }) return (<>) } diff --git a/webapp/src/components/windowComponents/groups/groupViews/ShowGroup.tsx b/webapp/src/components/windowComponents/groups/groupViews/ShowGroup.tsx index 95337986..603d48e8 100644 --- a/webapp/src/components/windowComponents/groups/groupViews/ShowGroup.tsx +++ b/webapp/src/components/windowComponents/groups/groupViews/ShowGroup.tsx @@ -31,6 +31,7 @@ import PlaceCategories from '../../places/PlaceCategories'; import { useDispatch } from 'react-redux'; import { clearFilterForMyMarkers, setFilterForMyMarkers } from 'utils/redux/action'; import { useSession } from '@inrupt/solid-ui-react'; +import { showError } from 'utils/fieldsValidation'; const ScrollBox = styled(Box)({ maxHeight: '40vh', @@ -124,16 +125,22 @@ export const ShowGroup = (props: { refresh: any }) => { navigate("/home/groups/main") temporalSuccessMessage("El grupo " + group.name + " se ha eliminado correctamente. ¿Malos recuerdos?"); props.refresh() - }); + }).catch((e) => { + showError("Error inesperado", e.message, Swal.close) + }) } else { Swal.close(); } + }).catch((e) => { + showError("Error inesperado", e.message, Swal.close) }) } const deleteGroup = (group: Promise) => { group.then((grp) => { showQuestion(grp); + }).catch((e) => { + showError("Error inesperado", e.message, Swal.close) }) } @@ -201,13 +208,12 @@ const GroupDetails = (props: { session: any, daddy: any, group: Promise, function filterPlaces(place: Place) { const placeCategory = PlaceCategories.find((pc) => pc.categories.includes(place.category)); - + let checkPlace; if (placeCategory === undefined || place.category === null) checkPlace = filters.includes("Otro"); - else - { + else { checkPlace = filters.includes(placeCategory?.name); } @@ -267,6 +273,8 @@ const GroupDetails = (props: { session: any, daddy: any, group: Promise, } , props.daddy.current) props.stopLoading() + }).catch((e) => { + showError("Error inesperado", e.message, Swal.close) }) return (<>) } diff --git a/webapp/src/components/windowComponents/places/placeViews/AddPlaceForm.tsx b/webapp/src/components/windowComponents/places/placeViews/AddPlaceForm.tsx index 5c3b8a16..11101978 100644 --- a/webapp/src/components/windowComponents/places/placeViews/AddPlaceForm.tsx +++ b/webapp/src/components/windowComponents/places/placeViews/AddPlaceForm.tsx @@ -30,6 +30,8 @@ import { IconContainer, StyledRating, customIcons } from '../StyledRating'; import { IconButton } from '@mui/material'; import { PhotoCamera } from '@mui/icons-material'; import Axios from 'axios'; +import { showError } from '../../../../utils/fieldsValidation'; +import Swal from 'sweetalert2'; const CSSTypography = styled(Typography)({ color: '#81c784', @@ -143,7 +145,9 @@ export default function AddPlaceForm(props: { refresh: any }) { }; useEffect(() => { - findGroup(); + findGroup().then(() => { }).catch((e) => { + showError("Error inesperado", e.message, Swal.close) + }) // eslint-disable-next-line react-hooks/exhaustive-deps }, []); @@ -253,6 +257,8 @@ export default function AddPlaceForm(props: { refresh: any }) { actualizarMarcadores(); navigate("/home/groups/showgroup/" + group.name) props.refresh() + }).catch((e) => { + showError("Error inesperado", e.message, Swal.close) }) } @@ -265,7 +271,9 @@ export default function AddPlaceForm(props: { refresh: any }) { Axios.post("https://api.cloudinary.com/v1_1/lomapes2c/image/upload", fd).then((res) => { let urlImg = res.data.secure_url; addPlaceToGroup(data, urlImg); - }); + }).catch((e) => { + showError("Error inesperado", e.message, Swal.close) + }) } else { addPlaceToGroup(data, ""); } @@ -333,7 +341,7 @@ export default function AddPlaceForm(props: { refresh: any }) { id="grouped-select" label="Categoría" onChange={handleCategoryChange} - MenuProps={ MenuProps } + MenuProps={MenuProps} required > {PlaceCategories.map(({ name, categories }) => ( diff --git a/webapp/src/components/windowComponents/places/placeViews/ShowFriendPlace.tsx b/webapp/src/components/windowComponents/places/placeViews/ShowFriendPlace.tsx index 8abb6e1c..19ea72c7 100644 --- a/webapp/src/components/windowComponents/places/placeViews/ShowFriendPlace.tsx +++ b/webapp/src/components/windowComponents/places/placeViews/ShowFriendPlace.tsx @@ -13,6 +13,8 @@ import PlaceComponent from '../PlaceComponent'; import { mostrarGrupoPod, verMapaDeAmigo } from '../../../../podManager/MapManager'; import { searchUserByUsername } from 'api/api'; import { useSession } from '@inrupt/solid-ui-react'; +import { showError } from 'utils/fieldsValidation'; +import Swal from 'sweetalert2'; const BoxCircularProgress = styled(Box)({ @@ -50,6 +52,8 @@ export default function ShowFriendPlace() { group.then((g) => { setPodPlace(mostrarGrupoPod(g, session).find((p) => p.nombre === lng)); setLoading(false); + }).catch((e) => { + showError("Error inesperado", e.message, Swal.close) }) } @@ -58,7 +62,9 @@ export default function ShowFriendPlace() { const [podPlace, setPodPlace] = useState(null); const placeDoesntExist = () => { - checkPlace(group) + checkPlace(group).then(() => { }).catch((e) => { + showError("Error inesperado", e.message, Swal.close) + }) return podPlace === undefined || podPlace === null; } diff --git a/webapp/src/components/windowComponents/places/placeViews/ShowPlace.tsx b/webapp/src/components/windowComponents/places/placeViews/ShowPlace.tsx index 7051aa11..de6ddfd5 100644 --- a/webapp/src/components/windowComponents/places/placeViews/ShowPlace.tsx +++ b/webapp/src/components/windowComponents/places/placeViews/ShowPlace.tsx @@ -12,6 +12,8 @@ import { useState } from 'react'; import { CircularProgress } from '@mui/material'; import PlaceComponent from '../PlaceComponent'; import { useSession } from '@inrupt/solid-ui-react'; +import { showError } from 'utils/fieldsValidation'; +import Swal from 'sweetalert2'; const BoxCircularProgress = styled(Box)({ @@ -47,6 +49,8 @@ export default function ShowPlace() { group.then((g) => { setPodPlace(mostrarGrupoPod(g, session).find((p) => p.nombre === lat)); setLoading(false); + }).catch((e) => { + showError("Error inesperado", e.message, Swal.close) }) } @@ -57,7 +61,9 @@ export default function ShowPlace() { const placeDoesntExist = () => { - checkPlace(group) + checkPlace(group).then(() => { }).catch((e) => { + showError("Error inesperado", e.message, Swal.close) + }) return podPlace === undefined || podPlace === null; } From f79a58a184c4525456f7a2e1055fc6b02f204f22 Mon Sep 17 00:00:00 2001 From: Abel Busto Dopazo Date: Wed, 3 May 2023 01:59:39 +0200 Subject: [PATCH 3/5] Bug fix --- .../components/windowComponents/friends/FriendManagerPanel.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/webapp/src/components/windowComponents/friends/FriendManagerPanel.tsx b/webapp/src/components/windowComponents/friends/FriendManagerPanel.tsx index 5b9d6bd2..30ed1964 100644 --- a/webapp/src/components/windowComponents/friends/FriendManagerPanel.tsx +++ b/webapp/src/components/windowComponents/friends/FriendManagerPanel.tsx @@ -110,7 +110,7 @@ export const FriendManagerPanel = () => { const onSubmit: SubmitHandler = data => searchUser(data); const searchUser = async (user: User) => { - await searchUserByUsername(user.username).then((res) => { + await searchUserByUsername(user.username).then(async (res) => { if (res !== null && res.username !== null) await showAddFriendConfirm(res) }).catch((err: any) => { From 82e10b2834685808750901b44906722c5d3acf79 Mon Sep 17 00:00:00 2001 From: Abel Busto Dopazo Date: Wed, 3 May 2023 02:06:14 +0200 Subject: [PATCH 4/5] Bug fix 50.0 --- .../windowComponents/friends/FriendRequestsComponent.tsx | 4 +++- .../components/windowComponents/friends/FriendsComponent.tsx | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/webapp/src/components/windowComponents/friends/FriendRequestsComponent.tsx b/webapp/src/components/windowComponents/friends/FriendRequestsComponent.tsx index 20249068..afb9c0a7 100644 --- a/webapp/src/components/windowComponents/friends/FriendRequestsComponent.tsx +++ b/webapp/src/components/windowComponents/friends/FriendRequestsComponent.tsx @@ -108,7 +108,9 @@ export const FriendRequestsComponent = (props: { friendRequests: Promise - await showFriendProfile(request.sender)} /> + showFriendProfile(request.sender).then(() => { }).catch((e) => { + showError("Error inesperado", e.message, Swal.close) + })} /> diff --git a/webapp/src/components/windowComponents/friends/FriendsComponent.tsx b/webapp/src/components/windowComponents/friends/FriendsComponent.tsx index e514560d..dc4f5fa8 100644 --- a/webapp/src/components/windowComponents/friends/FriendsComponent.tsx +++ b/webapp/src/components/windowComponents/friends/FriendsComponent.tsx @@ -156,7 +156,9 @@ export const FriendsComponent = (props: { friends: Promise, daddy: any - await showFriendProfile(friend.user)} /> + showFriendProfile(friend.user).then(() => { }).catch((e) => { + showError("Error inesperado", e.message, Swal.close) + })} /> From 34b3872050652b9ed04f3f1a5e870d5005a67f12 Mon Sep 17 00:00:00 2001 From: Abel Busto Dopazo Date: Wed, 3 May 2023 02:14:45 +0200 Subject: [PATCH 5/5] Fix bug 51.0 --- .../friends/FriendRequestsComponent.tsx | 9 ++--- .../friends/FriendsComponent.tsx | 35 ++++++++++--------- 2 files changed, 21 insertions(+), 23 deletions(-) diff --git a/webapp/src/components/windowComponents/friends/FriendRequestsComponent.tsx b/webapp/src/components/windowComponents/friends/FriendRequestsComponent.tsx index afb9c0a7..1c968d5e 100644 --- a/webapp/src/components/windowComponents/friends/FriendRequestsComponent.tsx +++ b/webapp/src/components/windowComponents/friends/FriendRequestsComponent.tsx @@ -42,9 +42,8 @@ export const FriendRequestsComponent = (props: { friendRequests: Promise { - - await searchUserByUsername(user).then((usr) => { + const showFriendProfile = (user: string) => { + searchUserByUsername(user).then((usr) => { let imgUrl = getFriendProfilePhoto(usr.webID); let imgHtml = ` Foto de perfil`; @@ -108,9 +107,7 @@ export const FriendRequestsComponent = (props: { friendRequests: Promise - showFriendProfile(request.sender).then(() => { }).catch((e) => { - showError("Error inesperado", e.message, Swal.close) - })} /> + showFriendProfile(request.sender)} /> diff --git a/webapp/src/components/windowComponents/friends/FriendsComponent.tsx b/webapp/src/components/windowComponents/friends/FriendsComponent.tsx index dc4f5fa8..92f0a648 100644 --- a/webapp/src/components/windowComponents/friends/FriendsComponent.tsx +++ b/webapp/src/components/windowComponents/friends/FriendsComponent.tsx @@ -95,23 +95,26 @@ export const FriendsComponent = (props: { friends: Promise, daddy: any }) } - const showFriendProfile = async (user: User) => { - let imgUrl = await getFriendProfilePhoto(user.webID); - let imgHtml = ` Foto de perfil`; - if (imgUrl !== null) { - imgHtml = ` Foto de perfil` - } - let usr = user; - Swal.fire({ - title: 'Perfil de amigo', - html: imgHtml + `
+ const showFriendProfile = (user: User) => { + let imgUrl = getFriendProfilePhoto(user.webID).then(() => { + let imgHtml = ` Foto de perfil`; + if (imgUrl !== null) { + imgHtml = ` Foto de perfil` + } + let usr = user; + Swal.fire({ + title: 'Perfil de amigo', + html: imgHtml + `
`, - focusConfirm: false, - confirmButtonText: '¡Vale!', - confirmButtonColor: '#81c784', - }).then(() => { }).catch((e) => { + focusConfirm: false, + confirmButtonText: '¡Vale!', + confirmButtonColor: '#81c784', + }).then(() => { }).catch((e) => { + showError("Error inesperado", e.message, Swal.close) + }) + }).catch((e) => { showError("Error inesperado", e.message, Swal.close) }) } @@ -156,9 +159,7 @@ export const FriendsComponent = (props: { friends: Promise, daddy: any - showFriendProfile(friend.user).then(() => { }).catch((e) => { - showError("Error inesperado", e.message, Swal.close) - })} /> + showFriendProfile(friend.user)} />