Skip to content

Instantly share code, notes, and snippets.

@smokeyfro
Created December 12, 2022 07:25
Show Gist options
  • Save smokeyfro/791fdec3a6a6065f559d63927512799f to your computer and use it in GitHub Desktop.
Save smokeyfro/791fdec3a6a6065f559d63927512799f to your computer and use it in GitHub Desktop.
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