From e1e944da306ee124c5197c7debee6be9b4065a42 Mon Sep 17 00:00:00 2001 From: Chika Date: Sun, 24 Apr 2022 14:13:50 +0300 Subject: [PATCH] types: move User type closer to service --- pages/index.tsx | 2 +- services/{user.ts => user/index.ts} | 2 +- services/user/types.ts | 8 ++++++++ stores/user.ts | 10 +--------- 4 files changed, 11 insertions(+), 11 deletions(-) rename services/{user.ts => user/index.ts} (92%) create mode 100644 services/user/types.ts diff --git a/pages/index.tsx b/pages/index.tsx index de50fa8..ff68f1e 100644 --- a/pages/index.tsx +++ b/pages/index.tsx @@ -1,6 +1,6 @@ import type { GetServerSideProps, NextPage } from 'next'; import { fetchUser } from 'services/user'; -import { User } from 'stores/user'; +import type { User } from 'services/user/types'; interface PageProps { user: User; diff --git a/services/user.ts b/services/user/index.ts similarity index 92% rename from services/user.ts rename to services/user/index.ts index c7dd679..5fc7e51 100644 --- a/services/user.ts +++ b/services/user/index.ts @@ -1,5 +1,5 @@ import axios, { AxiosRequestConfig } from 'axios'; -import { User } from 'stores/user'; +import type { User } from './types'; function love(user: User) { const superUsers: string[] = JSON.parse(process.env.USERS_SUPER || ''); diff --git a/services/user/types.ts b/services/user/types.ts new file mode 100644 index 0000000..2b1e39a --- /dev/null +++ b/services/user/types.ts @@ -0,0 +1,8 @@ +export type User = { + displayName: string; + username: string; + department: string; + position: string; + mail: string; + domain: string; +}; diff --git a/stores/user.ts b/stores/user.ts index fabd94d..a171197 100644 --- a/stores/user.ts +++ b/stores/user.ts @@ -1,15 +1,7 @@ import { makeAutoObservable } from 'mobx'; +import type { User } from 'services/user/types'; import { RootStore } from './root'; -export type User = { - displayName: string; - username: string; - department: string; - position: string; - mail: string; - domain: string; -}; - export class UserStore { root: RootStore; user?: User = undefined;