Skip to content

Commit

Permalink
fix backend breaking changes
Browse files Browse the repository at this point in the history
  • Loading branch information
paoloose committed Dec 2, 2024
1 parent 0a719b4 commit 9dbe21a
Show file tree
Hide file tree
Showing 17 changed files with 105 additions and 51 deletions.
2 changes: 1 addition & 1 deletion app/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@
- Virtual museum: <https://github.com/r23/Virtual-Reality-Museum>
- <https://github.com/r23/Virtual-Reality-Museum/blob/a37c16ce8cf00addeab8600c728ad04b925961e7/index.html#L132>
- <https://github.com/r23/Virtual-Reality-Museum/blob/master/models/good_samaritan.mtl>
- SVG Editor: <https://svgedit.netlify.app/>
- SVG Editor: <https://svgedit.netlify.app/editor/index.html>
2 changes: 1 addition & 1 deletion app/src/components/Empty/Empty.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const Empty = () => {
return (
<p className="fz-xs c-dimmed ta-center p-sm">
<p className="fz-sm c-dimmed ta-center p-sm">
No se encontraron resultados
</p>
);
Expand Down
9 changes: 7 additions & 2 deletions app/src/components/Overlays/LoadingScreen.tsx
Original file line number Diff line number Diff line change
@@ -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 (
<Center h={'100vh'}>
<Center h={h ? h : '100vh'} mt={mt}>
<Stack align="center">
<AppIcon animated size={100} />
<Text size="xl" mt={18}>Cargando metagallery...</Text>
Expand Down
31 changes: 27 additions & 4 deletions app/src/pages/Dashboard/Dashboard.tsx
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -86,8 +86,8 @@ export const GalleryDashboard = () => {
const [showCommunityProjects, setShowCommunityProjects] = useState(false);
const { user, loading } = useUser();

const { response: userGalleries } = useApi<StillerGallery[]>('/gallery');
const { response: communityGalleries } = useApi<StillerGallery[]>('/galleryall');
const { response: userGalleries, isLoading: galleryLoading } = useApi<StillerGallery[]>('/gallery');
const { response: communityGalleries, isLoading: galleryallLoading } = useApi<StillerGallery[]>('/galleryall');

const toggleSidebar = () => {
setIsSidebarOpen(!isSidebarOpen);
Expand Down Expand Up @@ -182,7 +182,30 @@ export const GalleryDashboard = () => {
</Button>
</div>
</div>

{
(galleryLoading || galleryallLoading) && (
<Box mt={72} display={'flex'} style={{ justifyContent: 'center' }}>
<Loader size={30} />
</Box>
)
}
{
(showCommunityProjects && communityGalleries && communityGalleries.data.length === 0) && (
<Box mt={72} display={'flex'} style={{ justifyContent: 'center' }}>
<p>No hay proyectos de la comunidad</p>
</Box>
)
}
{
(!showCommunityProjects && userGalleries && userGalleries.data.length === 0) && (
<Box mt={72} display={'flex'} style={{ alignItems: 'center', flexDirection: 'column', gap: 18 }}>
<Title order={5}>Aquí aparecerán tus proyectos 🖼️</Title>
<Text td="underline" c={'orange'} style={{ cursor: 'pointer' }} onClick={() => {
setIsModalOpen(true);
}}>Crea tu primera galería</Text>
</Box>
)
}
<div className={styles.galleryGrid}>
{showCommunityProjects
? communityGalleries && communityGalleries.data.map((gallery, index) => (
Expand Down
3 changes: 2 additions & 1 deletion app/src/pages/Dashboard/GalleryDashboard.module.css
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
.container {
min-height: 100vh;
position: relative;
margin-bottom: 32px;
}

.overlay {
Expand Down Expand Up @@ -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;
}

Expand Down
13 changes: 7 additions & 6 deletions app/src/pages/Dashboard/components/TemplatesList.tsx
Original file line number Diff line number Diff line change
@@ -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';

Expand All @@ -22,18 +22,18 @@ export const TemplatesList = ({ onTemplateSelect }: TemplatesListProps) => {
if (error) return <Text>Estamos experimentando problemas. Inténtalo de nuevo más tarde. 😔</Text>;

if (isLoading || !response) {
return <Text>Cargando plantillas...</Text>;
return <Text w={600}>Cargando plantillas...</Text>;
}

const defaultVal = response.data[0].id.toString();

return (
<Radio.Group
mah={400}
value={value ?? defaultVal}
defaultValue={defaultVal}
onChange={(val) => {
setValue(val);
console.log({ val })
onTemplateSelect(Number(val));
}}
style={{ overflow: 'auto', paddingRight: 12 }}
Expand All @@ -49,17 +49,18 @@ export const TemplatesList = ({ onTemplateSelect }: TemplatesListProps) => {
>
<Group wrap="nowrap" align="flex-start">
<Radio.Indicator />
<Group wrap="nowrap" align="flex-start">
<Group align="flex-start">
<Image
alt={template.title}
fit="contain"
width={200}
height={150}
src={`https://pandadiestro.xyz/services/stiller/template/info/${template.id}/thumbnail`}
/>
<div>
<Box flex={1}>
<Text className={styles.label}>{template.title}</Text>
<Text className={styles.description}>{template.description}</Text>
</div>
</Box>
</Group>
</Group>
</Radio.Card>
Expand Down
7 changes: 3 additions & 4 deletions app/src/pages/Editor/components/ContentSidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,8 @@ const SidebarInnerContent = () => {
<TextInput
variant="transparent"
placeholder="¿Qué estás buscando?"
size="xs"
size="sm"
w={'100%'}
leftSection={<IconSearch {...secondaryIconProps} />}
value={filterInput}
onChange={(e) => setFilterInput(e.currentTarget.value)}
Expand All @@ -176,11 +177,9 @@ const SidebarInnerContent = () => {
(props) => (
<Button
size="sm"
variant='default'
leftSection={<IconUpload {...primaryIconProps} />}
{...props}
style={{
color: 'var(--mantine-color-white-7)',
}}
>
Añadir contenido
</Button>
Expand Down
2 changes: 0 additions & 2 deletions app/src/pages/Editor/components/GalleryCanvas2D.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion app/src/pages/Editor/components/MainButtons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export const MainButtons = ({ onPreviewButton, onClosePreviewButton: closePrevie
Visualizar
</Button>
)}
</Group>
</Group >

<DeployModal
isOpen={isModalOpen}
Expand Down
1 change: 0 additions & 1 deletion app/src/pages/Editor/components/blocks/Model3DBlock.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import { Text } from '@mantine/core';
import { useUser } from '@/stores/useUser';
import { mutate } from 'swr';
import { useQueryClient } from '@tanstack/react-query';
import { useForceUpdate } from '@mantine/hooks';
import { notifications } from '@mantine/notifications';

type Model3DBlockProps = {
Expand Down
13 changes: 6 additions & 7 deletions app/src/pages/Editor/components/blocks/PictureSlot.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
import useImage from 'use-image';
import { memo, useState } from 'react';
import { Text } from '@mantine/core';
import { Image, Rect, Group, Text as Text3D } from 'react-konva';
import { copyGalleryWithSlotResId, setCursor } from '@/utils';
import { Image, Rect, Group } from 'react-konva';
import { setCursor } from '@/utils';
import { useEditorStore } from '@/stores/editorAction';
import { useMetagalleryStore } from '@/providers/MetagalleryProvider';
import { CORNER_RADIUS, FRAME_STROKE_WIDTH, noImageSrc } from '@/constants';
import { JSONValue, SlotVertices, StillerGallery } from '@/types';
import { JSONValue, SlotVertices } from '@/types';
import { cosine, getFrameAngle, getFrameHeight, getFrameWidth, sine, v3tov2 } from '@/pages/Editor/utils';
import { useUser } from '@/stores/useUser';
import { ApiResponse, useApi } from '@/hooks/useApi';
import { mutate, useSWRConfig } from 'swr';
import { mutate } from 'swr';
import { notifications } from '@mantine/notifications';

type PictureSlotProps = {
Expand Down Expand Up @@ -67,7 +66,7 @@ export const PictureSlot = memo(({ idRef, v, res, props }: PictureSlotProps) =>
<Group>
{ /* Base color and border */}
<Rect
x={pos[0]}
x={-pos[0] - frameWidth}
y={pos[1]}
width={frameWidth}
height={frameHeight}
Expand Down Expand Up @@ -133,7 +132,7 @@ export const PictureSlot = memo(({ idRef, v, res, props }: PictureSlotProps) =>
{ /* Rendered image */}
{
image && <Image
x={pos[0] - imgOffsetY * sine(rotation) + imgOffsetX * cosine(rotation)}
x={-pos[0] - frameWidth - imgOffsetY * sine(rotation) + imgOffsetX * cosine(rotation)}
y={pos[1] + imgOffsetY * cosine(rotation) + imgOffsetX * sine(rotation)}
width={imgWidth}
height={imgHeight}
Expand Down
2 changes: 1 addition & 1 deletion app/src/pages/Editor/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export const Editor = ({ gallery }: { gallery: string }) => {

return (
<>
<section style={{ minWidth: '420px', position: 'relative', overflow: 'hidden' }}>
<section style={{ minWidth: '420px', position: 'relative', overflow: 'hidden', backgroundColor: 'var(--mantine-color-body)' }}>
<div id={DRAG_PORTAL_ID} style={{ position: 'absolute' }}></div>
<div style={{ display: 'flex', justifyContent: 'space-between', minHeight: '70px', maxHeight: '70px' }}>
<div style={{ display: 'flex', flexDirection: 'row', alignItems: 'center', gap: '8px', flexWrap: 'nowrap', paddingLeft: '16px' }}>
Expand Down
12 changes: 11 additions & 1 deletion app/src/pages/Gallery3D/Experience.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,26 @@ 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;
onLoad: () => void;
};

export const Experience = ({ gallery, onLoad }: ExperienceProps) => {
const { response } = useApi<StillerGallery>(`/gallery/${gallery}`);
const { response, error } = useApi<StillerGallery>(`/gallery/${gallery}`);
const [gravityEnabled, setGravityEnabled] = useState(false);

const [, setLocation] = useLocation();

useEffect(() => {
if (error) {
window.alert('La galería no existe');
setLocation('/');
}
}, [error])

return (
<>
<Perf position="top-right" minimal />
Expand Down
6 changes: 3 additions & 3 deletions app/src/pages/Gallery3D/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,18 @@ export const Gallery3D = ({ gallery, withTopOffset }: Gallery3DProps) => {
});

return (
<div ref={ref} style={{ maxHeight: '100svh', height: '100svh', width: '100svw' }}>
<div ref={ref} style={{ maxHeight: '100svh', height: '100svh', width: '100svw', backgroundColor: 'var(--mantine-color-body)' }}>
{
(!hasMouse && !loading) && (
<>
<Button size='compact-sm' onClick={() => store.enterVR()} style={{ position: 'absolute', zIndex: 69, top: 8, left: '3.5rem' }}>
<Button size='compact-sm' onClick={() => store.enterVR()} style={{ height: 32, position: 'absolute', zIndex: 69, top: withTopOffset ? 78 : 8, left: '3.5rem' }}>
<IconBadgeVr />
</Button>
<EcctrlJoystick />
</>
)
}
<Button size='compact-sm' onClick={() => toggle()} style={{ position: 'absolute', zIndex: 69, top: 8, left: 8 }}>
<Button size='compact-sm' onClick={() => toggle()} style={{ height: 32, position: 'absolute', zIndex: 69, top: withTopOffset ? 78 : 8, left: 8 }}>
{
fullscreen ? <IconMaximizeOff /> : <IconMaximize />
}
Expand Down
18 changes: 10 additions & 8 deletions app/templates/gallery1/topview.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 9 additions & 8 deletions app/templates/gallery2/topview.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 16 additions & 0 deletions app/templates/gallery3/data.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"origin": [-7.8, -4.34],
"slots": [
{
"ref": "center",
"type": "3d",
"props": {
"scale": 1.5,
"rotate": true
},
"v": [
[0, 0.7822, -3.103]
]
}
]
}

0 comments on commit 9dbe21a

Please sign in to comment.