diff --git a/src/components/item/edit/EditModal.tsx b/src/components/item/edit/EditModal.tsx
index 33b125b98..6d02d5132 100644
--- a/src/components/item/edit/EditModal.tsx
+++ b/src/components/item/edit/EditModal.tsx
@@ -72,8 +72,6 @@ const EditModal = ({ item, onClose, open }: Props): JSX.Element => {
switch (item.type) {
case ItemType.DOCUMENT:
return ;
- case ItemType.SHORTCUT:
- return ;
case ItemType.LINK:
case ItemType.APP:
case ItemType.ETHERPAD:
@@ -128,6 +126,9 @@ const EditModal = ({ item, onClose, open }: Props): JSX.Element => {
if (item.type === ItemType.LOCAL_FILE || item.type === ItemType.S3_FILE) {
return ;
}
+ if (item.type === ItemType.SHORTCUT) {
+ return ;
+ }
return (
<>
diff --git a/src/components/item/shortcut/EditShortcutForm.tsx b/src/components/item/shortcut/EditShortcutForm.tsx
index 3d08ef259..1c381ffe3 100644
--- a/src/components/item/shortcut/EditShortcutForm.tsx
+++ b/src/components/item/shortcut/EditShortcutForm.tsx
@@ -1,7 +1,18 @@
-import { ReactNode, useEffect } from 'react';
+import { ReactNode } from 'react';
import { FormProvider, useForm } from 'react-hook-form';
+import { Box, Button, DialogActions, DialogContent } from '@mui/material';
+
import { DiscriminatedItem } from '@graasp/sdk';
+import { COMMON } from '@graasp/translations';
+
+import CancelButton from '@/components/common/CancelButton';
+import { useCommonTranslation } from '@/config/i18n';
+import { mutations } from '@/config/queryClient';
+import {
+ EDIT_ITEM_MODAL_CANCEL_BUTTON_ID,
+ ITEM_FORM_CONFIRM_BUTTON_ID,
+} from '@/config/selectors';
import { ItemNameField } from '../form/ItemNameField';
@@ -11,29 +22,53 @@ type Inputs = {
function EditShortcutForm({
item,
- setChanges,
+ onClose,
}: {
item: DiscriminatedItem;
- setChanges: (args: { name: string }) => void;
+ onClose: () => void;
}): ReactNode {
+ const { t: translateCommon } = useCommonTranslation();
const methods = useForm({
defaultValues: { name: item.name },
});
- const { watch } = methods;
-
- const name = watch('name');
+ const {
+ handleSubmit,
+ formState: { isValid },
+ } = methods;
- // synchronize upper state after async local state change
- useEffect(() => {
- setChanges({
- name,
- });
- // eslint-disable-next-line react-hooks/exhaustive-deps
- }, [name]);
+ const { mutateAsync: editItem } = mutations.useEditItem();
+ async function onSubmit(data: Inputs) {
+ try {
+ await editItem({
+ id: item.id,
+ name: data.name,
+ });
+ onClose();
+ } catch (e) {
+ console.error(e);
+ }
+ }
return (
-
+
+
+
+
+
+
+
+
+
);
}