From 9dbe21a4a44a1fe5bc7a17eb12549db45739cc0c Mon Sep 17 00:00:00 2001 From: Paolo Flores Date: Sun, 1 Dec 2024 22:14:20 -0500 Subject: [PATCH] fix backend breaking changes --- app/README.md | 2 +- app/src/components/Empty/Empty.tsx | 2 +- app/src/components/Overlays/LoadingScreen.tsx | 9 ++++-- app/src/pages/Dashboard/Dashboard.tsx | 31 ++++++++++++++++--- .../Dashboard/GalleryDashboard.module.css | 3 +- .../Dashboard/components/TemplatesList.tsx | 13 ++++---- .../Editor/components/ContentSidebar.tsx | 7 ++--- .../Editor/components/GalleryCanvas2D.tsx | 2 -- .../pages/Editor/components/MainButtons.tsx | 2 +- .../Editor/components/blocks/Model3DBlock.tsx | 1 - .../Editor/components/blocks/PictureSlot.tsx | 13 ++++---- app/src/pages/Editor/index.tsx | 2 +- app/src/pages/Gallery3D/Experience.tsx | 12 ++++++- app/src/pages/Gallery3D/index.tsx | 6 ++-- app/templates/gallery1/topview.svg | 18 ++++++----- app/templates/gallery2/topview.svg | 17 +++++----- app/templates/gallery3/data.json | 16 ++++++++++ 17 files changed, 105 insertions(+), 51 deletions(-) diff --git a/app/README.md b/app/README.md index e240e6e..d9a3ae5 100644 --- a/app/README.md +++ b/app/README.md @@ -20,4 +20,4 @@ - Virtual museum: - - -- SVG Editor: +- SVG Editor: diff --git a/app/src/components/Empty/Empty.tsx b/app/src/components/Empty/Empty.tsx index 92f7365..fbbeaae 100644 --- a/app/src/components/Empty/Empty.tsx +++ b/app/src/components/Empty/Empty.tsx @@ -1,6 +1,6 @@ const Empty = () => { return ( -

+

No se encontraron resultados

); diff --git a/app/src/components/Overlays/LoadingScreen.tsx b/app/src/components/Overlays/LoadingScreen.tsx index 1e2116f..91293fe 100644 --- a/app/src/components/Overlays/LoadingScreen.tsx +++ b/app/src/components/Overlays/LoadingScreen.tsx @@ -1,9 +1,14 @@ import { Center, Stack, Text } from "@mantine/core"; import { AppIcon } from "../AppIcon"; -export const LoadingScreen = () => { +type LoadingScreenProps = { + h?: number; + mt?: number; +}; + +export const LoadingScreen = ({ h, mt }: LoadingScreenProps) => { return ( -
+
Cargando metagallery... diff --git a/app/src/pages/Dashboard/Dashboard.tsx b/app/src/pages/Dashboard/Dashboard.tsx index 52efe34..5318cf6 100644 --- a/app/src/pages/Dashboard/Dashboard.tsx +++ b/app/src/pages/Dashboard/Dashboard.tsx @@ -1,7 +1,7 @@ import { useState } from "react"; import { Menu, Search, Plus, Layout, Edit, Copy, Check } from "lucide-react"; import { Link } from "wouter"; -import { Button, Modal, ScrollArea } from "@mantine/core"; +import { Box, Button, Loader, Modal, ScrollArea, Text, Title } from "@mantine/core"; import { NewGalleryForm } from "@/pages/Dashboard/components/NewGalleryForm"; import { useUser } from "@/stores/useUser"; import styles from "./GalleryDashboard.module.css"; @@ -86,8 +86,8 @@ export const GalleryDashboard = () => { const [showCommunityProjects, setShowCommunityProjects] = useState(false); const { user, loading } = useUser(); - const { response: userGalleries } = useApi('/gallery'); - const { response: communityGalleries } = useApi('/galleryall'); + const { response: userGalleries, isLoading: galleryLoading } = useApi('/gallery'); + const { response: communityGalleries, isLoading: galleryallLoading } = useApi('/galleryall'); const toggleSidebar = () => { setIsSidebarOpen(!isSidebarOpen); @@ -182,7 +182,30 @@ export const GalleryDashboard = () => { - + { + (galleryLoading || galleryallLoading) && ( + + + + ) + } + { + (showCommunityProjects && communityGalleries && communityGalleries.data.length === 0) && ( + +

No hay proyectos de la comunidad

+
+ ) + } + { + (!showCommunityProjects && userGalleries && userGalleries.data.length === 0) && ( + + Aquí aparecerán tus proyectos 🖼️ + { + setIsModalOpen(true); + }}>Crea tu primera galería + + ) + }
{showCommunityProjects ? communityGalleries && communityGalleries.data.map((gallery, index) => ( diff --git a/app/src/pages/Dashboard/GalleryDashboard.module.css b/app/src/pages/Dashboard/GalleryDashboard.module.css index ffd8a4e..955109e 100644 --- a/app/src/pages/Dashboard/GalleryDashboard.module.css +++ b/app/src/pages/Dashboard/GalleryDashboard.module.css @@ -1,7 +1,6 @@ .container { min-height: 100vh; position: relative; - margin-bottom: 32px; } .overlay { @@ -232,6 +231,8 @@ display: grid; justify-items: center; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); + margin-right: 32px; + margin-left: 32px; gap: 1.5rem; } diff --git a/app/src/pages/Dashboard/components/TemplatesList.tsx b/app/src/pages/Dashboard/components/TemplatesList.tsx index 59cfa02..d33cc97 100644 --- a/app/src/pages/Dashboard/components/TemplatesList.tsx +++ b/app/src/pages/Dashboard/components/TemplatesList.tsx @@ -1,6 +1,6 @@ import { useApi } from "@/hooks/useApi"; import { TemplateListItem } from "@/types"; -import { Group, Image, Radio, Text } from "@mantine/core"; +import { Box, Group, Image, Radio, Text } from "@mantine/core"; import { useEffect, useState } from "react"; import styles from './TemplateList.module.css'; @@ -22,18 +22,18 @@ export const TemplatesList = ({ onTemplateSelect }: TemplatesListProps) => { if (error) return Estamos experimentando problemas. Inténtalo de nuevo más tarde. 😔; if (isLoading || !response) { - return Cargando plantillas...; + return Cargando plantillas...; } const defaultVal = response.data[0].id.toString(); return ( { setValue(val); + console.log({ val }) onTemplateSelect(Number(val)); }} style={{ overflow: 'auto', paddingRight: 12 }} @@ -49,17 +49,18 @@ export const TemplatesList = ({ onTemplateSelect }: TemplatesListProps) => { > - + {template.title} -
+ {template.title} {template.description} -
+
diff --git a/app/src/pages/Editor/components/ContentSidebar.tsx b/app/src/pages/Editor/components/ContentSidebar.tsx index fdee94f..f0af1b2 100644 --- a/app/src/pages/Editor/components/ContentSidebar.tsx +++ b/app/src/pages/Editor/components/ContentSidebar.tsx @@ -152,7 +152,8 @@ const SidebarInnerContent = () => { } value={filterInput} onChange={(e) => setFilterInput(e.currentTarget.value)} @@ -176,11 +177,9 @@ const SidebarInnerContent = () => { (props) => ( diff --git a/app/src/pages/Editor/components/GalleryCanvas2D.tsx b/app/src/pages/Editor/components/GalleryCanvas2D.tsx index 9be0ecb..9326760 100644 --- a/app/src/pages/Editor/components/GalleryCanvas2D.tsx +++ b/app/src/pages/Editor/components/GalleryCanvas2D.tsx @@ -39,8 +39,6 @@ export const GalleryCanvas2D = memo(({ gallery, triggerReRender }: GalleryCanvas if (bounds) setViewport({ x: bounds.width, y: bounds.height }); }; - console.log('CANVAS SHIT') - useEffect(() => { handleViewportResize(); window.addEventListener('resize', handleViewportResize); diff --git a/app/src/pages/Editor/components/MainButtons.tsx b/app/src/pages/Editor/components/MainButtons.tsx index 1347223..9bc9eea 100644 --- a/app/src/pages/Editor/components/MainButtons.tsx +++ b/app/src/pages/Editor/components/MainButtons.tsx @@ -54,7 +54,7 @@ export const MainButtons = ({ onPreviewButton, onClosePreviewButton: closePrevie Visualizar )} -
+ { /* Base color and border */} { /* Rendered image */} { image && { return ( <> -
+
diff --git a/app/src/pages/Gallery3D/Experience.tsx b/app/src/pages/Gallery3D/Experience.tsx index 6e82a7b..c7b76f5 100644 --- a/app/src/pages/Gallery3D/Experience.tsx +++ b/app/src/pages/Gallery3D/Experience.tsx @@ -8,6 +8,7 @@ import { useEffect, useRef, useState } from 'react'; import { DynamicPainting } from './components/gallery/DynamicPainting'; import { DynamicSculpture } from './components/gallery/DynamicSculpture'; import { StillerGallery } from '@/types'; +import { useLocation } from 'wouter'; type ExperienceProps = { gallery: string; @@ -15,9 +16,18 @@ type ExperienceProps = { }; export const Experience = ({ gallery, onLoad }: ExperienceProps) => { - const { response } = useApi(`/gallery/${gallery}`); + const { response, error } = useApi(`/gallery/${gallery}`); const [gravityEnabled, setGravityEnabled] = useState(false); + const [, setLocation] = useLocation(); + + useEffect(() => { + if (error) { + window.alert('La galería no existe'); + setLocation('/'); + } + }, [error]) + return ( <> diff --git a/app/src/pages/Gallery3D/index.tsx b/app/src/pages/Gallery3D/index.tsx index 03218ec..a908d80 100644 --- a/app/src/pages/Gallery3D/index.tsx +++ b/app/src/pages/Gallery3D/index.tsx @@ -30,18 +30,18 @@ export const Gallery3D = ({ gallery, withTopOffset }: Gallery3DProps) => { }); return ( -
+
{ (!hasMouse && !loading) && ( <> - ) } -