This commit is contained in:
IDONTSUDO 2023-12-28 17:18:12 +03:00
parent 7ff6165882
commit ae9842d5e1
61 changed files with 929 additions and 433 deletions

View file

@ -3,9 +3,9 @@ import { v4 as uuidv4 } from "uuid";
import { TriggerType } from "../../../core/model/trigger_model";
import { TriggerRepository } from "../data/trigger_repository";
import { TriggerViewModel } from "../model/trigger_form_view_model";
import { BaseStore } from "../../../core/store/base_store";
import { SimpleErrorState } from "../../../core/store/base_store";
class TriggerStore extends BaseStore {
export class TriggerStore extends SimpleErrorState {
constructor(repository: TriggerRepository) {
super();
this.triggerType = TriggerType.FILE;
@ -39,9 +39,7 @@ class TriggerStore extends BaseStore {
this.triggerType = TriggerType.FILE;
};
getTriggerDescription = (): string => {
return this.triggerType === TriggerType.FILE
? TriggerType.FILE
: TriggerType.PROCESS;
return this.triggerType === TriggerType.FILE ? TriggerType.FILE : TriggerType.PROCESS;
};
pushTrigger = (value: string, type: TriggerType): void => {
this.triggers.push({
@ -72,16 +70,15 @@ class TriggerStore extends BaseStore {
}
}
async saveResult(): Promise<void> {
this.isLoading = true;
await this.repository.save({
type: this.getTriggerDescription(),
description: this.triggerDescription,
value: this.triggers.map((el) => {
return el.value;
}),
});
this.isLoading = false;
await this.loadingHelper(
this.repository.save({
type: this.getTriggerDescription(),
description: this.triggerDescription,
value: this.triggers.map((el) => {
return el.value;
}),
})
);
}
}
export const triggerStore = new TriggerStore(new TriggerRepository());