فهرست منبع

add use attachment delete modal

ryoji-s 3 سال پیش
والد
کامیت
52e8385234
1فایلهای تغییر یافته به همراه26 افزوده شده و 0 حذف شده
  1. 26 0
      packages/app/src/stores/modal.tsx

+ 26 - 0
packages/app/src/stores/modal.tsx

@@ -607,3 +607,29 @@ export const useTemplateModal = (): SWRResponse<TemplateModalStatus, Error> & Te
     },
   });
 };
+
+/**
+ * AttachmentDeleteModal
+ */
+type AttachmentDeleteModalStatus = {
+  isOpened: boolean,
+}
+
+type AttachmentDeleteModalUtils = {
+  open(): void,
+  close(): void,
+}
+
+export const useAttachmentDeleteModal = (): SWRResponse<AttachmentDeleteModalStatus, Error> & AttachmentDeleteModalUtils => {
+  const initialStatus: AttachmentDeleteModalStatus = { isOpened: false };
+  const swrResponse = useStaticSWR<AttachmentDeleteModalStatus, Error>('attachmentDeleteModal', undefined, { fallbackData: initialStatus });
+
+  return Object.assign(swrResponse, {
+    open: () => {
+      swrResponse.mutate({ isOpened: true });
+    },
+    close: () => {
+      swrResponse.mutate({ isOpened: false });
+    },
+  });
+};