mirror of
https://github.com/sergeyyarkov/educt-client.git
synced 2026-10-11 10:19:22 +03:00
refactor: moved fetch params types to types folder
This commit is contained in:
parent
02b2a4ee43
commit
a7792983fd
@ -82,6 +82,8 @@ const CreateUserModal: React.FC<CreateUserModalPropsType> = ({ me }) => {
|
||||
role: searchingRole,
|
||||
search,
|
||||
});
|
||||
toast({ title: 'User created.', status: 'info' });
|
||||
|
||||
/**
|
||||
* Clear form state
|
||||
*/
|
||||
|
||||
@ -1,18 +1,6 @@
|
||||
import { AxiosInstance } from 'axios';
|
||||
import { CourseStatusEnum } from 'enums';
|
||||
import { IApiRespose, ICourse } from 'interfaces';
|
||||
|
||||
export type FetchCoursesParams = {
|
||||
/**
|
||||
* Get courses by status
|
||||
*/
|
||||
status?: CourseStatusEnum;
|
||||
|
||||
/**
|
||||
* Get courses with category by id
|
||||
*/
|
||||
category_id?: string;
|
||||
};
|
||||
import { FetchCoursesParams } from 'types';
|
||||
|
||||
export class CourseService {
|
||||
public api: AxiosInstance;
|
||||
|
||||
@ -1,18 +1,7 @@
|
||||
import { AxiosInstance } from 'axios';
|
||||
import { IApiRespose, IMe, IUser, IUserContacts } from 'interfaces';
|
||||
import * as helpers from 'helpers';
|
||||
import { UserRoleEnum } from 'enums';
|
||||
|
||||
export type FetchUsersParamsType = { page?: number; limit?: number; role?: UserRoleEnum | 'any'; search?: string };
|
||||
export type CreateUserParamsType = {
|
||||
first_name: string;
|
||||
last_name: string;
|
||||
login: string;
|
||||
email: string;
|
||||
role: UserRoleEnum;
|
||||
password: string;
|
||||
};
|
||||
export type UpdateUserParamsType = { first_name?: string; last_name?: string; email?: string };
|
||||
import { CreateUserParamsType, FetchUsersParamsType, UpdateUserParamsType } from 'types';
|
||||
|
||||
export default class UserService {
|
||||
public api: AxiosInstance;
|
||||
|
||||
@ -1,7 +1,19 @@
|
||||
import { AxiosInstance } from 'axios';
|
||||
import { ICategory } from 'interfaces';
|
||||
import { makeAutoObservable, runInAction } from 'mobx';
|
||||
|
||||
/**
|
||||
* Types
|
||||
*/
|
||||
import { ICategory } from 'interfaces';
|
||||
|
||||
/**
|
||||
* Services
|
||||
*/
|
||||
import CategoryService from 'services/CategoryService';
|
||||
|
||||
/**
|
||||
* Stores
|
||||
*/
|
||||
import RootStore from './RootStore';
|
||||
|
||||
export default class CategoryStore {
|
||||
|
||||
@ -1,7 +1,20 @@
|
||||
import { AxiosInstance } from 'axios';
|
||||
import { ICourse } from 'interfaces';
|
||||
import { makeAutoObservable, runInAction } from 'mobx';
|
||||
import { CourseService, FetchCoursesParams } from 'services/CourseService';
|
||||
|
||||
/**
|
||||
* Types
|
||||
*/
|
||||
import { FetchCoursesParams } from 'types';
|
||||
import { ICourse } from 'interfaces';
|
||||
|
||||
/**
|
||||
* Services
|
||||
*/
|
||||
import { CourseService } from 'services/CourseService';
|
||||
|
||||
/**
|
||||
* Stores
|
||||
*/
|
||||
import RootStore from './RootStore';
|
||||
|
||||
export default class CourseStore {
|
||||
|
||||
@ -1,5 +1,9 @@
|
||||
import { makeAutoObservable, observable } from 'mobx';
|
||||
import { createBrowserHistory } from 'history';
|
||||
|
||||
/**
|
||||
* Types
|
||||
*/
|
||||
import { IWindowDimensions } from 'interfaces';
|
||||
|
||||
/**
|
||||
|
||||
@ -1,18 +1,23 @@
|
||||
import { AxiosInstance } from 'axios';
|
||||
import { makeAutoObservable, runInAction } from 'mobx';
|
||||
import { IUser, IUserContacts, IMe, IPaginationMeta } from 'interfaces';
|
||||
import * as helpers from 'helpers';
|
||||
|
||||
/**
|
||||
* Types
|
||||
*/
|
||||
import { CreateUserParamsType, FetchUsersParamsType, UpdateUserParamsType } from 'types';
|
||||
import { IUser, IUserContacts, IMe, IPaginationMeta } from 'interfaces';
|
||||
import { UserRoleEnum } from 'enums';
|
||||
|
||||
/**
|
||||
* Services
|
||||
*/
|
||||
import UserService, { CreateUserParamsType, UpdateUserParamsType, FetchUsersParamsType } from 'services/UserService';
|
||||
import UserService from 'services/UserService';
|
||||
|
||||
/**
|
||||
* Stores
|
||||
*/
|
||||
import RootStore from './RootStore';
|
||||
import { UserRoleEnum } from 'enums';
|
||||
|
||||
export default class UserStore {
|
||||
public root: RootStore;
|
||||
|
||||
26
src/types/index.d.ts
vendored
26
src/types/index.d.ts
vendored
@ -81,3 +81,29 @@ export type CoursesPageContextType = {
|
||||
selectedCategory: ICategory | undefined;
|
||||
setSelectedCategory: React.Dispatch<React.SetStateAction<ICategory | undefined>>;
|
||||
};
|
||||
export type FetchCoursesParams = {
|
||||
/**
|
||||
* Get courses by status
|
||||
*/
|
||||
status?: CourseStatusEnum;
|
||||
|
||||
/**
|
||||
* Get courses with category by id
|
||||
*/
|
||||
category_id?: string;
|
||||
};
|
||||
export type FetchUsersParamsType = {
|
||||
page?: number;
|
||||
limit?: number;
|
||||
role?: UserRoleEnum | 'any';
|
||||
search?: string;
|
||||
};
|
||||
export type CreateUserParamsType = {
|
||||
first_name: string;
|
||||
last_name: string;
|
||||
login: string;
|
||||
email: string;
|
||||
role: UserRoleEnum;
|
||||
password: string;
|
||||
};
|
||||
export type UpdateUserParamsType = { first_name?: string; last_name?: string; email?: string };
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user