generated from Flycro/laravel-nuxt
feat: Realtime for Votes + Deadlines
This commit is contained in:
@@ -123,6 +123,17 @@ export const useBookRecommendationStore = defineStore('bookRecommendations', ()
|
||||
})
|
||||
}
|
||||
|
||||
const createVoteWS = async (data: Partial<Vote>) => {
|
||||
const index = recommendations.value.findIndex(r => r.id === data.book_recommendation_id)
|
||||
// check if vote already exists otherwise add an empty array
|
||||
if (index !== -1) {
|
||||
if (!recommendations.value[index]?.votes) {
|
||||
recommendations.value[index].votes = []
|
||||
}
|
||||
recommendations.value[index].votes.push(data)
|
||||
}
|
||||
}
|
||||
|
||||
function resetRecommendations() {
|
||||
recommendations.value = []
|
||||
}
|
||||
@@ -133,6 +144,7 @@ export const useBookRecommendationStore = defineStore('bookRecommendations', ()
|
||||
updateRecommendationWS,
|
||||
deleteRecommendationWS,
|
||||
createRecommendationWS,
|
||||
createVoteWS,
|
||||
statusOptions,
|
||||
fetchRecommendations,
|
||||
fetchRecommendationsStatus,
|
||||
|
||||
Reference in New Issue
Block a user