129d83c368ddf6b88a6abc3a7cdff1e0c9b7baee7e2400349e97db77c2008461.json 4.9 KB

1
  1. {"ast":null,"code":"import { Validators } from '@angular/forms';\nimport * as i0 from \"@angular/core\";\nimport * as i1 from \"src/app/services/auth.service\";\nimport * as i2 from \"src/app/services/users.service\";\nimport * as i3 from \"@angular/forms\";\nimport * as i4 from \"@angular/common/http\";\nimport * as i5 from \"@angular/material/snack-bar\";\nfunction TirageComponent_mat_error_10_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_r0 = i0.ɵɵnextContext();\n i0.ɵɵadvance(1);\n i0.ɵɵtextInterpolate1(\" \", ctx_r0.messageError, \" \");\n }\n}\nexport let TirageComponent = /*#__PURE__*/(() => {\n class TirageComponent {\n constructor(authService, userService, fb, http, snackbar) {\n this.authService = authService;\n this.userService = userService;\n this.fb = fb;\n this.http = http;\n this.snackbar = snackbar;\n this.URL = \"http://localhost:4000\";\n this.messageError = null;\n this.tirage = {\n message: '',\n success: false\n };\n }\n ngOnInit() {\n this.authService.getUserInfo().subscribe(user => this.user = user);\n this.createdForm();\n }\n createdForm() {\n this.formTirage = this.fb.group({\n date: ['', Validators.required]\n });\n }\n postDateTirage() {\n console.log('date: ', this.formTirage.value);\n const tiragedate = this.formTirage.value;\n const reponse = this.http.post(`${this.URL}/api/tirage/date`, tiragedate);\n reponse.toPromise().then(res => {\n this.snackbar.open(res.message, 'close');\n }).catch(err => {\n console.log('message erreur =>', err.error.message);\n this.messageError = err.error.message;\n });\n }\n getTirage() {\n const resultatTirage = this.http.get(`${this.URL}/api/tirage`);\n resultatTirage.toPromise().then(res => {\n this.tirage = res;\n console.log('resultar ', this.tirage);\n }).catch(err => console.log('err', err));\n }\n getWinner(user) {}\n static #_ = this.ɵfac = function TirageComponent_Factory(t) {\n return new (t || TirageComponent)(i0.ɵɵdirectiveInject(i1.AuthService), i0.ɵɵdirectiveInject(i2.UsersService), i0.ɵɵdirectiveInject(i3.FormBuilder), i0.ɵɵdirectiveInject(i4.HttpClient), i0.ɵɵdirectiveInject(i5.MatSnackBar));\n };\n static #_2 = this.ɵcmp = /*@__PURE__*/i0.ɵɵdefineComponent({\n type: TirageComponent,\n selectors: [[\"app-tirage\"]],\n decls: 21,\n vars: 3,\n consts: [[1, \"navtop\"], [3, \"formGroup\", \"ngSubmit\"], [1, \"row\", \"justify-content-center\", \"mt-3\"], [\"appearance\", \"fill\", 1, \"formu\"], [\"matInput\", \"\", \"formControlName\", \"date\", \"type\", \"date\"], [4, \"ngIf\"], [\"mat-raised-button\", \"\", \"color\", \"primary\", \"type\", \"submit\", 1, \"col-4\", \"color-theme\"], [\"mat-raised-button\", \"\", \"color\", \"primary\", 1, \"col-4\", \"color-theme\", 3, \"click\"]],\n template: function TirageComponent_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 TirageComponent_Template_form_ngSubmit_2_listener() {\n return ctx.postDateTirage();\n });\n i0.ɵɵelementStart(3, \"div\", 2)(4, \"div\")(5, \"mat-form-field\", 3)(6, \"mat-label\");\n i0.ɵɵtext(7, \"Choose a date\");\n i0.ɵɵelementEnd();\n i0.ɵɵelement(8, \"input\", 4);\n i0.ɵɵelementEnd()()();\n i0.ɵɵelementStart(9, \"div\", 2);\n i0.ɵɵtemplate(10, TirageComponent_mat_error_10_Template, 2, 1, \"mat-error\", 5);\n i0.ɵɵelementEnd();\n i0.ɵɵelementStart(11, \"div\", 2)(12, \"button\", 6);\n i0.ɵɵtext(13, \"Excuter\");\n i0.ɵɵelementEnd()()()();\n i0.ɵɵelementStart(14, \"mat-card-content\")(15, \"div\", 2)(16, \"button\", 7);\n i0.ɵɵlistener(\"click\", function TirageComponent_Template_button_click_16_listener() {\n return ctx.getTirage();\n });\n i0.ɵɵtext(17, \"Lancer le tirage\");\n i0.ɵɵelementEnd()();\n i0.ɵɵelementStart(18, \"div\", 2);\n i0.ɵɵtext(19);\n i0.ɵɵelementEnd()();\n i0.ɵɵelement(20, \"mat-card-content\");\n i0.ɵɵelementEnd();\n }\n if (rf & 2) {\n i0.ɵɵadvance(2);\n i0.ɵɵproperty(\"formGroup\", ctx.formTirage);\n i0.ɵɵadvance(8);\n i0.ɵɵproperty(\"ngIf\", ctx.messageError != null);\n i0.ɵɵadvance(9);\n i0.ɵɵtextInterpolate1(\" \", ctx.tirage.message, \" \");\n }\n },\n styles: [\".navtop[_ngcontent-%COMP%]{margin-top:12em}\"]\n });\n }\n return TirageComponent;\n})();","map":null,"metadata":{},"sourceType":"module","externalDependencies":[]}