Created
December 12, 2022 07:25
-
-
Save smokeyfro/791fdec3a6a6065f559d63927512799f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { defineStore } from 'pinia'; | |
export const useAssignmentsStore = defineStore('assignments', { | |
state: () => ( { | |
assignments: {}, | |
}), | |
actions: { | |
async fetchAssignments() { | |
const user = useDirectusUser() | |
const { getItems } = useDirectusItems() | |
const payload = await getItems({ | |
collection: 'assignments', | |
params: { | |
filter: { | |
'status': { '_neq': 'draft' }, | |
'student': { '_eq': user.value.id } | |
}, | |
sort: '-date' | |
} | |
}) | |
this.assignments = await payload; | |
return this.assignments; | |
} | |
}, | |
persist: { | |
storage: persistedState.localStorage, | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment