| 6 | import {IClient} from '../types'; |
| 7 | |
| 8 | export class ClientStore extends BaseStore<IClient> { |
| 9 | public constructor(private readonly snack: SnackReporter) { |
| 10 | super(); |
| 11 | } |
| 12 | |
| 13 | protected requestItems = (): Promise<IClient[]> => |
| 14 | axios.get<IClient[]>(`${config.get('url')}client`).then((response) => response.data); |
| 15 | |
| 16 | protected requestDelete(id: number): Promise<void> { |
| 17 | return axios |
| 18 | .delete(`${config.get('url')}client/${id}`) |
| 19 | .then(() => this.snack('Client deleted')); |
| 20 | } |
| 21 | |
| 22 | @action |
| 23 | public update = async (id: number, name: string): Promise<void> => { |
| 24 | await axios.put(`${config.get('url')}client/${id}`, {name}); |
| 25 | await this.refresh(); |
| 26 | this.snack('Client updated'); |
| 27 | }; |
| 28 | |
| 29 | @action |
| 30 | public createNoNotifcation = async (name: string): Promise<IClient> => { |
| 31 | const client = await axios.post(`${config.get('url')}client`, {name}); |
| 32 | await this.refresh(); |
| 33 | return client.data; |
| 34 | }; |
| 35 | |
| 36 | @action |
| 37 | public create = async (name: string): Promise<void> => { |
| 38 | await this.createNoNotifcation(name); |
| 39 | this.snack('Client added'); |
| 40 | }; |
| 41 | } |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…