Skip to content

Commit 94d5b05

Browse files
committed
change on styles
1 parent 7b7c5fa commit 94d5b05

23 files changed

Lines changed: 189 additions & 169 deletions

src/app/components/cart/cart.component.html

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,12 @@
5454
<div class="item-info">
5555
<div class="item-image">
5656
<img
57-
[src]="getProductImageUrl(item.product)"
58-
[alt]="item.product.name"
59-
(error)="
60-
$any($event.target).src =
61-
'data:image/svg+xml,%3Csvg xmlns=%22http://www.w3.org/2000/svg%22 width=%2260%22 height=%2260%22%3E%3Crect width=%2260%22 height=%2260%22 fill=%22%23f0f0f0%22/%3E%3Ctext x=%2230%22 y=%2237%22 text-anchor=%22middle%22 fill=%22%23999%22 font-size=%2224%22%3E📦%3C/text%3E%3C/svg%3E'
57+
[src]="
58+
item.product.local_image
59+
? getProductImageUrl(item.product)
60+
: 'assets/placeholder-product.png'
6261
"
62+
[alt]="item.product.name"
6363
/>
6464
</div>
6565
<div class="item-header">

src/app/components/cart/cart.component.scss

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
width: $cart-width;
1111
display: flex;
1212
flex-direction: column;
13-
box-shadow: -4px 0 20px rgba(0, 0, 0, 0.08);
1413
position: relative;
1514
height: 100%;
1615
border-bottom: 1px solid var(--border-color);
@@ -195,8 +194,8 @@
195194
flex: 1;
196195
overflow-y: auto;
197196
padding: 0.5rem;
198-
background-color: var(--bg-tertiary);
199-
197+
background-color: $neumorphic-surface;
198+
box-shadow: -4px 0 6px rgba(0, 0, 0, 0.08);
200199
&::-webkit-scrollbar {
201200
width: 6px;
202201
}

src/app/components/cart/cart.component.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,10 @@ export class CartComponent {
5353
}));
5454
}
5555
getProductImageUrl(product: Product): string {
56-
if (product.local_image) {
57-
return `${environment.imageUrl}/${product.local_image}`;
58-
}
59-
return "";
56+
return `${environment.imageUrl}/${product.local_image}`;
57+
}
58+
onImageError(event: Event): void {
59+
(event.target as HTMLImageElement).src = "assets/placeholder.png";
6060
}
6161

6262
getTotalItems(): number {

src/app/components/cashier/cashier.component.scss

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,13 @@
1010
overflow: hidden;
1111
display: flex;
1212
flex-direction: column;
13+
border-radius: $radius-2xl;
1314

1415
.register-warning {
1516
display: flex;
1617
align-items: center;
1718
gap: $spacing-md;
18-
padding: $spacing-md $spacing-lg;
19+
padding: $spacing-xs $spacing-lg;
1920
background: linear-gradient(
2021
135deg,
2122
rgba($warning, 0.15),

src/app/components/cashier/cashier.component.ts

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {
1111
import { CommonModule } from "@angular/common";
1212
import { FormsModule } from "@angular/forms";
1313
import { Router, NavigationEnd } from "@angular/router";
14-
import { filter } from "rxjs";
14+
import { filter, Observable, Subscription } from "rxjs";
1515
import { SaleService } from "../../services/sale.service";
1616
import { CartService } from "../../services/cart.service";
1717
import { AuthService } from "../../services/auth.service";
@@ -117,8 +117,18 @@ export class CashierComponent implements OnInit, AfterViewInit {
117117

118118
onRegisterOpened(): void {
119119
this.closeRegisterModal();
120-
// Focus calculator after register is opened
121-
setTimeout(() => this.calculator?.focusCalculator(), 300);
120+
// Reload the active register to update the state
121+
this.registerService.getActiveRegister().subscribe({
122+
next: () => {
123+
// Focus calculator after register is opened
124+
setTimeout(() => this.calculator?.focusCalculator(), 300);
125+
},
126+
error: (err) => {
127+
console.error("Error reloading register:", err);
128+
// Still focus calculator even if there's an error
129+
setTimeout(() => this.calculator?.focusCalculator(), 300);
130+
},
131+
});
122132
}
123133

124134
constructor(
@@ -146,18 +156,18 @@ export class CashierComponent implements OnInit, AfterViewInit {
146156
this.scaleConnected.set(this.scaleService.isConnected());
147157

148158
// Load active cart from database
149-
this.loadActiveCart();
150159

151160
// Handle session cleanup when user leaves or closes window
152161
this.setupSessionCleanup();
153162
}
154163

155164
ngOnInit(): void {
156165
// Subscribe to register state
157-
this.registerService.currentRegister$.subscribe((register) => {
158-
this.currentRegister.set(register);
166+
this.loadActiveCart()?.add(() => {
167+
this.registerService.currentRegister$.subscribe((register) => {
168+
this.currentRegister.set(register);
169+
});
159170
});
160-
161171
// Load active register
162172
this.registerService.getActiveRegister().subscribe();
163173

@@ -214,11 +224,11 @@ export class CashierComponent implements OnInit, AfterViewInit {
214224
navigator.sendBeacon(apiUrl, formData);
215225
}
216226

217-
loadActiveCart(): void {
227+
loadActiveCart(): Subscription | null {
218228
const currentUser = this.authService.getCurrentUser();
219-
if (!currentUser || !currentUser.id) return;
229+
if (!currentUser || !currentUser.id) return null;
220230

221-
this.cartService.getActiveCart(currentUser.id).subscribe({
231+
return this.cartService.getActiveCart(currentUser.id).subscribe({
222232
next: (cart) => {
223233
if (cart && cart.items) {
224234
// Convert cart items to cashier items format

src/app/components/dashboard/dashboard.component.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
background-color: var(--bg-secondary);
66
min-height: calc(100vh - 65px);
77
overflow-y: auto;
8-
8+
border-radius: $radius-2xl;
99
.dashboard-header {
1010
display: flex;
1111
justify-content: space-between;

src/app/components/favorites/favorites.component.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<div class="favorites">
22
<!-- Loading state -->
3-
<div class="loading-state" *ngIf="isLoading">
3+
<div class="loading-state" *ngIf="isLoading()">
44
<i class="fas fa-spinner fa-spin"></i>
55
<p>{{ "GLOBAL.LOADING" | translate }}</p>
66
</div>
@@ -18,7 +18,7 @@
1818
<!-- Products grid -->
1919
<div
2020
class="products-grid"
21-
*ngIf="!isLoading && !loadError && products.length > 0"
21+
*ngIf="!isLoading() && !loadError() && products.length > 0"
2222
>
2323
<div
2424
class="product-card"
@@ -47,7 +47,7 @@ <h4 class="product-name">{{ product.name }}</h4>
4747
<!-- Empty state -->
4848
<div
4949
class="empty-state"
50-
*ngIf="!isLoading && !loadError && products.length === 0"
50+
*ngIf="!isLoading() && !loadError() && products.length === 0"
5151
>
5252
<i class="fas fa-star"></i>
5353
<p>{{ "FAVORITES.EMPTY" | translate }}</p>

src/app/components/favorites/favorites.component.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
@use "../../../styles/theme" as *;
22

33
.favorites {
4-
background: $white;
4+
background: $neumorphic-surface;
55
border-radius: $radius-lg;
66
height: 100%;
77
overflow: hidden;

src/app/components/favorites/favorites.component.ts

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {
44
OnDestroy,
55
Output,
66
EventEmitter,
7+
signal,
78
} from "@angular/core";
89
import { CommonModule } from "@angular/common";
910
import { Subject, takeUntil, timeout, catchError, of } from "rxjs";
@@ -24,8 +25,8 @@ export class FavoritesComponent implements OnInit, OnDestroy {
2425
@Output() productSelected = new EventEmitter<Product>();
2526

2627
products: Product[] = [];
27-
isLoading = false;
28-
loadError = false;
28+
isLoading = signal(false);
29+
loadError = signal(false);
2930
private destroy$ = new Subject<void>();
3031

3132
constructor(private productService: ProductService) {}
@@ -40,29 +41,29 @@ export class FavoritesComponent implements OnInit, OnDestroy {
4041
}
4142

4243
loadTopProducts(): void {
43-
this.isLoading = true;
44-
this.loadError = false;
44+
this.isLoading.set(true);
45+
this.loadError.set(false);
4546

4647
this.productService
4748
.getFavoriteProducts(20)
4849
.pipe(
4950
timeout(10000), // 10 second timeout
5051
catchError((err) => {
5152
console.error("Error or timeout loading favorite products:", err);
52-
this.loadError = true;
53+
this.loadError.set(true);
5354
return of([]);
5455
}),
5556
takeUntil(this.destroy$)
5657
)
5758
.subscribe({
5859
next: (products) => {
5960
this.products = products;
60-
this.isLoading = false;
61+
this.isLoading.set(false);
6162
},
6263
error: (err) => {
6364
console.error("Error loading favorite products:", err);
64-
this.isLoading = false;
65-
this.loadError = true;
65+
this.isLoading.set(false);
66+
this.loadError.set(true);
6667
},
6768
});
6869
}

src/app/components/inventory/inventory.component.scss

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
max-width: 1500px;
66
margin: 0 auto;
77
height: calc(100% - 65px);
8-
border-radius: 0;
8+
background: $neumorphic-surface;
9+
border-radius: $radius-2xl;
910
}
1011

1112
.inventory-header {

0 commit comments

Comments
 (0)