mirror of
				https://github.com/crater-invoice/crater.git
				synced 2025-10-31 05:31:10 -04:00 
			
		
		
		
	Add New SweetAlert & Notification Components
This commit is contained in:
		
				
					committed by
					
						 Mohit Panjwani
						Mohit Panjwani
					
				
			
			
				
	
			
			
			
						parent
						
							3f7db2793f
						
					
				
				
					commit
					c3d3e5e35f
				
			| @ -45,9 +45,8 @@ | ||||
| </template> | ||||
|  | ||||
| <script type="text/babel"> | ||||
| import { async } from 'q' | ||||
| const { required, email } = require('vuelidate/lib/validators') | ||||
|  | ||||
| import { mapActions } from 'vuex' | ||||
| export default { | ||||
|   data() { | ||||
|     return { | ||||
| @ -67,6 +66,7 @@ export default { | ||||
|     }, | ||||
|   }, | ||||
|   methods: { | ||||
|     ...mapActions('notification', ['showNotification']), | ||||
|     async validateBeforeSubmit(e) { | ||||
|       this.$v.formData.$touch() | ||||
|       if (!this.$v.formData.$invalid) { | ||||
| @ -78,7 +78,10 @@ export default { | ||||
|           ) | ||||
|  | ||||
|           if (res.data) { | ||||
|             toastr['success']('Mail sent successfuly!', 'Success') | ||||
|             this.showNotification({ | ||||
|               type: 'success', | ||||
|               message: 'Mail sent successfuly!', | ||||
|             }) | ||||
|           } | ||||
|  | ||||
|           this.isSent = true | ||||
|  | ||||
| @ -145,6 +145,7 @@ export default { | ||||
|   }, | ||||
|   methods: { | ||||
|     ...mapActions('auth', ['login']), | ||||
|     ...mapActions('notification', ['showNotification']), | ||||
|     async validateBeforeSubmit() { | ||||
|       axios.defaults.withCredentials = true | ||||
|  | ||||
| @ -158,6 +159,10 @@ export default { | ||||
|       try { | ||||
|         await this.login(this.loginData) | ||||
|         this.$router.push('/admin/dashboard') | ||||
|         this.showNotification({ | ||||
|           type: 'success', | ||||
|           message: 'Logged in successfully.', | ||||
|         }) | ||||
|         this.isLoading = false | ||||
|       } catch (error) { | ||||
|         this.isLoading = false | ||||
|  | ||||
| @ -92,6 +92,7 @@ const { | ||||
|   sameAs, | ||||
|   minLength, | ||||
| } = require('vuelidate/lib/validators') | ||||
| import { mapActions } from 'vuex' | ||||
|  | ||||
| export default { | ||||
|   data() { | ||||
| @ -120,6 +121,7 @@ export default { | ||||
|     }, | ||||
|   }, | ||||
|   methods: { | ||||
|     ...mapActions('notification', ['showNotification']), | ||||
|     async validateBeforeSubmit(e) { | ||||
|       this.$v.formData.$touch() | ||||
|  | ||||
| @ -135,18 +137,18 @@ export default { | ||||
|           let res = await axios.post('/api/v1/auth/reset/password', data) | ||||
|           this.isLoading = false | ||||
|           if (res.data) { | ||||
|             toastr['success']( | ||||
|               this.$t('login.password_reset_successfully'), | ||||
|               'Success' | ||||
|             ) | ||||
|             this.showNotification({ | ||||
|               type: 'success', | ||||
|               message: this.$t('login.password_reset_successfully'), | ||||
|             }) | ||||
|             this.$router.push('/login') | ||||
|           } | ||||
|         } catch (err) { | ||||
|           if (err.response && err.response.status === 403) { | ||||
|             toastr['error']( | ||||
|               err.response.data, | ||||
|               this.$t('validation.email_incorrect') | ||||
|             ) | ||||
|             this.showNotification({ | ||||
|               type: 'error', | ||||
|               message: this.$t('validation.email_incorrect'), | ||||
|             }) | ||||
|             this.isLoading = false | ||||
|           } | ||||
|         } | ||||
|  | ||||
		Reference in New Issue
	
	Block a user