2022-02-23 15:04:45 -09:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								import { Plugin } from "@nuxt/types";
							 | 
						
					
						
							
								
									
										
										
										
											2021-10-09 13:08:23 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								import { NuxtAxiosInstance } from "@nuxtjs/axios";
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								import { alert } from "~/composables/use-toast";
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2022-01-09 07:15:23 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								const toastPlugin: Plugin = ({ $axios }: { $axios: NuxtAxiosInstance }) => {
							 | 
						
					
						
							
								
									
										
										
										
											2021-10-09 13:08:23 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  $axios.onResponse((response) => {
							 | 
						
					
						
							
								
									
										
										
										
											2022-02-23 15:04:45 -09:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    if (response?.data?.message) {
							 | 
						
					
						
							
								
									
										
										
										
											2021-10-09 13:08:23 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      alert.info(response.data.message);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  });
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  $axios.onError((error) => {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    if (error.response?.data?.detail?.message) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      alert.error(error.response.data.detail.message);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  });
							 | 
						
					
						
							
								
									
										
										
										
											2022-02-23 15:04:45 -09:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								};
							 | 
						
					
						
							
								
									
										
										
										
											2022-01-09 07:15:23 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								export default toastPlugin;
							 |