Explorar o código

create swr for ConflictDiffModal

Yuken Tezuka %!s(int64=3) %!d(string=hai) anos
pai
achega
95919c665e
Modificáronse 1 ficheiros con 28 adicións e 0 borrados
  1. 28 0
      packages/app/src/stores/modal.tsx

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

@@ -553,3 +553,31 @@ export const useHandsontableModal = (status?: HandsontableModalStatus): SWRRespo
     close,
   };
 };
+
+/*
+ * ConflictDiffModal
+ */
+type ConflictDiffModalStatus = {
+  isOpened: boolean,
+}
+
+type ConflictDiffModalUtils = {
+  open(): void,
+  close(): void,
+}
+
+export const useConflictDiffModal = (): SWRResponse<ConflictDiffModalStatus, Error> & ConflictDiffModalUtils => {
+
+  const initialStatus: ConflictDiffModalStatus = { isOpened: false };
+  const swrResponse = useStaticSWR<ConflictDiffModalStatus, Error>('conflictDiffModal', undefined, { fallbackData: initialStatus });
+
+  return {
+    ...swrResponse,
+    open() {
+      swrResponse.mutate({ isOpened: true });
+    },
+    close() {
+      swrResponse.mutate({ isOpened: false });
+    },
+  };
+};