Sprava eventu a organizaci
This commit is contained in:
@@ -4,7 +4,7 @@ import {COPILOT_DETAIL, COPILOTS_LIST} from "src/graphql/queries/copilots";
|
||||
import {CREATE_COPILOT, EDIT_COPILOT} from "src/graphql/mutations/copilot";
|
||||
import {updateInItems} from "stores/helpers";
|
||||
|
||||
export const useCopilotsStore = defineStore('SecondPilots', {
|
||||
export const useCopilotsStore = defineStore('Copilots', {
|
||||
state: () => ({
|
||||
items: [],
|
||||
isMutationRunning: false,
|
||||
|
||||
@@ -4,7 +4,7 @@ import {CREATE_EVENT, EDIT_EVENT} from "src/graphql/mutations/event";
|
||||
import {updateInItems} from "stores/helpers";
|
||||
import {EVENT_DETAIL, EVENTS_LIST} from "src/graphql/queries/event";
|
||||
|
||||
export const useEventsStore = defineStore('SecondPilots', {
|
||||
export const useEventsStore = defineStore('Events', {
|
||||
state: () => ({
|
||||
items: [],
|
||||
isMutationRunning: false,
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
import {defineStore} from 'pinia'
|
||||
import {apolloWrapper} from "src/graphql/apollo";
|
||||
import {ADD_USER_TO_ORGANIZATION, CREATE_ORGANIZATION, EDIT_ORGANIZATION, REMOVE_USER_FROM_ORGANIZATION} from "src/graphql/mutations/organization";
|
||||
import {ORGANIZATION_DETAIL, ORGANIZATIONS_LIST} from "src/graphql/queries/organization";
|
||||
import {updateInItems} from "stores/helpers";
|
||||
|
||||
export const useOrganizationsStore = defineStore('Organizations', {
|
||||
state: () => ({
|
||||
items: [],
|
||||
isMutationRunning: false,
|
||||
}),
|
||||
|
||||
actions: {
|
||||
fetchDetail(organizationId) {
|
||||
return apolloWrapper.query(ORGANIZATION_DETAIL, {id: organizationId}).then(({data}) => data.organization);
|
||||
},
|
||||
fetch() {
|
||||
return apolloWrapper.query(ORGANIZATIONS_LIST).then(result => {
|
||||
this.items = result.data.organizations;
|
||||
return result.data.organizations;
|
||||
});
|
||||
},
|
||||
create(formData) {
|
||||
delete formData['id'];
|
||||
|
||||
this.isMutationRunning = true;
|
||||
return apolloWrapper.mutate(CREATE_ORGANIZATION, {input: formData}).then(({data}) => {
|
||||
const organization = data.createOrganization;
|
||||
this.items.push(organization);
|
||||
return organization;
|
||||
}).finally(() => this.isMutationRunning = false);
|
||||
},
|
||||
|
||||
addUserToOrganization(organizationId) {
|
||||
this.isMutationRunning = true;
|
||||
return apolloWrapper.mutate(ADD_USER_TO_ORGANIZATION, {organizationId}).then(({data}) => {
|
||||
return data.addToOrganization;
|
||||
}).finally(() => this.isMutationRunning = false);
|
||||
},
|
||||
|
||||
removeUserFromOrganization(organizationId) {
|
||||
this.isMutationRunning = true;
|
||||
return apolloWrapper.mutate(REMOVE_USER_FROM_ORGANIZATION, {organizationId}).then(({data}) => {
|
||||
return data.removeFromOrganization;
|
||||
}).finally(() => this.isMutationRunning = false);
|
||||
},
|
||||
|
||||
update(id, formData) {
|
||||
return apolloWrapper.mutate(EDIT_ORGANIZATION, {id: id, input: formData}).then(({data}) => {
|
||||
const organization = data.editOrganization;
|
||||
updateInItems(this.items, "id", organization);
|
||||
return organization;
|
||||
}).finally(() => this.isMutationRunning = false);
|
||||
},
|
||||
}
|
||||
})
|
||||
+1
-1
@@ -2,7 +2,7 @@ import {defineStore} from "pinia";
|
||||
import {apolloWrapper} from "src/graphql/apollo";
|
||||
import {DELETE_PHOTO, EDIT_PHOTO, UPLOAD_PHOTO} from "src/graphql/mutations/photo";
|
||||
|
||||
export const usePhotosStore = defineStore('photos', {
|
||||
export const usePhotosStore = defineStore('Photos', {
|
||||
state: () => ({
|
||||
isMutationRunning: false,
|
||||
}),
|
||||
|
||||
Reference in New Issue
Block a user