Browse Source

impl useSWRxAppSettings

Taichi Masuyama 3 năm trước cách đây
mục cha
commit
f84dd08210
1 tập tin đã thay đổi với 13 bổ sung0 xóa
  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;
+    }),
+  );
+};