import ResourceHandlers from "common/ResourceHandlers" ; import { CommentResource , ItemCreateData , State } from "entity/comment" ; import { ModuleNames } from "modules/names" ; import { Actions , effect , exportModel } from "react-coat" ; import api from "./api" ; import { defRouteData } from "./facade" ; export { State } from "entity/comment" ; const initState = { } ; class ModuleHandlers extends ResourceHandlers < CommentResource , State > { constructor ( init ) { super ( init , { api } ) ; } @ effect ( ) public async createItem ( data ) { const response = await super . createItem ( data ) ; if ( ! response . error ) { const search = { ... defRouteData . searchData . search , isNewest : true } ; delete search . articleId ; this . searchList ( search ) ; } return response ; } @ effect ( ) protected async [ ModuleNames . comments + "/INIT" ] ( ) { await super . onInit ( ) ; } } export type ModuleActions = Actions < ModuleHandlers > ; export default exportModel ( ModuleNames . comments , ModuleHandlers , initState ) ;