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,
|
role: searchingRole,
|
||||||
search,
|
search,
|
||||||
});
|
});
|
||||||
|
toast({ title: 'User created.', status: 'info' });
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clear form state
|
* Clear form state
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -1,18 +1,6 @@
|
|||||||
import { AxiosInstance } from 'axios';
|
import { AxiosInstance } from 'axios';
|
||||||
import { CourseStatusEnum } from 'enums';
|
|
||||||
import { IApiRespose, ICourse } from 'interfaces';
|
import { IApiRespose, ICourse } from 'interfaces';
|
||||||
|
import { FetchCoursesParams } from 'types';
|
||||||
export type FetchCoursesParams = {
|
|
||||||
/**
|
|
||||||
* Get courses by status
|
|
||||||
*/
|
|
||||||
status?: CourseStatusEnum;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get courses with category by id
|
|
||||||
*/
|
|
||||||
category_id?: string;
|
|
||||||
};
|
|
||||||
|
|
||||||
export class CourseService {
|
export class CourseService {
|
||||||
public api: AxiosInstance;
|
public api: AxiosInstance;
|
||||||
|
|||||||
@ -1,18 +1,7 @@
|
|||||||
import { AxiosInstance } from 'axios';
|
import { AxiosInstance } from 'axios';
|
||||||
import { IApiRespose, IMe, IUser, IUserContacts } from 'interfaces';
|
import { IApiRespose, IMe, IUser, IUserContacts } from 'interfaces';
|
||||||
import * as helpers from 'helpers';
|
import * as helpers from 'helpers';
|
||||||
import { UserRoleEnum } from 'enums';
|
import { CreateUserParamsType, FetchUsersParamsType, UpdateUserParamsType } from 'types';
|
||||||
|
|
||||||
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 };
|
|
||||||
|
|
||||||
export default class UserService {
|
export default class UserService {
|
||||||
public api: AxiosInstance;
|
public api: AxiosInstance;
|
||||||
|
|||||||
@ -1,7 +1,19 @@
|
|||||||
import { AxiosInstance } from 'axios';
|
import { AxiosInstance } from 'axios';
|
||||||
import { ICategory } from 'interfaces';
|
|
||||||
import { makeAutoObservable, runInAction } from 'mobx';
|
import { makeAutoObservable, runInAction } from 'mobx';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Types
|
||||||
|
*/
|
||||||
|
import { ICategory } from 'interfaces';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Services
|
||||||
|
*/
|
||||||
import CategoryService from 'services/CategoryService';
|
import CategoryService from 'services/CategoryService';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Stores
|
||||||
|
*/
|
||||||
import RootStore from './RootStore';
|
import RootStore from './RootStore';
|
||||||
|
|
||||||
export default class CategoryStore {
|
export default class CategoryStore {
|
||||||
|
|||||||
@ -1,7 +1,20 @@
|
|||||||
import { AxiosInstance } from 'axios';
|
import { AxiosInstance } from 'axios';
|
||||||
import { ICourse } from 'interfaces';
|
|
||||||
import { makeAutoObservable, runInAction } from 'mobx';
|
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';
|
import RootStore from './RootStore';
|
||||||
|
|
||||||
export default class CourseStore {
|
export default class CourseStore {
|
||||||
|
|||||||
@ -1,5 +1,9 @@
|
|||||||
import { makeAutoObservable, observable } from 'mobx';
|
import { makeAutoObservable, observable } from 'mobx';
|
||||||
import { createBrowserHistory } from 'history';
|
import { createBrowserHistory } from 'history';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Types
|
||||||
|
*/
|
||||||
import { IWindowDimensions } from 'interfaces';
|
import { IWindowDimensions } from 'interfaces';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -1,18 +1,23 @@
|
|||||||
import { AxiosInstance } from 'axios';
|
import { AxiosInstance } from 'axios';
|
||||||
import { makeAutoObservable, runInAction } from 'mobx';
|
import { makeAutoObservable, runInAction } from 'mobx';
|
||||||
import { IUser, IUserContacts, IMe, IPaginationMeta } from 'interfaces';
|
|
||||||
import * as helpers from 'helpers';
|
import * as helpers from 'helpers';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Types
|
||||||
|
*/
|
||||||
|
import { CreateUserParamsType, FetchUsersParamsType, UpdateUserParamsType } from 'types';
|
||||||
|
import { IUser, IUserContacts, IMe, IPaginationMeta } from 'interfaces';
|
||||||
|
import { UserRoleEnum } from 'enums';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Services
|
* Services
|
||||||
*/
|
*/
|
||||||
import UserService, { CreateUserParamsType, UpdateUserParamsType, FetchUsersParamsType } from 'services/UserService';
|
import UserService from 'services/UserService';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Stores
|
* Stores
|
||||||
*/
|
*/
|
||||||
import RootStore from './RootStore';
|
import RootStore from './RootStore';
|
||||||
import { UserRoleEnum } from 'enums';
|
|
||||||
|
|
||||||
export default class UserStore {
|
export default class UserStore {
|
||||||
public root: RootStore;
|
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;
|
selectedCategory: ICategory | undefined;
|
||||||
setSelectedCategory: React.Dispatch<React.SetStateAction<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