partie 'beforeConnexion' entierement connectée avec le back

This commit is contained in:
MiharyR 2021-12-11 14:17:10 +01:00
parent 411cea6ff0
commit cf3c596c7b
4 changed files with 39 additions and 15 deletions

View file

@ -6,7 +6,8 @@ import {MessageService} from "../../../utils/services/message/message.service";
import {map, startWith} from "rxjs/operators"; import {map, startWith} from "rxjs/operators";
import {MatChipInputEvent} from "@angular/material/chips"; import {MatChipInputEvent} from "@angular/material/chips";
import {MatAutocompleteSelectedEvent} from "@angular/material/autocomplete"; import {MatAutocompleteSelectedEvent} from "@angular/material/autocomplete";
import {FictitiousUtilsService} from "../../../utils/services/fictitiousDatas/fictitiousUtils/fictitious-utils.service";
@Component({ @Component({
selector: 'app-input-interests-register', selector: 'app-input-interests-register',
@ -26,8 +27,7 @@ export class InputInterestsRegisterComponent implements OnInit
@ViewChild('tagInput') tagInput: ElementRef<HTMLInputElement>; @ViewChild('tagInput') tagInput: ElementRef<HTMLInputElement>;
constructor( private fictitiousUtilsService: FictitiousUtilsService, constructor( private messageService: MessageService ) {}
private messageService: MessageService ) {}
ngOnInit(): void ngOnInit(): void
@ -36,10 +36,20 @@ export class InputInterestsRegisterComponent implements OnInit
startWith(null), startWith(null),
map((fruit: string | null) => fruit ? this._filter(fruit) : this.allInterests.slice())); map((fruit: string | null) => fruit ? this._filter(fruit) : this.allInterests.slice()));
// --- FAUX CODE --- this.messageService
this.allInterests = this.fictitiousUtilsService.getTags(); .get("misc/getInterests", {})
.subscribe( retour => {
if(retour.status !== "success") {
console.log(retour);
}
else {
this.allInterests = [];
for(let elt of retour.data) this.allInterests.push(elt.interest);
this.allInterests.sort(); this.allInterests.sort();
} }
});
}
add(event: MatChipInputEvent): void add(event: MatChipInputEvent): void

View file

@ -109,9 +109,9 @@
</mat-form-field> </mat-form-field>
<!-- interests --> <!-- interests -->
<app-input-interests-profil <app-input-interests-register
[myInterests]="user.interests" [myInterests]="user.interests"
(eventEmitter)="onEventInputInterests($event)"></app-input-interests-profil> (eventEmitter)="onEventInputInterests($event)"></app-input-interests-register>
</div> </div>
</div> </div>

View file

@ -53,21 +53,23 @@ export class PageRegisterComponent
this.checkField(); this.checkField();
if(!this.hasError) if(!this.hasError)
{ {
if(this.user.role.name === "user") this.user.role.permission = 0; let data: any = Object.assign({}, this.user);
else this.user.role.permission = 5; if(this.user.role.name === "user") data.role = "user" ;
this.user.hashPass = this.password; else data.role = "advertiser";
data.hashPass = this.password;
this.messageService this.messageService
.post('user/create', this.user) .post('user/create', data)
.subscribe(retour => this.onEnregistrerCallback(retour), err => this.onEnregistrerCallback(err)); .subscribe(retour => this.onEnregistrerCallback(retour), err => this.onEnregistrerCallback(err));
} }
} }
// Gestion de la réponde du backend // Gestion de la réponse du backend
onEnregistrerCallback(retour): void onEnregistrerCallback(retour): void
{ {
if(retour.status !== "success") {
console.log(retour); console.log(retour);
if(retour.status !== "success") {
} }
else else
{ {

View file

@ -11,7 +11,7 @@ export interface User
profileImageUrl: string, profileImageUrl: string,
dateOfBirth: Date, dateOfBirth: Date,
gender: string, gender: string,
interests: string[], interests: any[],
company: string, company: string,
isActive: boolean, isActive: boolean,
isAccepted: boolean, isAccepted: boolean,
@ -19,3 +19,15 @@ export interface User
createdAt: Date, createdAt: Date,
updatedAt: Date updatedAt: Date
} }
interface VideoCategorie
{
id: number
interest: string
categories: {
id: string
name: string
source: string
}
}