ccfdcc0e2fdf3101565c52def4740f0c82c9c794b68ac52380242257a25fe9c5.json 7.8 KB

1
  1. {"ast":null,"code":"import { __decorate } from \"tslib\";\nimport __NG_CLI_RESOURCE__0 from \"./edit-profil-info-user.component.html?ngResource\";\nimport __NG_CLI_RESOURCE__1 from \"./edit-profil-info-user.component.scss?ngResource\";\nimport { UsersService } from './../../../../services/users.service';\nimport { AuthService } from 'src/app/services/auth.service';\nimport { FormBuilder, Validators } from '@angular/forms';\nimport { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';\nimport { Component, Inject } from '@angular/core';\nimport { Router } from '@angular/router';\nlet EditProfilInfoUserComponent = class EditProfilInfoUserComponent {\n constructor(element, router, authService, dialogRef, formBuilder, usersService) {\n this.element = element;\n this.router = router;\n this.authService = authService;\n this.dialogRef = dialogRef;\n this.formBuilder = formBuilder;\n this.usersService = usersService;\n this.submitted = false;\n this.loading = false;\n this.user = this.element;\n }\n ngOnInit() {\n this.createForm();\n }\n createForm() {\n let phonenumberregex = /^(?:(?:\\+|00)33|0)\\s*[1-9](?:[\\s.-]*\\d{2}){4}$/;\n this.formGroup = this.formBuilder.group({\n phonenumber: [Validators.pattern(phonenumberregex)],\n adress: []\n });\n }\n // login\n updateProfil() {\n this.submitted = true;\n if (this.formGroup.invalid) {\n return;\n }\n this.usersService.editOneUser(this.element._id, this.formGroup.value).subscribe(data => {\n // this.router.navigate([this.returnUrl]);\n console.log(data);\n this.loading = false;\n this.dialogRef.close(true);\n //this.router.navigate(['auth']);\n }, err => {\n this.loading = false;\n console.log(err.error.message);\n this.authService.openSnackBar(err.error.message);\n });\n }\n getErrorPhonenumber() {\n return this.formGroup.get('phonenumber').hasError('pattern') ? 'Numéro de téléphone non valide' : '';\n }\n onConfirm() {\n // Close the dialog, return true\n this.dialogRef.close(true);\n }\n onNoClick() {\n this.dialogRef.close(false);\n }\n static #_ = this.ctorParameters = () => [{\n type: undefined,\n decorators: [{\n type: Inject,\n args: [MAT_DIALOG_DATA]\n }]\n }, {\n type: Router\n }, {\n type: AuthService\n }, {\n type: MatDialogRef\n }, {\n type: FormBuilder\n }, {\n type: UsersService\n }];\n};\nEditProfilInfoUserComponent = __decorate([Component({\n selector: 'app-edit-profil-info-user',\n template: __NG_CLI_RESOURCE__0,\n styles: [__NG_CLI_RESOURCE__1]\n})], EditProfilInfoUserComponent);\nexport { EditProfilInfoUserComponent };","map":{"version":3,"names":["UsersService","AuthService","FormBuilder","Validators","MatDialogRef","MAT_DIALOG_DATA","Component","Inject","Router","EditProfilInfoUserComponent","constructor","element","router","authService","dialogRef","formBuilder","usersService","submitted","loading","user","ngOnInit","createForm","phonenumberregex","formGroup","group","phonenumber","pattern","adress","updateProfil","invalid","editOneUser","_id","value","subscribe","data","console","log","close","err","error","message","openSnackBar","getErrorPhonenumber","get","hasError","onConfirm","onNoClick","_","args","__decorate","selector","template","__NG_CLI_RESOURCE__0"],"sources":["C:\\FatboarProject\\angular-client\\src\\app\\components\\auth\\profil\\edit-profil-info-user\\edit-profil-info-user.component.ts"],"sourcesContent":["import { UsersService } from './../../../../services/users.service';\r\nimport { AuthService } from 'src/app/services/auth.service'\r\nimport { FormBuilder, FormGroup, Validators } from '@angular/forms';\r\nimport { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';\r\nimport { User } from './../../../../models/userResponse';\r\nimport { Component, Inject, OnInit } from '@angular/core';\r\nimport { Router } from '@angular/router';\r\n\r\n@Component({\r\n selector: 'app-edit-profil-info-user',\r\n templateUrl: './edit-profil-info-user.component.html',\r\n styleUrls: ['./edit-profil-info-user.component.scss']\r\n})\r\nexport class EditProfilInfoUserComponent implements OnInit {\r\n\r\n constructor(@Inject(MAT_DIALOG_DATA) public element: User, public router: Router, private authService : AuthService, public dialogRef: MatDialogRef<EditProfilInfoUserComponent>,\r\n private formBuilder: FormBuilder, private usersService: UsersService )\r\n {}\r\n formGroup: FormGroup;\r\n submitted = false;\r\n loading = false;\r\n user = this.element\r\n\r\n ngOnInit(): void {\r\n\r\n this.createForm(); \r\n }\r\n\r\n\r\n\r\n createForm() {\r\n \r\n let phonenumberregex : RegExp = /^(?:(?:\\+|00)33|0)\\s*[1-9](?:[\\s.-]*\\d{2}){4}$/;\r\n this.formGroup = this.formBuilder.group({\r\n phonenumber: [Validators.pattern(phonenumberregex)],\r\n adress:[]\r\n });\r\n }\r\n\r\n\r\n // login\r\n updateProfil(){\r\n\r\n this.submitted = true;\r\n if (this.formGroup.invalid) {\r\n return;\r\n }\r\n this.usersService.editOneUser(this.element._id, this.formGroup.value).subscribe(\r\n data => {\r\n // this.router.navigate([this.returnUrl]);\r\n console.log(data)\r\n this.loading = false;\r\n this.dialogRef.close(true);\r\n //this.router.navigate(['auth']);\r\n },\r\n err => {\r\n this.loading = false;\r\n console.log(err.error.message)\r\n this.authService.openSnackBar(err.error.message)\r\n });\r\n}\r\n\r\n\r\n\r\n\r\n\r\ngetErrorPhonenumber() {\r\n return this.formGroup.get('phonenumber').hasError('pattern') ? 'Numéro de téléphone non valide' : '';\r\n}\r\n\r\n\r\n\r\n\r\n \r\n onConfirm(): void {\r\n // Close the dialog, return true\r\n this.dialogRef.close(true);\r\n }\r\n\r\n onNoClick(): void {\r\n this.dialogRef.close(false);\r\n }\r\n\r\n}"],"mappings":";;;AAAA,SAASA,YAAY,QAAQ,sCAAsC;AACnE,SAASC,WAAW,QAAQ,+BAA+B;AAC3D,SAASC,WAAW,EAAaC,UAAU,QAAQ,gBAAgB;AACnE,SAASC,YAAY,EAAEC,eAAe,QAAQ,0BAA0B;AAExE,SAASC,SAAS,EAAEC,MAAM,QAAgB,eAAe;AACzD,SAASC,MAAM,QAAQ,iBAAiB;AAOjC,IAAMC,2BAA2B,GAAjC,MAAMA,2BAA2B;EAEtCC,YAA4CC,OAAa,EAASC,MAAc,EAAUC,WAAyB,EAAUC,SAAoD,EACvKC,WAAwB,EAAUC,YAA0B;IAD1B,KAAAL,OAAO,GAAPA,OAAO;IAAe,KAAAC,MAAM,GAANA,MAAM;IA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