Browse Source

impl useSWRxAppSettings

Taichi Masuyama 3 years ago
parent
commit
f84dd08210
1 changed files with 13 additions and 0 deletions
  1. 13 0
      packages/app/src/stores/admin/app-settings.tsx

+ 13 - 0
packages/app/src/stores/admin/app-settings.tsx

@@ -0,0 +1,13 @@
+import useSWR, { SWRResponse } from 'swr';
+
+import { apiv3Get } from '~/client/util/apiv3-client';
+import { IResAppSettings } from '~/interfaces/res/admin/app-settings';
+
+export const useSWRxAppSettings = (): SWRResponse<IResAppSettings, Error> => {
+  return useSWR(
+    '/app-settings/',
+    endpoint => apiv3Get(endpoint).then((response) => {
+      return response.data.appSettingsParams;
+    }),
+  );
+};