fix: refresh assignable persons list after assignment and keep dialog open
Invalidate assignable-persons query cache in useAssignPersonToShift onSuccess so the list reflects the new assignment immediately. Keep the dialog open after assigning a person to allow sequential assignments, showing a brief success snackbar instead of closing. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -26,6 +26,8 @@ const searchQuery = ref('')
|
||||
const showOnlyAvailable = ref(true)
|
||||
const selectedCrowdType = ref<string | null>(null)
|
||||
const assignError = ref<string | null>(null)
|
||||
const showSuccess = ref(false)
|
||||
const successName = ref('')
|
||||
|
||||
// Clear error on filter changes
|
||||
watch([searchQuery, showOnlyAvailable, selectedCrowdType], () => {
|
||||
@@ -111,7 +113,8 @@ async function handleAssign(person: AssignablePerson) {
|
||||
personId: person.id,
|
||||
})
|
||||
emit('assigned')
|
||||
modelValue.value = false
|
||||
successName.value = person.name
|
||||
showSuccess.value = true
|
||||
}
|
||||
catch (error: any) {
|
||||
const message = error.response?.data?.errors?.person_id?.[0]
|
||||
@@ -348,4 +351,12 @@ async function handleAssign(person: AssignablePerson) {
|
||||
</VCardActions>
|
||||
</VCard>
|
||||
</VDialog>
|
||||
|
||||
<VSnackbar
|
||||
v-model="showSuccess"
|
||||
color="success"
|
||||
:timeout="2000"
|
||||
>
|
||||
{{ successName }} toegewezen
|
||||
</VSnackbar>
|
||||
</template>
|
||||
|
||||
@@ -140,6 +140,7 @@ export function useAssignPersonToShift(eventId: Ref<string>) {
|
||||
},
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries({ queryKey: ['shift-assignments', eventId.value] })
|
||||
queryClient.invalidateQueries({ queryKey: ['assignable-persons'] })
|
||||
queryClient.invalidateQueries({ queryKey: ['shifts'] })
|
||||
queryClient.invalidateQueries({ queryKey: ['persons', eventId.value] })
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user