From 834a7efc96ac7cced05047437dd96572438781ff Mon Sep 17 00:00:00 2001 From: Pedro Maximino <53193337+PMax5@users.noreply.github.com> Date: Thu, 18 Jan 2024 11:27:07 +0100 Subject: [PATCH] refact: Change payloads to match new API requests and responses --- .../admin/links/complete-company-info.pipe.ts | 2 +- src/app/admin/links/link/companies.ts | 2 +- src/app/admin/links/links.service.ts | 10 +++---- src/app/admin/login/login.component.ts | 1 + src/app/admin/login/login.service.ts | 8 +++--- src/app/deck/company.ts | 28 ++++++++++++++----- src/app/deck/deck.service.ts | 6 ++-- 7 files changed, 37 insertions(+), 20 deletions(-) diff --git a/src/app/admin/links/complete-company-info.pipe.ts b/src/app/admin/links/complete-company-info.pipe.ts index 6de7bfd..fa1597a 100644 --- a/src/app/admin/links/complete-company-info.pipe.ts +++ b/src/app/admin/links/complete-company-info.pipe.ts @@ -20,7 +20,7 @@ export class CompleteCompanyInfoPipe implements PipeTransform { if (event === undefined) { return result; } - const participation = Participation.getFromEvent(complete[index].participations, event); + const participation = Participation.getFromEvent(complete[index].participation, event); if (participation) { result.currentParticipation = participation; diff --git a/src/app/admin/links/link/companies.ts b/src/app/admin/links/link/companies.ts index 2825cde..b9921c9 100644 --- a/src/app/admin/links/link/companies.ts +++ b/src/app/admin/links/link/companies.ts @@ -45,7 +45,7 @@ export class Companies { newCompany.currentParticipation = company.currentParticipation ? company.currentParticipation - : Participation.getFromEdition(company.participations, filtered[0].edition); + : Participation.getFromEdition(company.participation, filtered[0].edition); newCompany.link = link; if (link.valid) { diff --git a/src/app/admin/links/links.service.ts b/src/app/admin/links/links.service.ts index 6fd4feb..eea6a33 100644 --- a/src/app/admin/links/links.service.ts +++ b/src/app/admin/links/links.service.ts @@ -47,12 +47,12 @@ export class LinksService { const eventOverride = this.event !== undefined && this.event.id !== event.id; this.event = event; if (eventOverride) { this.updateLinks(event.id as string); } - }); - this.deckCompaniesSubscription = this.deckService.getDeckCompaniesSubject() - .subscribe(companies => { - this.companies.updateCompanies(companies, this.event.id); - this.updateLinks(); + this.deckCompaniesSubscription = this.deckService.getDeckCompaniesSubject() + .subscribe(companies => { + this.companies.updateCompanies(companies, this.event.id.toString()); + this.updateLinks(); + }); }); } diff --git a/src/app/admin/login/login.component.ts b/src/app/admin/login/login.component.ts index f4ddde6..7349f73 100644 --- a/src/app/admin/login/login.component.ts +++ b/src/app/admin/login/login.component.ts @@ -49,6 +49,7 @@ export class LoginComponent implements OnInit { auto_select: false, cancel_on_tap_outside: true, ux_mode: "popup", + hd: "sinfo.org" }); this.renderGoogleButton(); } diff --git a/src/app/admin/login/login.service.ts b/src/app/admin/login/login.service.ts index a7ff2ab..08da331 100644 --- a/src/app/admin/login/login.service.ts +++ b/src/app/admin/login/login.service.ts @@ -25,11 +25,11 @@ export class LoginService { ) { } getToken() { - return this.storage.getItem('corlief_token'); + return this.storage.getItem('token')['token']; } saveToken(credentials: String) { - this.storage.setItem('corlief_token', credentials); + this.storage.setItem('token', credentials); } login(user: String, token: String): Observable { @@ -37,11 +37,11 @@ export class LoginService { } logout() { - this.storage.removeItem('corlief_token'); + this.storage.removeItem('token'); this.router.navigate(['/login']); } isLoggedIn(): boolean { - return this.storage.getItem('corlief_token') !== null; + return this.storage.getItem('token') !== null; } } diff --git a/src/app/deck/company.ts b/src/app/deck/company.ts index 9da4d03..9baafc4 100644 --- a/src/app/deck/company.ts +++ b/src/app/deck/company.ts @@ -1,12 +1,26 @@ import { Link } from '../admin/links/link/link'; import { Event } from './event'; +export class Item { + name: String; + description: String; + type: String; + cost: Number; + vat: Number; +} + +export class Package { + name: String; + items?: [Item]; +} + export class Participation { event: String; member: String; status: String; kind: String; advertisementLvl: String; + partner: Boolean; static getFromEvent(participations: [Participation], event: Event): Participation { return Participation.getFromEdition(participations, event.id); @@ -14,7 +28,7 @@ export class Participation { static getFromEdition(participations: [Participation], edition: String): Participation { for (const p of participations) { - if (p.event === edition) { return p; } + if (p.event.toString() === edition) { return p; } } return null; } } @@ -22,28 +36,28 @@ export class Participation { export class Company { id: String; img: String; + description: String; name?: String; - participations?: [Participation]; + participation?: [Participation]; currentParticipation: Participation; link?: Link; static filter(company: Company, edition: String) { - if (company.participations === undefined || !company.participations.length) { + if (company.participation === undefined || !company.participation.length) { return false; } if (company.currentParticipation === undefined) { - company.currentParticipation = Participation.getFromEdition(company.participations, edition); + company.currentParticipation = Participation.getFromEdition(company.participation, edition); } - if (company.currentParticipation === null || company.currentParticipation.kind === 'Partnership') { + if (company.currentParticipation === null || company.currentParticipation.partner) { return false; } - return ['in-conversations', 'closed-deal', 'announced'] - .includes(company.currentParticipation.status as string); + return true; } static findById(id: String, companies: Company[]) { diff --git a/src/app/deck/deck.service.ts b/src/app/deck/deck.service.ts index 1e26884..455a55d 100644 --- a/src/app/deck/deck.service.ts +++ b/src/app/deck/deck.service.ts @@ -51,7 +51,9 @@ export class DeckService { private getCompanies(edition: String): void { this.http.get( `${this.deck}/companies?event=${edition}` - ).subscribe(companies => this.deckCompaniesSubject.next(companies)); + ).subscribe(companies => { + this.deckCompaniesSubject.next(companies) + }); } getEventSubject(): Observable { @@ -70,7 +72,7 @@ export class DeckService { this.events = Event.fromArray(events).sort(Event.compare) as [Event]; const filtered = edition - ? events.filter(e => e.id === edition)[0] + ? events.filter(e => e.id.toString() === edition)[0] : events[events.length - 1]; const event = new Event(filtered);