Aktualizace balicku, strnakovani, uprava hlavni stranky
This commit is contained in:
+25
-7
@@ -1,29 +1,46 @@
|
||||
import {defineStore} from 'pinia'
|
||||
import {CREATE_EVENT, EDIT_EVENT} from "src/graphql/mutations/event";
|
||||
import {mutate, query, updateInItems} from "stores/helpers";
|
||||
import {mutate, query, setItems, updateInItems} from "stores/helpers";
|
||||
import {ref} from "vue";
|
||||
import {EVENT_DETAIL, EVENTS_LIST} from "src/graphql/queries/event";
|
||||
import {EVENT_DETAIL, EVENT_PUBLIC_DETAIL, EVENTS_LIST, EVENTS_PUBLIC_LIST} from "src/graphql/queries/event";
|
||||
|
||||
export const useEventsStore = defineStore('Events', () => {
|
||||
const event = ref(null);
|
||||
const events = ref([]);
|
||||
const totalItemsCount = ref(0);
|
||||
const isMutationRunning = ref(false);
|
||||
const isQueryRunning = ref(false);
|
||||
|
||||
const fetchDetail = (id, username) => {
|
||||
const fetchDetail = (id) => {
|
||||
return query({
|
||||
isQueryRunning,
|
||||
query: EVENT_DETAIL,
|
||||
variables: {id},
|
||||
}).then(item => event.value = item);
|
||||
};
|
||||
|
||||
const fetchPublicDetail = (id, username) => {
|
||||
return query({
|
||||
isQueryRunning,
|
||||
query: EVENT_PUBLIC_DETAIL,
|
||||
variables: {id, username},
|
||||
}).then(item => event.value = item);
|
||||
};
|
||||
|
||||
const fetch = (username = undefined) => {
|
||||
const fetch = ({limit = 100, offset, appendItems}) => {
|
||||
return query({
|
||||
isQueryRunning,
|
||||
query: EVENTS_LIST,
|
||||
variables: {username}
|
||||
}).then(items => events.value = items);
|
||||
variables: {limit, offset}
|
||||
}).then(data => setItems(data, appendItems, events, totalItemsCount));
|
||||
}
|
||||
|
||||
const fetchPublic = (username, limit = 100, offset, appendItems) => {
|
||||
return query({
|
||||
isQueryRunning,
|
||||
query: EVENTS_PUBLIC_LIST,
|
||||
variables: {username, limit, offset}
|
||||
}).then(data => setItems(data, appendItems, events, totalItemsCount));
|
||||
}
|
||||
|
||||
const create = (input) => {
|
||||
@@ -43,6 +60,7 @@ export const useEventsStore = defineStore('Events', () => {
|
||||
}
|
||||
|
||||
return {
|
||||
event, events, isMutationRunning, isQueryRunning, fetch, fetchDetail, create, update
|
||||
event, events, isMutationRunning, isQueryRunning, fetch, fetchDetail, create, update,
|
||||
fetchPublic, fetchPublicDetail, totalItemsCount
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user