Skip to content

Commit

Permalink
Minor linting changes made
Browse files Browse the repository at this point in the history
  • Loading branch information
amenconi committed Feb 11, 2024
1 parent cdefd66 commit 8d51969
Show file tree
Hide file tree
Showing 12 changed files with 409 additions and 304 deletions.
2 changes: 1 addition & 1 deletion src/app/@shell/ui/header/header.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ export class HeaderComponent implements OnInit, OnDestroy {
) {}

public ngOnInit(): void {
this.member$.pipe(untilDestroyed(this)).subscribe((obj) => {
this.member$.pipe(untilDestroyed(this)).subscribe((obj) => {
if (obj?.uid) {
this.cancelAccessSubscriptions();
this.accessSubscriptions$.push(
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ import {
ChangeDetectorRef,
ChangeDetectionStrategy,
} from '@angular/core';
import {
Network,
} from '@build-5/interfaces';
import { Network } from '@build-5/interfaces';
import { Subscription, take, of, Observable } from 'rxjs';
import { CartService, CartItem } from '@components/cart/services/cart.service';
import { AuthService } from '@components/auth/services/auth.service';
Expand All @@ -30,7 +28,7 @@ export enum StepType {
styleUrls: ['./cart-modal.component.less'],
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class CartModalComponent implements OnInit, OnDestroy {
export class CartModalComponent implements OnDestroy {
private subscriptions$ = new Subscription();
public collectionPath: string = ROUTER_UTILS.config.collection.root;
public nftPath: string = ROUTER_UTILS.config.nft.root;
Expand Down Expand Up @@ -60,11 +58,7 @@ export class CartModalComponent implements OnInit, OnDestroy {
private router: Router,
public unitsService: UnitsService,
public deviceService: DeviceService,
) {

}

ngOnInit() {}
) {}

trackByItemId(index: number, item: CartItem): string {
return item.nft.uid;
Expand All @@ -78,26 +72,29 @@ export class CartModalComponent implements OnInit, OnDestroy {
const inputElement = event.target as HTMLInputElement;
let newQuantity = Number(inputElement.value);

this.cartService.getCartItems().pipe(
take(1),
switchMap(cartItems => {
const item = cartItems.find(item => item.nft.uid === itemId);
if (item) {
return this.cartService.getAvailableNftQuantity(item).pipe(
map(maxQuantity => ({ item, maxQuantity })),
);
} else {
return of(null);
this.cartService
.getCartItems()
.pipe(
take(1),
switchMap((cartItems) => {
const item = cartItems.find((item) => item.nft.uid === itemId);
if (item) {
return this.cartService
.getAvailableNftQuantity(item)
.pipe(map((maxQuantity) => ({ item, maxQuantity })));
} else {
return of(null);
}
}),
)
.subscribe((result) => {
if (result) {
const { maxQuantity } = result;
newQuantity = Math.max(1, Math.min(newQuantity, maxQuantity));
inputElement.value = String(newQuantity);
this.cartService.updateCartItemQuantity(itemId, newQuantity);
}
}),
).subscribe(result => {
if (result) {
const { maxQuantity } = result;
newQuantity = Math.max(1, Math.min(newQuantity, maxQuantity));
inputElement.value = String(newQuantity);
this.cartService.updateCartItemQuantity(itemId, newQuantity);
}
});
});
}

public handleClose(): void {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ <h3 nz-typography nzTitle level="4" class="mb-2">
<button (click)="toggleGroup($event, group.tokenSymbol)">
{{ isGroupExpanded(group.tokenSymbol) ? 'Hide' : 'Show' }}
<span class="uppercase">{{ group.tokenSymbol }}</span> Items
</button>

</button>
</div>
</div>

Expand Down Expand Up @@ -74,33 +73,33 @@ <h3 nz-typography nzTitle level="4" class="mb-2">
<td>
<!-- NFT -->
<div>
<span class="underline font-bold">
NFT:
</span>
<span class="text-blue-500 hover:text-blue-600 cursor-pointer" (click)="goToNft(item.nft.uid)">
<span class="underline font-bold"> NFT: </span>
<span
class="text-blue-500 hover:text-blue-600 cursor-pointer"
(click)="goToNft(item.nft.uid)"
>
{{ item.nft.name }}
</span>
</div>

<!-- Collection -->
<div>
<span class="underline font-bold">
COL:
</span>
<span class="text-blue-500 hover:text-blue-600 cursor-pointer" (click)="goToCollection(item.collection.uid)">
<span class="underline font-bold"> COL: </span>
<span
class="text-blue-500 hover:text-blue-600 cursor-pointer"
(click)="goToCollection(item.collection.uid)"
>
{{ item.collection.name }}
</span>
</div>

<!-- Royalties -->
<div>
<span class="underline font-bold">
Royalties:
</span>
<span>
{{ (item.collection.royaltiesFee || 0) * 100 }}%
</span>
<span class="underline font-bold"> Royalties: </span>
<span> {{ (item.collection.royaltiesFee || 0) * 100 }}% </span>
</div>
</td>

<td>{{ item.quantity }}</td>
<td>
{{
Expand All @@ -116,7 +115,10 @@ <h3 nz-typography nzTitle level="4" class="mb-2">
<br />
({{
unitsService.getUsd(
cartService.valueDivideExponent({ value: item.salePrice || 0, exponents: cartService.getDefaultNetworkDecimals() }),
cartService.valueDivideExponent({
value: item.salePrice || 0,
exponents: cartService.getDefaultNetworkDecimals()
}),
group.network
)
| async
Expand All @@ -129,9 +131,7 @@ <h3 nz-typography nzTitle level="4" class="mb-2">
</ng-container>
<tr>
<td>
<strong>
Total
</strong>
<strong> Total </strong>
</td>
<td>
<strong>
Expand Down Expand Up @@ -206,7 +206,10 @@ <h3 nz-typography nzTitle level="4" class="mb-2">
}}
&nbsp; ({{
unitsService.getUsd(
cartService.valueDivideExponent({ value: item.salePrice || 0, exponents: cartService.getDefaultNetworkDecimals() }),
cartService.valueDivideExponent({
value: item.salePrice || 0,
exponents: cartService.getDefaultNetworkDecimals()
}),
group.network
)
| async
Expand All @@ -228,7 +231,10 @@ <h3 nz-typography nzTitle level="4" class="mb-2">
}}
&nbsp; ({{
unitsService.getUsd(
cartService.valueDivideExponent({ value: (item.quantity * item.salePrice) || 0, exponents: cartService.getDefaultNetworkDecimals() }),
cartService.valueDivideExponent({
value: item.quantity * item.salePrice || 0,
exponents: cartService.getDefaultNetworkDecimals()
}),
group.network
)
| async
Expand Down Expand Up @@ -256,7 +262,6 @@ <h3 nz-typography nzTitle level="4" class="mb-2">
</tbody>
</nz-table>
</ng-template>

</div>
</div>
<nz-divider></nz-divider>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,15 @@ import { AuthService } from '@components/auth/services/auth.service';
import { NotificationService } from '@core/services/notification';
import { OrderApi } from '@api/order.api';
import { NftApi } from '@api/nft.api';
import { BehaviorSubject, firstValueFrom, interval, Observable, Subscription, forkJoin, of } from 'rxjs';
import {
BehaviorSubject,
firstValueFrom,
interval,
Observable,
Subscription,
forkJoin,
of,
} from 'rxjs';
import { map, switchMap } from 'rxjs/operators';
import { TransactionService } from '@core/services/transaction';
import {
Expand Down Expand Up @@ -406,14 +414,14 @@ export class CheckoutOverlayComponent implements OnInit, OnDestroy {
}

public groupItems() {
const availabilityChecks$ = this.items.map(item =>
const availabilityChecks$ = this.items.map((item) =>
this.cartService.isCartItemAvailableForSale(item).pipe(
map(result => ({ item, isAvailable: result.isAvailable })),
switchMap(result => result ? of(result) : of({ item, isAvailable: false }))
)
map((result) => ({ item, isAvailable: result.isAvailable })),
switchMap((result) => (result ? of(result) : of({ item, isAvailable: false }))),
),
);

forkJoin(availabilityChecks$).subscribe(results => {
forkJoin(availabilityChecks$).subscribe((results) => {
const groups: { [tokenSymbol: string]: GroupedCartItem } = {};
this.unavailableItemCount = 0;

Expand All @@ -424,18 +432,28 @@ export class CheckoutOverlayComponent implements OnInit, OnDestroy {
}

const tokenSymbol =
(item.nft?.placeholderNft ? item.collection?.mintingData?.network : item.nft?.mintingData?.network) || DEFAULT_NETWORK;
(item.nft?.placeholderNft
? item.collection?.mintingData?.network
: item.nft?.mintingData?.network) || DEFAULT_NETWORK;
const discount = this.discount(item);
const originalPrice = this.calcPrice(item, 1);
const discountedPrice = this.calcPrice(item, discount);
const price = discount < 1 ? discountedPrice : originalPrice;
item.salePrice = price;

const network =
(item.nft?.placeholderNft ? item.collection?.mintingData?.network : item.nft?.mintingData?.network) || DEFAULT_NETWORK;
(item.nft?.placeholderNft
? item.collection?.mintingData?.network
: item.nft?.mintingData?.network) || DEFAULT_NETWORK;

if (!groups[tokenSymbol]) {
groups[tokenSymbol] = { tokenSymbol, items: [], totalQuantity: 0, totalPrice: 0, network };
groups[tokenSymbol] = {
tokenSymbol,
items: [],
totalQuantity: 0,
totalPrice: 0,
network,
};
}

groups[tokenSymbol].items.push(item);
Expand Down Expand Up @@ -468,10 +486,11 @@ export class CheckoutOverlayComponent implements OnInit, OnDestroy {
}

public isCartItemAvailableForSale(item: CartItem): Observable<boolean> {
return this.cartService.isCartItemAvailableForSale(item).pipe(map(result => result.isAvailable));
return this.cartService
.isCartItemAvailableForSale(item)
.pipe(map((result) => result.isAvailable));
}


public reset(): void {
this.receivedTransactions = false;
this.currentStep = StepType.CONFIRM;
Expand Down Expand Up @@ -506,10 +525,9 @@ export class CheckoutOverlayComponent implements OnInit, OnDestroy {
}

public goToMemberNfts(): void {

const memberId = this.auth.member$.value?.uid;

if(!memberId) {
if (!memberId) {
return;
}

Expand Down
Loading

0 comments on commit 8d51969

Please sign in to comment.