Skip to content

Commit

Permalink
close modal on save
Browse files Browse the repository at this point in the history
  • Loading branch information
paoloose committed Dec 6, 2024
1 parent a43e8e2 commit 9d0771e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
7 changes: 4 additions & 3 deletions app/src/pages/Editor/components/SlotInformationModa.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { useMetagalleryStore } from "@/providers/MetagalleryProvider";
import { useEditorStore } from "@/stores/editorAction";
import { useUser } from "@/stores/useUser";
import { Button, TextInput } from "@mantine/core";
Expand All @@ -7,12 +8,13 @@ import { useMutation, useQueryClient } from "@tanstack/react-query";
import { mutate } from "swr";

type SlotInformationModalProps = {
id: string;
title: string;
description: string;
slotRef: string;
}

export const SlotInformationModal = ({ title, description, slotRef }: SlotInformationModalProps) => {
export const SlotInformationModal = ({ id, title, description, slotRef }: SlotInformationModalProps) => {
const gallery = useEditorStore((s) => s.gallery);
const queryClient = useQueryClient();

Expand All @@ -38,6 +40,7 @@ export const SlotInformationModal = ({ title, description, slotRef }: SlotInform
console.log('File uploaded');
queryClient.invalidateQueries({ queryKey: ['user/media'] });
mutate(`/gallery/${gallery}`);
useMetagalleryStore.getState().closeModal(id);
},
onError: (error) => {
console.error('Error uploading file', error);
Expand Down Expand Up @@ -67,14 +70,12 @@ export const SlotInformationModal = ({ title, description, slotRef }: SlotInform
<TextInput
label="Título de la obra"
placeholder="Título"
required
{...form.getInputProps('title')}
/>
<TextInput
mt={12}
label="Descripción"
placeholder="Descripción"
required
{...form.getInputProps('description')}
/>
<Button mt={16} size="sm" type="submit">Guardar</Button>
Expand Down
3 changes: 2 additions & 1 deletion app/src/pages/Editor/components/blocks/Model3DBlock.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ export const Model3DSlot = memo(({ idRef, v, res, props, title, description }: M
id: 'picture-slot-modal',
child: (
<SlotInformationModal
id='picture-slot-modal'
title={title}
description={description}
slotRef={idRef}
Expand Down Expand Up @@ -169,6 +170,6 @@ export const Model3DSlot = memo(({ idRef, v, res, props, title, description }: M
</>
);
}, (prev, next) => {
return prev.res === next.res;
return prev.res === next.res && prev.title === next.title && prev.description === next.description;
});

1 change: 1 addition & 0 deletions app/src/pages/Editor/components/blocks/PictureSlot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ export const PictureSlot = memo(({ idRef, v, res, title, description, props }: P
id: 'picture-slot-modal',
child: (
<SlotInformationModal
id='picture-slot-modal'
title={title}
description={description}
slotRef={idRef}
Expand Down

0 comments on commit 9d0771e

Please sign in to comment.