feat: Select article list in sight
This commit is contained in:
36
src/shared/store/ArticlesStore/index.tsx
Normal file
36
src/shared/store/ArticlesStore/index.tsx
Normal file
@@ -0,0 +1,36 @@
|
||||
import { authInstance } from "@shared";
|
||||
import { makeAutoObservable, runInAction } from "mobx";
|
||||
|
||||
export type Article = {
|
||||
id: string;
|
||||
heading: string;
|
||||
body: string;
|
||||
service_name: string;
|
||||
};
|
||||
|
||||
class ArticlesStore {
|
||||
constructor() {
|
||||
makeAutoObservable(this);
|
||||
}
|
||||
|
||||
articles: Article[] = [];
|
||||
articleData: Article | null = null;
|
||||
|
||||
getArticles = async () => {
|
||||
const response = await authInstance.get("/article");
|
||||
|
||||
runInAction(() => {
|
||||
this.articles = response.data;
|
||||
});
|
||||
};
|
||||
|
||||
getArticle = async (id: string) => {
|
||||
const response = await authInstance.get(`/article/${id}`);
|
||||
|
||||
runInAction(() => {
|
||||
this.articleData = response.data;
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
export const articlesStore = new ArticlesStore();
|
||||
Reference in New Issue
Block a user