fix: redirect doen als een assignment is aangemaakt, idem voor delete
This commit is contained in:
		
							parent
							
								
									71e0c221a4
								
							
						
					
					
						commit
						85edb8feb5
					
				
					 3 changed files with 19 additions and 7 deletions
				
			
		|  | @ -65,6 +65,13 @@ | |||
| 
 | ||||
|     const { mutate, data, isSuccess } = useCreateAssignmentMutation(); | ||||
| 
 | ||||
|     watch([isSuccess, data], async ([success, newData]) => { | ||||
|         if (success && newData?.assignment) { | ||||
|             await router.push(`/assignment/${newData.assignment.within}/${newData.assignment.id}`); | ||||
|         } | ||||
|     }); | ||||
| 
 | ||||
| 
 | ||||
|     async function submitFormHandler(): Promise<void> { | ||||
|         const { valid } = await form.value.validate(); | ||||
|         if (!valid) return; | ||||
|  | @ -80,8 +87,6 @@ | |||
|         }; | ||||
| 
 | ||||
|         mutate({ cid: assignmentDTO.within, data: assignmentDTO }); | ||||
|         if (isSuccess) | ||||
|             await router.push(`/assignment/class/${data.value?.assignment.within}/${data.value?.assignment.id}`); | ||||
|     } | ||||
| </script> | ||||
| 
 | ||||
|  |  | |||
|  | @ -1,5 +1,5 @@ | |||
| <script setup lang="ts"> | ||||
|     import { computed, type Ref, ref } from "vue"; | ||||
| import {computed, type Ref, ref, watch} from "vue"; | ||||
|     import { useI18n } from "vue-i18n"; | ||||
|     import { useAssignmentQuery, useDeleteAssignmentMutation } from "@/queries/assignments.ts"; | ||||
|     import UsingQueryResult from "@/components/UsingQueryResult.vue"; | ||||
|  | @ -72,14 +72,17 @@ Const {groupProgressMap} = props.useGroupsWithProgress( | |||
|     ]); | ||||
| 
 | ||||
|     const { mutate, isSuccess } = useDeleteAssignmentMutation(); | ||||
|     watch(isSuccess, async (success) => { | ||||
|         if (success) { | ||||
|             await router.push("/user/assignment"); | ||||
|         } | ||||
|     }); | ||||
| 
 | ||||
|     async function deleteAssignment(num: number, clsId: string): Promise<void> { | ||||
|         mutate({ | ||||
|             cid: clsId, | ||||
|             an: num, | ||||
|         }); | ||||
| 
 | ||||
|         if (isSuccess) await router.push("/user/assignments"); | ||||
|     } | ||||
| </script> | ||||
| 
 | ||||
|  |  | |||
|  | @ -1,5 +1,5 @@ | |||
| <script setup lang="ts"> | ||||
|     import { ref, computed, onMounted } from "vue"; | ||||
| import {ref, computed, onMounted, watch} from "vue"; | ||||
|     import { useI18n } from "vue-i18n"; | ||||
|     import { useRouter } from "vue-router"; | ||||
|     import auth from "@/services/auth/auth-service.ts"; | ||||
|  | @ -61,6 +61,11 @@ | |||
|     } | ||||
| 
 | ||||
|     const { mutate, isSuccess } = useDeleteAssignmentMutation(); | ||||
|     watch(isSuccess, async (success) => { | ||||
|         if (success) { | ||||
|             await router.push("/user/assignment"); | ||||
|         } | ||||
|     }); | ||||
| 
 | ||||
|     async function goToDeleteAssignment(num: number, clsId: string): Promise<void> { | ||||
|         mutate({ | ||||
|  | @ -68,7 +73,6 @@ | |||
|             an: num, | ||||
|         }); | ||||
| 
 | ||||
|         if (isSuccess) await router.push("/user/assignment"); | ||||
|     } | ||||
| 
 | ||||
|     onMounted(async () => { | ||||
|  |  | |||
		Reference in a new issue
	
	 Joyelle Ndagijimana
						Joyelle Ndagijimana