From 03a206dae79f4d0871663e4a0e7ad7f4c1fc728f Mon Sep 17 00:00:00 2001 From: Vic Date: Sun, 5 Jun 2022 21:45:13 +0200 Subject: [PATCH] changed cart reactive template to template driven + responsive fix --- src/app/app-routing.module.ts | 3 +- src/app/components/cart/cart.component.html | 84 +++++++++++++++---- src/app/components/cart/cart.component.scss | 1 - src/app/components/cart/cart.component.ts | 19 ++--- .../product-item-details.component.scss | 26 +++--- .../product-item/product-item.component.html | 6 +- .../product-item/product-item.component.scss | 13 +++ 7 files changed, 112 insertions(+), 40 deletions(-) diff --git a/src/app/app-routing.module.ts b/src/app/app-routing.module.ts index b672764..f5156c0 100644 --- a/src/app/app-routing.module.ts +++ b/src/app/app-routing.module.ts @@ -9,7 +9,8 @@ const routes: Routes = [ { path: '', component: HomeComponent }, { path: 'product/:id', component: ProductItemDetailsComponent }, { path: 'cart', component: CartComponent }, - { path: 'confirmation', component: ConfirmationComponent} + { path: 'confirmation', component: ConfirmationComponent}, + { path: '**', redirectTo: '/' } ]; @NgModule({ diff --git a/src/app/components/cart/cart.component.html b/src/app/components/cart/cart.component.html index 2be9a38..7426965 100644 --- a/src/app/components/cart/cart.component.html +++ b/src/app/components/cart/cart.component.html @@ -22,47 +22,87 @@ -
+ First Name - - + + First Name is required Last Name - - + + Last Name is required Email - - + + Please enter a valid email address - + Email is required Address - - + + Address is required - + Postal Code - - - Postal Code is required + + + Postal Code is required number @@ -76,3 +116,19 @@ + \ No newline at end of file diff --git a/src/app/components/cart/cart.component.scss b/src/app/components/cart/cart.component.scss index 1d283ce..8abf6d1 100644 --- a/src/app/components/cart/cart.component.scss +++ b/src/app/components/cart/cart.component.scss @@ -86,7 +86,6 @@ img { flex-direction: column; justify-content: center; align-items: center; - max-height: 60vh; padding: 4vh; padding-top: 5vh; padding-bottom: 5vh; diff --git a/src/app/components/cart/cart.component.ts b/src/app/components/cart/cart.component.ts index 3741531..48da345 100644 --- a/src/app/components/cart/cart.component.ts +++ b/src/app/components/cart/cart.component.ts @@ -2,7 +2,7 @@ import { Component, OnInit } from '@angular/core'; import { Router } from '@angular/router'; import { CartService } from '../../services/cart.service'; import { Product } from 'src/app/models/product'; -import { FormControl, Validators, FormGroup } from '@angular/forms'; +import { Form } from '@angular/forms'; @@ -18,13 +18,14 @@ export class CartComponent implements OnInit { cartItems: Product[] = [] totalPrice: number = 0 - checkoutForm = new FormGroup({ - firstname: new FormControl('', [Validators.required]), - lastname: new FormControl('', [Validators.required]), - email: new FormControl('', [Validators.required, Validators.email]), - address: new FormControl('', [Validators.required]), - postalcode: new FormControl('', [Validators.required]) - }); + firstname: string = '' + lastname: string = '' + email: string = '' + address: string = '' + postalcode: string = '' + + + constructor(private cartService: CartService, private router: Router) { } @@ -42,8 +43,6 @@ export class CartComponent implements OnInit { onSubmit(): void { // Your submit logic here (e.g., making an API call that sends form data) this.cartItems = this.cartService.clearCart(); - console.warn('Your order has been submitted', this.checkoutForm.value); - this.checkoutForm.reset(); this.router.navigate(['confirmation']); } diff --git a/src/app/components/product-item-details/product-item-details.component.scss b/src/app/components/product-item-details/product-item-details.component.scss index 0746376..2f336f9 100644 --- a/src/app/components/product-item-details/product-item-details.component.scss +++ b/src/app/components/product-item-details/product-item-details.component.scss @@ -38,20 +38,24 @@ $medium: 960px; @media screen and (max-width: $small) { width: 60%; } -} - -.info-tilte { - font-size: 4vh; - padding-bottom: 2%; -} -.info-price { - font-size: 2.5vh; + .info-tilte { + font-size: 3vh; + font-weight: lighter; + padding-bottom: 2%; + } + + .info-price { + font-size: 2.5vh; + color: #0F1111; + font-weight: 500; + } + + .info-description { + padding-top: 10%; + } } -.info-description { - padding-top: 10%; -} .details-quantity { width: 30%; diff --git a/src/app/components/product-item/product-item.component.html b/src/app/components/product-item/product-item.component.html index 04c7c59..20712a5 100644 --- a/src/app/components/product-item/product-item.component.html +++ b/src/app/components/product-item/product-item.component.html @@ -4,9 +4,9 @@ {{product.name}}
- {{product.name}} - {{product.description}} - {{product.price | currency}} + {{product.name}} + {{product.description}} + {{product.price | currency}}
diff --git a/src/app/components/product-item/product-item.component.scss b/src/app/components/product-item/product-item.component.scss index 77e89b8..1f8221a 100644 --- a/src/app/components/product-item/product-item.component.scss +++ b/src/app/components/product-item/product-item.component.scss @@ -40,6 +40,19 @@ $medium: 960px; align-items: center; flex-grow: 1; padding-top: 5%; + .name { + font-size: 2.5vh; + font-weight: lighter; + } + .description { + padding-top: 3vh; + } + .price{ + padding-top: 5vh; + font-size: 2vh; + color: #0F1111; + font-weight: 500; + } } .card-buttons {