Просмотр исходного кода

Set initial value of actionMap to auditLogAvailableActions

Shun Miyazawa 3 лет назад
Родитель
Сommit
738e083607
1 измененных файлов с 5 добавлено и 5 удалено
  1. 5 5
      packages/app/src/components/Admin/AuditLogManagement.tsx

+ 5 - 5
packages/app/src/components/Admin/AuditLogManagement.tsx

@@ -3,7 +3,7 @@ import React, { FC, useState, useCallback } from 'react';
 import { format } from 'date-fns';
 import { useTranslation } from 'react-i18next';
 
-import { SupportedActionType, AllSupportedActions } from '~/interfaces/activity';
+import { SupportedActionType } from '~/interfaces/activity';
 import { useSWRxActivity } from '~/stores/activity';
 import { useAuditLogEnabled, useAuditLogAvailableActions } from '~/stores/context';
 
@@ -29,6 +29,9 @@ const PAGING_LIMIT = 10;
 export const AuditLogManagement: FC = () => {
   const { t } = useTranslation();
 
+  const { data: auditLogAvailableActionsData } = useAuditLogAvailableActions();
+  const auditLogAvailableActions = auditLogAvailableActionsData != null ? auditLogAvailableActionsData : [];
+
   /*
    * State
    */
@@ -39,7 +42,7 @@ export const AuditLogManagement: FC = () => {
   const [endDate, setEndDate] = useState<Date | null>(null);
   const [selectedUsernames, setSelectedUsernames] = useState<string[]>([]);
   const [actionMap, setActionMap] = useState(
-    new Map<SupportedActionType, boolean>(AllSupportedActions.map(action => [action, true])),
+    new Map<SupportedActionType, boolean>(auditLogAvailableActions.map(action => [action, true])),
   );
 
   /*
@@ -54,9 +57,6 @@ export const AuditLogManagement: FC = () => {
   const totalActivityNum = activityData?.totalDocs != null ? activityData.totalDocs : 0;
   const isLoading = activityData === undefined && error == null;
 
-  const { data: auditLogAvailableActionsData } = useAuditLogAvailableActions();
-  const  auditLogAvailableActions = auditLogAvailableActionsData != null ? auditLogAvailableActionsData : [];
-
   const { data: auditLogEnabled } = useAuditLogEnabled();
 
   /*