Skip to content
This repository has been archived by the owner on Oct 2, 2024. It is now read-only.

Commit

Permalink
Merge pull request #227 from wrth1337/general-polish-wrth1337
Browse files Browse the repository at this point in the history
General polish wrth1337
  • Loading branch information
wrth1337 authored Mar 17, 2024
2 parents 2fa78ba + 5313474 commit a997b7f
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 27 deletions.
2 changes: 1 addition & 1 deletion backend/routes/offer.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ async function addOffer(description, startLocation, endLocation, startDate, endD
const addOfferAd = `
INSERT INTO ad (description, startLocation, endLocation, startDate, endDate, animals, smoker, notes, numSeats, userId)
VALUES (?,?,?,?,?,?,?,?,?,?)`;
const addOffer = 'INSERT INTO offer (vehicleId, adId, pricePerPerson, pricePerFreight) VALUES (?, ?, ?, ?)';
const addOffer = 'INSERT INTO offer (vehicleId, adId, pricePerPerson, pricePerFreight) VALUES (?, last_insert_id(), ?, ?)';

try {
const conn = await pool.getConnection();
Expand Down
17 changes: 3 additions & 14 deletions frontend/mycargonaut/src/app/main/ad/ad.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,6 @@
<div class="m-2">
<app-profile-data style="height: 100%"></app-profile-data>
</div>
<div class="profile m-2">
<div *ngIf="this.type === 'offer'">
Price per Person: {{typeSpecificContent.pricePerPerson}} <br>
Price per Freight: {{typeSpecificContent.pricePerFreight}}
</div>
<div *ngIf="this.type === 'wanted'">
Preis: {{typeSpecificContent.price}} <br>
Fracht: {{typeSpecificContent.freight}} <br>
Sitze: {{typeSpecificContent.numSeats}}
</div>
</div>
</div>
</div>
</div>
Expand Down Expand Up @@ -126,7 +115,7 @@ <h5 class="card-title adCardTitle p-1">{{writeTitle(ad)}}</h5>
<div class="container borderPrimary p-3">
<div class="row d-flex align-items-center justify-content-center">
<div class="col-6">
<span class="medium"> </span>
<span class="medium"> {{typeSpecificContent.price}} </span>
</div>
<div class="col-6">
<span class="material-symbols-outlined" style="font-size: xxx-large">toll</span>
Expand Down Expand Up @@ -172,12 +161,12 @@ <h5 class="card-title adCardTitle p-1">{{writeTitle(ad)}}</h5>
<input id="seats" class="form-control mx-2 mb-2 input-field" type="number" name="numSeats" placeholder="Anzahl Sitzplätze" min="1" [max]="this.seatsAvailable" ngModel [(ngModel)]="this.default">
<span class="ms-2">Menge an Fracht in Kg</span>
<input id="freight" class="form-control mx-2 mb-2 me-2 input-field" type="number" name="freight" placeholder="Menge Fracht" min="0" ngModel>
<span class="ms-2 price fs-4 ">Gesamtpreis: </span>
<span class="ms-2 price fs-4 ">Gesamtpreis: </span>
<span class="ms-2 price fs-4 " style="color: var(--primary);">{{this.typeSpecificContent.pricePerFreight * bookingForm.value.freight+ this.typeSpecificContent.pricePerPerson * bookingForm.value.numSeats}}</span>
</div>
<div *ngIf="this.type==='wanted'" class="modal-body">
<p class="fs-3">Wollen Sie diese Fahrt übernehmen?</p>
<span class="ms-2 price fs-4 ">Angebotener Gesamtpreis: </span>
<span class="ms-2 price fs-4 ">Angebotener Gesamtpreis: </span>
<span class="ms-2 price fs-4 " style="color: var(--primary);">{{this.typeSpecificContent.price}}</span>
</div>
<div class="modal-footer">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ export class CreateOfferComponent {
this.error = false;
this.pet = true;
this.smoke = true;
} else {
this.error = true;
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ describe('EditProfileComponent', () => {
lastName: 'Mustermann',
birthdate: '01.01.2000',
description: 'Beschreibung',
experience: 'Erfahrung'
experience: 'Erfahrung',
picture: 'URL_DES_PROFILBILDS'
};
localStorage.setItem('userData','{"email":"[email protected]","user_id":4}');
fixture.detectChanges();
Expand Down Expand Up @@ -74,16 +75,21 @@ describe('EditProfileComponent', () => {
});

it('should display placeholder when no profile picture is available', () => {
component.userData = {
firstName: 'Max',
lastName: 'Mustermann',
birthdate: '01.01.2000',
description: 'Beschreibung',
experience: 'Erfahrung',
picture: ''
};
fixture.detectChanges();
const el = fixture.debugElement.query(By.css('.bi-person-circle'));
expect(el).toBeTruthy();

});

it('should display profile picture when available', () => {

component.userData = { picture: 'URL_DES_PROFILBILDS' };
fixture.detectChanges();

const el = fixture.debugElement.query(By.css('.profilepicture'));
const placeholder = fixture.debugElement.query(By.css('.bi-person-circle'));
expect(placeholder).toBeFalsy();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,14 @@ import { Location } from '@angular/common';


export class EditProfileComponent implements OnInit {
userData: any;
userData = {
firstName: '',
lastName: '',
birthdate: '',
picture: '',
description: '',
experience: ''
};
rating: any;
tripCount: any;
level = 1;
Expand Down Expand Up @@ -71,7 +78,7 @@ export class EditProfileComponent implements OnInit {
}

this.rating = Math.round(res.userData.rating);
this.userData.birthdate = this.datePipe.transform(res.userData.birthdate, 'dd.MM.yyyy');
this.userData.birthdate = this.datePipe.transform(res.userData.birthdate, 'dd.MM.yyyy')!;
});

this.api.getRequest("trip/getTripCount/"+userId).subscribe((res: any) => {
Expand All @@ -89,14 +96,13 @@ export class EditProfileComponent implements OnInit {

onSubmit(form: NgForm) {
form.value.language = this.language.map(lang => ({ languageId: lang.id, selected: this.languageVariables[lang.name] }));

if(!this.editUser) {
form.value.firstName = this.userData.firstName;
form.value.lastName = this.userData.lastName;
}
if(!this.editBirth) {
const birthdate = this.formatBirthdate();
this.userData.birthdate = this.datePipe.transform(birthdate, 'yyyy-MM-dd');
this.userData.birthdate = this.datePipe.transform(birthdate, 'yyyy-MM-dd')!;
form.value.birthdate = this.userData.birthdate;
}

Expand All @@ -107,7 +113,7 @@ export class EditProfileComponent implements OnInit {
this.success = true;
}
});
this.userData.birthdate = this.datePipe.transform(this.userData.birthdate, 'dd.MM.yyyy');
this.userData.birthdate = this.datePipe.transform(this.userData.birthdate, 'dd.MM.yyyy')!;
this.editUser = false;
this.editBirth = false;

Expand All @@ -125,11 +131,11 @@ export class EditProfileComponent implements OnInit {
editBirthdate() {
this.editBirth = !this.editBirth;
if(!this.editBirth) {
this.userData.birthdate = this.datePipe.transform(this.userData.birthdate, 'dd.MM.yyyy');
this.userData.birthdate = this.datePipe.transform(this.userData.birthdate, 'dd.MM.yyyy')!;
}
else {
const birthdate = this.formatBirthdate();
this.userData.birthdate = this.datePipe.transform(birthdate, 'yyyy-MM-dd');
this.userData.birthdate = this.datePipe.transform(birthdate, 'yyyy-MM-dd')!;
}
}

Expand Down

0 comments on commit a997b7f

Please sign in to comment.