Upravy UI, refaktoring, davkove upravy a mazani fotek

This commit is contained in:
Michal Kváček
2023-08-28 22:02:24 +02:00
parent dcc3230cbe
commit dd248d4432
53 changed files with 636 additions and 357 deletions
+9 -7
View File
@@ -6,7 +6,8 @@ import {updateInItems} from "stores/helpers";
export const useCopilotsStore = defineStore('SecondPilots', {
state: () => ({
items: []
items: [],
isMutationRunning: false,
}),
actions: {
@@ -21,19 +22,20 @@ export const useCopilotsStore = defineStore('SecondPilots', {
},
create(formData) {
delete formData['id'];
return apolloWrapper.mutate(CREATE_COPILOT, {input: formData}).then(({data}) => {
this.items.push(data.createCopilot);
return data.createCopilot;
})
this.isMutationRunning = true;
return apolloWrapper.mutate(CREATE_COPILOT, {input: formData}).then(({data}) => {
const copilot = data.createCopilot;
this.items.push(copilot);
return copilot;
}).finally(() => this.isMutationRunning = false);
},
update(id, formData) {
return apolloWrapper.mutate(EDIT_COPILOT, {id: id, input: formData}).then(({data}) => {
const copilot = data.editCopilot;
updateInItems(this.items, "id", copilot);
return copilot;
});
}).finally(() => this.isMutationRunning = false);
},
}
})