8000 feat: Epic/saved carts by bgambocjaviniar · Pull Request #11358 · SAP/spartacus · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

feat: Epic/saved carts #11358

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 75 commits into from
Mar 26, 2021
Merged

feat: Epic/saved carts #11358

merged 75 commits into from
Mar 26, 2021

Conversation

bgambocjaviniar
Copy link
Contributor
@bgambocjaviniar bgambocjaviniar commented Mar 3, 2021

closes GH-11062

Master ticket: #11062

testing use cases were done from here #11518

NOTE

  • environment.ts is updated to point to dev3 and b2b ootb just for testing purposes. It will be reverted once feature is completed

bgambocjaviniar and others added 12 commits February 21, 2021 01:58
* Create base feature-lib for cart (GH-11061)

* base cart lib - now for multicart

* made cart have multi entrypoint for saved cart package

* yarn config:update + change files and exposed the the basic necessities

* hook it to the config shell app

* updated root module with multiple cms components to trigger the feature-lib

* added the routes so that no conflicts in future

* push empty folder for Michal so that he can place his part in there instead

* remove unncessary module for saved cart occ module

* additional config

* add the filter in test.ts in cart feature-lib

* adding cart to build:libs script and removing top level re-export of carts
* feat: Saved carts list page UI #9194

* fixed ui to work with core form 9193

* feat: Load saved carts store and facade (GH-9193)

* everything in the cart state instead of a global state

* added logilogic for restore

* added the github action

* refactored load / restore logic

* ran the config:update script

* uncomment michal's styling

* introduced list in multicart

* constructor requirement from restore success as it is for changing the flag

* loardcartsuccess instead of reloading the cart

* removed unun-ncessary files/folders

Co-authored-by: Michal Dydo <mdydo@divante.pl>
bgambocjaviniar and others added 10 commits March 3, 2021 14:10
…1364)

* feat: Update the AccountSavedCartDetailsActionsComponent UI #9197
* feat: Update the AccountSavedCartDetailsOverviewComponent #9198
… for other component unit tests to pass (#11415)

* Fix other broken unit tests for saved carts lib

* Unit tests for add to save cart component

* fixed Michal's PR

Co-authored-by: Brian Gamboc-Javiniar <brian_javiniar@hotmail.com>
* chore: support events by updating saved cart actions

* fix the undefined description to use default backend response
@bgambocjaviniar bgambocjaviniar temporarily deployed to dev March 10, 2021 17:23 Inactive
…o eslint (GH-11327)

* Unit tests for details page + exposing components/services

* restore save cart change in order to use default name value when empty string is passed

* fix directionality issue with border-right

* removed unused styling

* update to eslint

* prettier + version update to libs

* removed a 'it' duplication unit test
@bgambocjaviniar bgambocjaviniar temporarily deployed to dev March 10, 2021 21:26 Inactive 10000
dydome and others added 5 commits March 25, 2021 11:49
…ion.ts

Co-authored-by: Marcin Lasak <lasakmarcin90@gmail.com>
…er.ts

Co-authored-by: Marcin Lasak <lasakmarcin90@gmail.com>
…er.ts

Co-authored-by: Marcin Lasak <lasakmarcin90@gmail.com>
Co-authored-by: Marcin Lasak <lasakmarcin90@gmail.com>
Co-authored-by: Marcin Lasak <lasakmarcin90@gmail.com>
…er.ts

Co-authored-by: Marcin Lasak <lasakmarcin90@gmail.com>
@github-actions
Copy link
Contributor

Hosting service deployment

❗ Spartacus deployment failed ( ERR Failed to execute command [application deploy] due to: Error: Deploy
Failed. Could not generate environment or presigned URL.
Response code: 500
Message: Could not deploy new application, the limit: 20 for the
tenant: spartacus has been reached
Type: internal_service_error

). Check job logs for details.)

@github-actions
Copy link
Contributor

Public API changes

⚠️ @spartacus/cart

New entry point. Initial public api:

// (No @packageDocumentation comment for this package)

⚠️ @spartacus/cart/saved-cart/assets

New entry point. Initial public api:

import { TranslationChunksConfig } from '@spartacus/core';
import { TranslationResources } from '@spartacus/core';

// @public (undocumented)
export const savedCartTranslationChunksConfig: TranslationChunksConfig;

// @public (undocumented)
export const savedCartTranslations: TranslationResources;


// (No @packageDocumentation comment for this package)

⚠️ @spartacus/cart/saved-cart/components

New entry point. Initial public api:

import { ActiveCartService } from '@spartacus/core';
import { AuthService } from '@spartacus/core';
import { Card } from '@spartacus/storefront';
import { Cart } from '@spartacus/core';
import { ClearCheckoutService } from '@spartacus/core';
import { ElementRef } from '@angular/core';
import { EventService } from '@spartacus/core';
import { FocusConfig } from '@spartacus/storefront';
import { FormGroup } from '@angular/forms';
import { GlobalMessageService } from '@spartacus/core';
import { ICON_TYPE } from '@spartacus/storefront';
import { LaunchDialogService } from '@spartacus/storefront';
import { LayoutConfig } from '@spartacus/storefront';
import { Observable } from 'rxjs';
import { OnDestroy } from '@angular/core';
import { OnInit } from '@angular/core';
import { PromotionLocation } from '@spartacus/core';
import { RoutingService } from '@spartacus/core';
import { SavedCartFormType } from '@spartacus/cart/saved-cart/core';
import { SavedCartService } from '@spartacus/cart/saved-cart/core';
import { Subscription } from 'rxjs';
import { TranslationService } from '@spartacus/core';
import { ViewContainerRef } from '@angular/core';

// @public (undocumented)
export class AddToSavedCartComponent implements OnInit, OnDestroy {
    constructor(activeCartService: ActiveCartService, authService: AuthService, routingService: RoutingService, savedCartFormLaunchDialogService: SavedCartFormLaunchDialogService, vcr: ViewContainerRef);
    // (undocumented)
    protected activeCartService: ActiveCartService;
    // (undocumented)
    protected authService: AuthService;
    // (undocumented)
    cart$: Observable<Cart>;
    // (undocumented)
    element: ElementRef;
    // (undocumented)
    protected loggedIn: boolean;
    // (undocumented)
    ngOnDestroy(): void;
    // (undocumented)
    ngOnInit(): void;
    // (undocumented)
    openDialog(cart: Cart): void;
    // (undocumented)
    protected routingService: RoutingService;
    // (undocumented)
    saveCart(cart: Cart): void;
    // (undocumented)
    protected savedCartFormLaunchDialogService: SavedCartFormLaunchDialogService;
    // (undocumented)
    protected subscription: Subscription;
    // (undocumented)
    protected vcr: ViewContainerRef;
}

// @public (undocumented)
export class AddToSavedCartModule {
}

// @public (undocumented)
export const defaultSavedCartFormLayoutConfig: LayoutConfig;

// @public (undocumented)
export class SavedCartComponentsModule {
}

// @public (undocumented)
export class SavedCartDetailsActionComponent implements OnInit, OnDestroy {
    constructor(savedCartDetailsService: SavedCartDetailsService, savedCartService: SavedCartService, routingService: RoutingService, globalMessageService: GlobalMessageService, savedCartFormLaunchDialogService: SavedCartFormLaunchDialogService, vcr: ViewContainerRef, clearCheckoutService: ClearCheckoutService);
    // (undocumented)
    protected clearCheckoutService: ClearCheckoutService;
    // (undocumented)
    element: ElementRef;
    // (undocumented)
    protected globalMessageService: GlobalMessageService;
    // (undocumented)
    ngOnDestroy(): void;
    // (undocumented)
    ngOnInit(): void;
    // (undocumented)
    onRestoreComplete(success: boolean): void;
    // (undocumented)
    openDialog(cart: Cart): void;
    // (undocumented)
    restoreSavedCart(cartId: string): void;
    // (undocumented)
    protected routingService: RoutingService;
    // (undocumented)
    savedCart$: Observable<Cart | undefined>;
    // (undocumented)
    protected savedCartDetailsService: SavedCartDetailsService;
    // (undocumented)
    protected savedCartFormLaunchDialogService: SavedCartFormLaunchDialogService;
    // (undocumented)
    protected savedCartService: SavedCartService;
    // (undocumented)
    protected vcr: ViewContainerRef;
}

// @public (undocumented)
export class SavedCartDetailsItemsComponent implements OnInit, OnDestroy {
    constructor(savedCartDetailsService: SavedCartDetailsService, savedCartService: SavedCartService, eventSercvice: EventService, globalMessageService: GlobalMessageService, routingService: RoutingService);
    // (undocumented)
    cartLoaded$: Observable<boolean>;
    // (undocumented)
    CartLocation: typeof PromotionLocation;
    // (undocumented)
    protected eventSercvice: EventService;
    // (undocumented)
    protected globalMessageService: GlobalMessageService;
    // (undocumen
F438
ted)
    ngOnDestroy(): void;
    // (undocumented)
    ngOnInit(): void;
    // (undocumented)
    onDeleteComplete(success: boolean): void;
    // (undocumented)
    protected routingService: RoutingService;
    // (undocumented)
    savedCart$: Observable<Cart | undefined>;
    // (undocumented)
    protected savedCartDetailsService: SavedCartDetailsService;
    // (undocumented)
    protected savedCartService: SavedCartService;
    }

// @public (undocumented)
export class SavedCartDetailsModule {
}

// @public (undocumented)
export class SavedCartDetailsOverviewComponent implements OnDestroy {
    constructor(savedCartDetailsService: SavedCartDetailsService, translation: TranslationService, savedCartFormLaunchDialogService: SavedCartFormLaunchDialogService, vcr: ViewContainerRef);
    // (undocumented)
    element: ElementRef;
    // (undocumented)
    getCartDescription(cartDescription: string): Observable<Card>;
    // (undocumented)
    getCartId(cartId: string): Observable<Card>;
    // (undocumented)
    getCartItems(totalItems: number): Observable<Card>;
    // (undocumented)
    getCartName(cartName: string): Observable<Card>;
    // (undocumented)
    getCartQuantity(totalUnitCount: number): Observable<Card>;
    // (undocumented)
    getCartTotal(totalPriceWithTax: string): Observable<Card>;
    // (undocumented)
    getDateSaved(saveTime: string): Observable<Card>;
    // (undocumented)
    iconTypes: typeof ICON_TYPE;
    // (undocumented)
    ngOnDestroy(): void;
    // (undocumented)
    openDialog(cart: Cart): void;
    // (undocumented)
    savedCart$: Observable<Cart | undefined>;
    // (undocumented)
    protected savedCartDetailsService: SavedCartDetailsService;
    // (undocumented)
    protected savedCartFormLaunchDialogService: SavedCartFormLaunchDialogService;
    // (undocumented)
    protected translation: TranslationService;
    // (undocumented)
    protected vcr: ViewContainerRef;
}

// @public (undocumented)
export class SavedCartDetailsService {
    constructor(routingService: RoutingService, savedCartService: SavedCartService);
    // (undocumented)
    getCartDetails(): Observable<Cart | undefined>;
    // (undocumented)
    getSavedCartId(): Observable<string>;
    // (undocumented)
    protected routingService: RoutingService;
    // (undocumented)
    protected savedCart$: Observable<Cart | undefined>;
    // (undocumented)
    protected savedCartId$: Observable<any>;
    // (undocumented)
    protected savedCartService: SavedCartService;
}

// @public (undocumented)
export class SavedCartFormDialogComponent implements OnInit, OnDestroy {
    constructor(launchDialogService: LaunchDialogService, el: ElementRef, savedCartService: SavedCartService, eventService: EventService, routingService: RoutingService, globalMessageService: GlobalMessageService, clearCheckoutService: ClearCheckoutService);
    // (undocumented)
    protected build(cart?: Cart): void;
    // (undocumented)
    cart: Cart;
    // (undocumented)
    protected clearCheckoutService: ClearCheckoutService;
    // (undocumented)
    close(reason: string): void;
    // (undocumented)
    deleteCart(cartId: string): void;
    // (undocumented)
    descriptionMaxLength: number;
    // (undocumented)
    get descriptionsCharacterLeft(): number;
    // (undocumented)
    protected el: ElementRef;
    // (undocumented)
    protected eventService: EventService;
    // (undocumented)
    focusConfig: FocusConfig;
    // (undocumented)
    form: FormGroup;
    // (undocumented)
    protected globalMessageService: GlobalMessageService;
    // (undocumented)
    handleClick(event: UIEvent): void;
    // (undocumented)
    iconTypes: typeof ICON_TYPE;
    // (undocumented)
    isDisableDeleteButton$: Observable<boolean>;
    // (undocumented)
    isLoading$: Observable<boolean>;
    // (undocumented)
    protected launchDialogService: LaunchDialogService;
    // (undocumented)
    layoutOption: string | undefined;
    // (undocumented)
    nameMaxLength: number;
    // (undocumented)
    ngOnDestroy(): void;
    // (undocumented)
    ngOnInit(): void;
    // (undocumented)
    onComplete(success: boolean): void;
    // (undocumented)
    protected patchData(item?: any): void;
    // (undocumented)
    protected routingService: RoutingService;
    // (undocumented)
    savedCartFormType: typeof SavedCartFormType;
    // (undocumented)
    protected savedCartService: SavedCartService;
    // (undocumented)
    saveOrEditCart(cartId: string): void;
    }

// @public (undocumented)
export class SavedCartFormDialogModule {
}

// @public (undocumented)
export interface SavedCartFormDialogOptions {
    // (undocumented)
    cart: Cart;
    // (undocumented)
    layoutOption?: string;
}

// @public (undocumented)
export class SavedCartFormLaunchDialogService {
    constructor(launchDialogService: LaunchDialogService);
    // (undocumented)
    protected launchDialogService: LaunchDialogService;
    // (undocumented)
    openDialog(openElement?: ElementRef, vcr?: ViewContainerRef, data?: any): Observable<any> | undefined;
}

// @public (undocumented)
export class SavedCartListComponent implements OnInit, OnDestroy {
    constructor(routing: RoutingService, translation: TranslationService, savedCartService: SavedCartService, clearCheckoutService: ClearCheckoutService);
    // (undocumented)
    protected clearCheckoutService: ClearCheckoutService;
    // (undocumented)
    goToSavedCartDetails(cart: Cart): void;
    // (undocumented)
    isLoading$: Observable<boolean>;
    // (undocumented)
    ngOnDestroy(): void;
    // (undocumented)
    ngOnInit(): void;
    // (undocumented)
    onRestoreComplete(success: boolean): void;
    // (undocumented)
    restoreSavedCart(event: Event, cartId: string): void;
    // (undocumented)
    protected routing: RoutingService;
    // (undocumented)
    savedCarts$: Observable<Cart[]>;
    // (undocumented)
    protected savedCartService: SavedCartService;
    // (undocumented)
    protected translation: TranslationService;
}

// @public (undocumented)
export class SavedCartListModule {
}


// (No @packageDocumentation comment for this package)

💥 @spartacus/cart/saved-cart/core

New entry point that can't be analyzed with api-extractor. Please check the errors:

ERROR: "import * as ___ from ___;" is not supported yet for local files.

⚠️ @spartacus/cart/saved-cart/occ

New entry point. Initial public api:

import { Cart } from '@spartacus/core';
import { ConverterService } from '@spartacus/core';
import { HttpClient } from '@angular/common/http';
import { Observable } from 'rxjs';
import { OccEndpointsService } from '@spartacus/core';
import { SavedCartAdapter } from '@spartacus/cart/saved-cart/core';

// @public (undocumented)
export class OccSavedCartAdapter implements SavedCartAdapter {
    constructor(http: HttpClient, occEndpoints: OccEndpointsService, converter: ConverterService);
    // (undocumented)
    protected converter: ConverterService;
    // (undocumented)
    protected getRestoreSavedCartEndpoint(userId: string, cartId: string): string;
    // (undocumented)
    protected getSaveCartEndpoint(userId: string, cartId: string, saveCartName: string, saveCartDescription: string): string;
    // (undocumented)
    protected getSavedCartEndpoint(userId: string, cartId: string): string;
    // (undocumented)
    protected getSavedCartListEndpoint(userId: string): string;
    // (undocumented)
    protected http: HttpClient;
    // (undocumented)
    load(userId: string, cartId: string): Observable<Cart>;
    // (undocumented)
    loadList(userId: string): Observable<Cart[]>;
    // (undocumented)
    protected occEndpoints: OccEndpointsService;
    // (undocumented)
    restoreSavedCart(userId: string, cartId: string): Observable<Cart>;
    // (undocumented)
    saveCart(userId: string, cartId: string, saveCartName: string, saveCartDescription: string): Observable<Cart>;
}

// @public (undocumented)
export class SavedCartOccModule {
}


// (No @packageDocumentation comment for this package)

⚠️ @spartacus/cart/saved-cart

New entry point. Initial public api:

// @public (undocumented)
export class SavedCartModule {
}


// (No @packageDocumentation comment for this package)

⚠️ @spartacus/cart/saved-cart/root

New entry point. Initial public api:

// @public (undocumented)
export class SavedCartRootModule {
}


// (No @packageDocumentation comment for this package)

⚠️ @spartacus/product-configurator/common

     readonly quantityControl$: Observable<FormControl>;
     // (undocumented)
     readonly readonly$: Observable<boolean>;
+    // (undocumented)
+    readonly shouldShowButton$: Observable<boolean>;
 }
 
 // @public (undocumented)

⚠️ Some entry points are currently impossible to analyze.

Read more
  • @spartacus/asm/core - ERROR: "import * as ___ from ___;" is not supported yet for local files.
  • @spartacus/cart/saved-cart/core - ERROR: "import * as ___ from ___;" is not supported yet for local files.
  • @spartacus/cdc - ERROR: "import * as ___ from ___;" is not supported yet for local files.
  • @spartacus/core - ERROR: "import * as ___ from ___;" is not supported yet for local files.
  • @spartacus/organization/administration/core - ERROR: "import * as ___ from ___;" is not supported yet for local files.
  • @spartacus/organization/order-approval - ERROR: "import * as ___ from ___;" is not supported yet for local files.
  • @spartacus/product-configurator/rulebased - ERROR: "import * as ___ from ___;" is not supported yet for local files.
  • @spartacus/storefinder/core - ERROR: "import * as ___ from ___;" is not supported yet for local files.
  • @spartacus/storefront - ERROR: The expression contains an import() type, which is not yet supported by API Extractor:

💰 How to debug problems?

Read more

Problem with import() type

It happens when type is deduced by TS based on code and at the same time the deduced type is not present in the file.
In this specific case to support api-extractor it's worth to add type declaration explicitly.

Debugging steps:

  • go to the bot action logs
  • find api-extractor logs for broken library
  • check in which file and line the problems exists
  • build the library locally and check content of the file mentioned in logs (look for import()
  • add explicit type to problematic source code
  • build the library once again and verify that the import( is no longer present
  • commit and push the code with defined type

Problem with import * as ___

Api-extractor doesn't support this namespace syntax.
Check if you really need to use namespace in the library. Try to avoid namespaces when possible.

@dydome dydome merged commit 7c14d9a into develop Mar 26, 2021
@dydome dydome deleted the epic/saved-carts branch March 26, 2021 10:49
@dydome dydome temporarily deployed to dev March 26, 2021 10:49 Inactive
Comment on lines +37 to +43
return this.translation.translate('savedCartDetails.cartName').pipe(
filter(() => Boolean(cartName)),
map((textTitle) => ({
title: textTitle,
text: [cartName],
}))
);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally we should prefer using cxTranslate pipe in the template pipe over the TranslationService in the TS logic (unless TranslationService is justified).

The disadvantages of using TranslationService are:

  • it introduces an unnecessary dependency in the component TS class
  • it likely introduces unnecessary methods and RxJs logic to the TS class, which could be avoided

In this particular example we could have in the template:

<cx-card [content]="{ 
   title: 'savedCartDetails.cartName' | cxTranslate
   text: [cart?.name],
}"></cx-card>

@bgambocjaviniar bgambocjaviniar restored the epic/saved-carts branch July 30, 2021 16:27
@bgambocjaviniar bgambocjaviniar deleted the epic/saved-carts branch July 30, 2021 16:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[MASTER] Saved Cart
7 participants
0