7fa984f6f0832a62860e760f8d284f419b15f9292ce82a372cba1dc7042d5cb0.json 7.8 KB

1
  1. {"ast":null,"code":"import { ConfirmComponent } from './confirm/confirm.component';\nimport { Validators } from '@angular/forms';\nimport * as i0 from \"@angular/core\";\nimport * as i1 from \"src/app/services/contact.service\";\nimport * as i2 from \"src/app/services/auth.service\";\nimport * as i3 from \"@angular/forms\";\nimport * as i4 from \"@angular/material/dialog\";\nfunction FormulaireComponent_mat_progress_bar_3_Template(rf, ctx) {\n if (rf & 1) {\n i0.ɵɵelement(0, \"mat-progress-bar\", 11);\n }\n}\nfunction FormulaireComponent_mat_error_12_Template(rf, ctx) {\n if (rf & 1) {\n i0.ɵɵelementStart(0, \"mat-error\");\n i0.ɵɵtext(1);\n i0.ɵɵelementEnd();\n }\n if (rf & 2) {\n const ctx_r1 = i0.ɵɵnextContext();\n i0.ɵɵadvance(1);\n i0.ɵɵtextInterpolate1(\" \", ctx_r1.getErrorLastname(), \" \");\n }\n}\nfunction FormulaireComponent_mat_error_18_Template(rf, ctx) {\n if (rf & 1) {\n i0.ɵɵelementStart(0, \"mat-error\");\n i0.ɵɵtext(1);\n i0.ɵɵelementEnd();\n }\n if (rf & 2) {\n const ctx_r2 = i0.ɵɵnextContext();\n i0.ɵɵadvance(1);\n i0.ɵɵtextInterpolate1(\" \", ctx_r2.getErrorEmail(), \" \");\n }\n}\nfunction FormulaireComponent_mat_error_24_Template(rf, ctx) {\n if (rf & 1) {\n i0.ɵɵelementStart(0, \"mat-error\");\n i0.ɵɵtext(1);\n i0.ɵɵelementEnd();\n }\n if (rf & 2) {\n const ctx_r3 = i0.ɵɵnextContext();\n i0.ɵɵadvance(1);\n i0.ɵɵtextInterpolate1(\" \", ctx_r3.getErrorMessage(), \" \");\n }\n}\nconst googleLogoURL = \"../assets/img/social/google+.svg\";\nconst facebookLogoURL = \"../assets/img/social/facebook.svg\";\nexport let FormulaireComponent = /*#__PURE__*/(() => {\n class FormulaireComponent {\n constructor(contactService, authService, formBuilder, dialog) {\n this.contactService = contactService;\n this.authService = authService;\n this.formBuilder = formBuilder;\n this.dialog = dialog;\n this.submitted = false;\n this.loading = false;\n }\n ngOnInit() {\n this.createForm();\n }\n createForm() {\n let caracereregex = /^[a-zA-ZàáâäãåąčćęèéêëėįìíîïłńòóôöõøùúûüųūÿýżźñçčšžÀÁÂÄÃÅĄĆČĖĘÈÉÊËÌÍÎÏĮŁŃÒÓÔÖÕØÙÚÛÜŲŪŸÝŻŹÑßÇŒÆČŠŽ∂ð ,.'-]+$/;\n let emailregex = /^(([^<>()\\[\\]\\\\.,;:\\s@\"]+(\\.[^<>()\\[\\]\\\\.,;:\\s@\"]+)*)|(\".+\"))@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}])|(([a-zA-Z\\-0-9]+\\.)+[a-zA-Z]{2,}))$/;\n this.formGroup = this.formBuilder.group({\n lastname: [null, [Validators.required, Validators.pattern(caracereregex)]],\n email: [null, [Validators.required, Validators.pattern(emailregex)]],\n message: [null, Validators.required]\n });\n }\n getErrorLastname() {\n return this.formGroup.get('lastname').hasError('required') ? 'Nom requis' : this.formGroup.get('lastname').hasError('pattern') ? 'Nom non valide' : '';\n }\n getErrorEmail() {\n return this.formGroup.get('email').hasError('required') ? 'Adresse email requise' : this.formGroup.get('email').hasError('pattern') ? 'Adresse email non valide' : '';\n }\n getErrorMessage() {\n return this.formGroup.get('message').hasError('required') ? 'Message requis' : '';\n }\n get f() {\n return this.formGroup.controls;\n }\n sendMsgContact() {\n this.submitted = true;\n if (this.formGroup.invalid) {\n return;\n }\n this.loading = true;\n this.contactService.sendMsgContact(this.formGroup.value).subscribe(data => {\n console.log(data);\n this.response = data.message;\n this.loading = false;\n this.openDialog();\n }, err => {\n this.loading = false;\n console.log(err.error.message);\n this.authService.openSnackBar(err.error.message);\n });\n }\n openDialog() {\n const dialogRef = this.dialog.open(ConfirmComponent, {\n height: '40%',\n width: '38%',\n data: {\n response: this.response\n }\n });\n dialogRef.afterClosed().subscribe(() => {\n location.reload();\n });\n }\n static #_ = this.ɵfac = function FormulaireComponent_Factory(t) {\n return new (t || FormulaireComponent)(i0.ɵɵdirectiveInject(i1.ContactService), i0.ɵɵdirectiveInject(i2.AuthService), i0.ɵɵdirectiveInject(i3.FormBuilder), i0.ɵɵdirectiveInject(i4.MatDialog));\n };\n static #_2 = this.ɵcmp = /*@__PURE__*/i0.ɵɵdefineComponent({\n type: FormulaireComponent,\n selectors: [[\"app-formulaire\"]],\n decls: 28,\n vars: 5,\n consts: [[1, \"\"], [3, \"formGroup\", \"ngSubmit\"], [\"class\", \"row \", \"mode\", \"indeterminate\", 4, \"ngIf\"], [1, \"row\", \"justify-content-center\"], [\"appearance\", \"outline\", 1, \"col-10\"], [\"matInput\", \"\", \"placeholder\", \"Nom\", \"formControlName\", \"lastname\"], [4, \"ngIf\"], [\"matInput\", \"\", \"placeholder\", \"Adresse email\", \"formControlName\", \"email\"], [\"rows\", \"7\", \"matInput\", \"\", \"formControlName\", \"message\"], [1, \"row\", \"justify-content-center\", \"mt-3\", \"mb-2\"], [\"mat-raised-button\", \"\", \"color\", \"primary\", \"type\", \"submit\", 1, \"col-6\", \"color-theme\"], [\"mode\", \"indeterminate\", 1, \"row\"]],\n template: function FormulaireComponent_Template(rf, ctx) {\n if (rf & 1) {\n i0.ɵɵelementStart(0, \"mat-card\", 0)(1, \"mat-card-content\")(2, \"form\", 1);\n i0.ɵɵlistener(\"ngSubmit\", function FormulaireComponent_Template_form_ngSubmit_2_listener() {\n return ctx.sendMsgContact();\n });\n i0.ɵɵtemplate(3, FormulaireComponent_mat_progress_bar_3_Template, 1, 0, \"mat-progress-bar\", 2);\n i0.ɵɵelementStart(4, \"h1\", 3)(5, \"b\");\n i0.ɵɵtext(6, \"Contactez-nous\");\n i0.ɵɵelementEnd()();\n i0.ɵɵelementStart(7, \"div\", 3)(8, \"mat-form-field\", 4)(9, \"mat-label\");\n i0.ɵɵtext(10, \"Nom\");\n i0.ɵɵelementEnd();\n i0.ɵɵelement(11, \"input\", 5);\n i0.ɵɵtemplate(12, FormulaireComponent_mat_error_12_Template, 2, 1, \"mat-error\", 6);\n i0.ɵɵelementEnd()();\n i0.ɵɵelementStart(13, \"div\", 3)(14, \"mat-form-field\", 4)(15, \"mat-label\");\n i0.ɵɵtext(16, \"Adresse email\");\n i0.ɵɵelementEnd();\n i0.ɵɵelement(17, \"input\", 7);\n i0.ɵɵtemplate(18, FormulaireComponent_mat_error_18_Template, 2, 1, \"mat-error\", 6);\n i0.ɵɵelementEnd()();\n i0.ɵɵelementStart(19, \"div\", 3)(20, \"mat-form-field\", 4)(21, \"mat-label\");\n i0.ɵɵtext(22, \"Message\");\n i0.ɵɵelementEnd();\n i0.ɵɵelement(23, \"textarea\", 8);\n i0.ɵɵtemplate(24, FormulaireComponent_mat_error_24_Template, 2, 1, \"mat-error\", 6);\n i0.ɵɵelementEnd()();\n i0.ɵɵelementStart(25, \"div\", 9)(26, \"button\", 10);\n i0.ɵɵtext(27, \"Envoyer\");\n i0.ɵɵelementEnd()()()()();\n }\n if (rf & 2) {\n i0.ɵɵadvance(2);\n i0.ɵɵproperty(\"formGroup\", ctx.formGroup);\n i0.ɵɵadvance(1);\n i0.ɵɵproperty(\"ngIf\", ctx.loading);\n i0.ɵɵadvance(9);\n i0.ɵɵproperty(\"ngIf\", !ctx.formGroup.controls[\"lastname\"].valid && ctx.formGroup.controls[\"lastname\"].touched);\n i0.ɵɵadvance(6);\n i0.ɵɵproperty(\"ngIf\", !ctx.formGroup.controls[\"email\"].valid && ctx.formGroup.controls[\"email\"].touched);\n i0.ɵɵadvance(6);\n i0.ɵɵproperty(\"ngIf\", !ctx.formGroup.controls[\"message\"].valid && ctx.formGroup.controls[\"message\"].touched);\n }\n }\n });\n }\n return FormulaireComponent;\n})();","map":null,"metadata":{},"sourceType":"module","externalDependencies":[]}