feat: snackbar message opdrachten lijst
This commit is contained in:
		
							parent
							
								
									2ac1b8187c
								
							
						
					
					
						commit
						902518f9b1
					
				
					 1 changed files with 33 additions and 7 deletions
				
			
		|  | @ -83,16 +83,35 @@ | ||||||
|         await router.push(`/assignment/${clsId}/${id}`); |         await router.push(`/assignment/${clsId}/${id}`); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     const { mutate, data, isSuccess } = useDeleteAssignmentMutation(); |     const snackbar = ref({ | ||||||
| 
 |         visible: false, | ||||||
|     watch([isSuccess, data], async ([success, oldData]) => { |         message: "", | ||||||
|         if (success && oldData?.assignment) { |         color: "success", | ||||||
|             window.location.reload(); |  | ||||||
|         } |  | ||||||
|     }); |     }); | ||||||
| 
 | 
 | ||||||
|  |     function showSnackbar(message: string, color: string): void { | ||||||
|  |         snackbar.value.message = message; | ||||||
|  |         snackbar.value.color = color; | ||||||
|  |         snackbar.value.visible = true; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     const deleteAssignmentMutation = useDeleteAssignmentMutation(); | ||||||
|  | 
 | ||||||
|     async function goToDeleteAssignment(num: number, clsId: string): Promise<void> { |     async function goToDeleteAssignment(num: number, clsId: string): Promise<void> { | ||||||
|         mutate({ cid: clsId, an: num }); |         deleteAssignmentMutation.mutate( | ||||||
|  |             { cid: clsId, an: num }, | ||||||
|  |             { | ||||||
|  |                 onSuccess: (data) => { | ||||||
|  |                     if (data?.assignment){ | ||||||
|  |                         window.location.reload(); | ||||||
|  |                     } | ||||||
|  |                     showSnackbar(t("success") ,"success"); | ||||||
|  |                 }, | ||||||
|  |                 onError: (e) => { | ||||||
|  |                     showSnackbar(t("failed") + ": " + e.response.data.error || e.message, "error"); | ||||||
|  |                 }, | ||||||
|  |             } | ||||||
|  |         ); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     function formatDate(date?: string | Date): string { |     function formatDate(date?: string | Date): string { | ||||||
|  | @ -208,6 +227,13 @@ | ||||||
|                     </v-col> |                     </v-col> | ||||||
|                 </v-row> |                 </v-row> | ||||||
|             </v-container> |             </v-container> | ||||||
|  |             <v-snackbar | ||||||
|  |                 v-model="snackbar.visible" | ||||||
|  |                 :color="snackbar.color" | ||||||
|  |                 timeout="3000" | ||||||
|  |             > | ||||||
|  |                 {{ snackbar.message }} | ||||||
|  |             </v-snackbar> | ||||||
|         </using-query-result> |         </using-query-result> | ||||||
|     </div> |     </div> | ||||||
| </template> | </template> | ||||||
|  |  | ||||||
		Reference in a new issue
	
	 Gabriellvl
						Gabriellvl