diff --git a/.rgignore b/.rgignore new file mode 100644 index 0000000..21df648 --- /dev/null +++ b/.rgignore @@ -0,0 +1 @@ +backend/ diff --git a/src/app/core/models/product.model.ts b/src/app/core/models/product.model.ts index b509785..85160b4 100644 --- a/src/app/core/models/product.model.ts +++ b/src/app/core/models/product.model.ts @@ -11,6 +11,7 @@ export interface ProductModel { category: Category; productImages: string[]; updatedAt: string; + isFavorite: boolean; } export interface ProductCollection extends PaginatedResponse {} diff --git a/src/app/core/services/favorite-service.spec.ts b/src/app/core/services/favorite-service.spec.ts index 9bf2abe..6e7bc54 100644 --- a/src/app/core/services/favorite-service.spec.ts +++ b/src/app/core/services/favorite-service.spec.ts @@ -1,8 +1,8 @@ -import { TestBed } from '@angular/core/testing'; +import { TestBed } from "@angular/core/testing"; -import { FavoriteService } from './favorite-service'; +import { FavoriteService } from "./favorite-service"; -describe('FavoriteService', () => { +describe("FavoriteService", () => { let service: FavoriteService; beforeEach(() => { @@ -10,7 +10,7 @@ describe('FavoriteService', () => { service = TestBed.inject(FavoriteService); }); - it('should be created', () => { + it("should be created", () => { expect(service).toBeTruthy(); }); }); diff --git a/src/app/core/services/favorite-service.ts b/src/app/core/services/favorite-service.ts index 0df02da..fdde44e 100644 --- a/src/app/core/services/favorite-service.ts +++ b/src/app/core/services/favorite-service.ts @@ -1,6 +1,6 @@ -import { HttpClient } from '@angular/common/http'; -import { inject, Injectable } from '@angular/core'; -import { API_URL } from '../tokens/api-url-tokens'; +import { HttpClient } from "@angular/common/http"; +import { inject, Injectable } from "@angular/core"; +import { API_URL } from "../tokens/api-url-tokens"; export interface FavoriteResponse { message: string; @@ -8,7 +8,7 @@ export interface FavoriteResponse { } @Injectable({ - providedIn: 'root', + providedIn: "root", }) export class FavoriteService { http = inject(HttpClient); diff --git a/src/app/features/product/components/product-card/product-card.html b/src/app/features/product/components/product-card/product-card.html index c209551..73f1c6f 100644 --- a/src/app/features/product/components/product-card/product-card.html +++ b/src/app/features/product/components/product-card/product-card.html @@ -1,15 +1,19 @@
- +
-

{{product.title}}

+

{{ product.title }}

⭐4.5

Price: - {{product.actualPrice}} - {{product.listPrice}}/- + {{ product.actualPrice }} + {{ product.listPrice }}/-

diff --git a/src/app/features/product/components/product-card/product-card.ts b/src/app/features/product/components/product-card/product-card.ts index a7b28b6..4f3e754 100644 --- a/src/app/features/product/components/product-card/product-card.ts +++ b/src/app/features/product/components/product-card/product-card.ts @@ -1,13 +1,13 @@ -import { Component, inject, Input } from '@angular/core'; -import { ProductModel } from '../../../../core/models/product.model'; -import { Router } from '@angular/router'; -import { FavoriteButton } from '../../../../src/app/shared/components/favorite-button/favorite-button'; +import { Component, inject, Input } from "@angular/core"; +import { ProductModel } from "../../../../core/models/product.model"; +import { Router } from "@angular/router"; +import { FavoriteButton } from "../../../../src/app/shared/components/favorite-button/favorite-button"; @Component({ - selector: 'app-product-card', + selector: "app-product-card", standalone: true, imports: [FavoriteButton], - templateUrl: './product-card.html', + templateUrl: "./product-card.html", }) export class ProductCard { readonly router = inject(Router); diff --git a/src/app/features/product/services/product-service.ts b/src/app/features/product/services/product-service.ts index b56e5f1..9613f86 100644 --- a/src/app/features/product/services/product-service.ts +++ b/src/app/features/product/services/product-service.ts @@ -1,10 +1,10 @@ -import { inject, Injectable } from '@angular/core'; -import { HttpClient } from '@angular/common/http'; -import { API_URL } from '../../../core/tokens/api-url-tokens'; -import { ProductCollection, ProductModel } from '../../../core/models/product.model'; +import { inject, Injectable } from "@angular/core"; +import { HttpClient } from "@angular/common/http"; +import { API_URL } from "../../../core/tokens/api-url-tokens"; +import { ProductCollection, ProductModel } from "../../../core/models/product.model"; @Injectable({ - providedIn: 'root', + providedIn: "root", }) export class ProductService { http = inject(HttpClient); diff --git a/src/app/src/app/shared/components/favorite-button/favorite-button.html b/src/app/src/app/shared/components/favorite-button/favorite-button.html index cf185bf..1380952 100644 --- a/src/app/src/app/shared/components/favorite-button/favorite-button.html +++ b/src/app/src/app/shared/components/favorite-button/favorite-button.html @@ -1,7 +1,13 @@ diff --git a/src/app/src/app/shared/components/favorite-button/favorite-button.spec.ts b/src/app/src/app/shared/components/favorite-button/favorite-button.spec.ts index 7f14936..227ca91 100644 --- a/src/app/src/app/shared/components/favorite-button/favorite-button.spec.ts +++ b/src/app/src/app/shared/components/favorite-button/favorite-button.spec.ts @@ -1,23 +1,22 @@ -import { ComponentFixture, TestBed } from '@angular/core/testing'; +import { ComponentFixture, TestBed } from "@angular/core/testing"; -import { FavoriteButton } from './favorite-button'; +import { FavoriteButton } from "./favorite-button"; -describe('FavoriteButton', () => { +describe("FavoriteButton", () => { let component: FavoriteButton; let fixture: ComponentFixture; beforeEach(async () => { await TestBed.configureTestingModule({ - imports: [FavoriteButton] - }) - .compileComponents(); + imports: [FavoriteButton], + }).compileComponents(); fixture = TestBed.createComponent(FavoriteButton); component = fixture.componentInstance; await fixture.whenStable(); }); - it('should create', () => { + it("should create", () => { expect(component).toBeTruthy(); }); }); diff --git a/src/app/src/app/shared/components/favorite-button/favorite-button.ts b/src/app/src/app/shared/components/favorite-button/favorite-button.ts index 437e8d0..733a074 100644 --- a/src/app/src/app/shared/components/favorite-button/favorite-button.ts +++ b/src/app/src/app/shared/components/favorite-button/favorite-button.ts @@ -1,16 +1,16 @@ -import { Component, inject, Input } from '@angular/core'; -import { HeartIcon, LucideAngularModule } from 'lucide-angular'; -import { FavoriteService } from '../../../../../core/services/favorite-service'; +import { Component, inject, Input } from "@angular/core"; +import { HeartIcon, LucideAngularModule } from "lucide-angular"; +import { FavoriteService } from "../../../../../core/services/favorite-service"; @Component({ - selector: 'app-favorite-button', + selector: "app-favorite-button", imports: [LucideAngularModule], - templateUrl: './favorite-button.html', - styleUrl: './favorite-button.css', + templateUrl: "./favorite-button.html", + styleUrl: "./favorite-button.css", }) export class FavoriteButton { @Input({ required: true }) productId!: number; - @Input() isFavorite = true; + @Input() isFavorite = false; favoriteService = inject(FavoriteService);