Skip to content
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

feat(checkout,demo)!: remove legacy and deprecated checkout code #2752

Merged
merged 1 commit into from
Jun 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions apps/demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
},
"devDependencies": {
"@daffodil/builders": "0.0.0-PLACEHOLDER",
"@daffodil/authorizenet": "0.0.0-PLACEHOLDER",
"@daffodil/auth": "0.0.0-PLACEHOLDER",
"@daffodil/cart": "0.0.0-PLACEHOLDER",
"@daffodil/category": "0.0.0-PLACEHOLDER",
Expand Down
3 changes: 0 additions & 3 deletions apps/demo/src/app/app-routing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,10 @@ import {
DaffProductPageUrlResolver,
} from '@daffodil/product/routing';

import { EmptyCartResolver } from './cart/routing-resolvers/resolvers/empty-cart-resolver.service';
import { CheckoutViewComponent } from './checkout/pages/checkout-view/checkout-view.component';
import { TemplateComponent } from './core/template/template/template.component';
import { NotFoundComponent } from './misc/not-found/not-found.component';
import { ProductGridViewComponent } from './product/pages/product-grid-view/product-grid-view.component';
import { ProductViewComponent } from './product/pages/product-view/product-view.component';
import { ThankYouViewComponent } from './thank-you/pages/thank-you-view.component';

export const appRoutes: Routes = [
{
Expand Down
29 changes: 26 additions & 3 deletions apps/demo/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,27 @@ import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { EffectsModule } from '@ngrx/effects';
import { provideRouterStore } from '@ngrx/router-store';
import { StoreModule } from '@ngrx/store';
import { StoreDevtoolsModule } from '@ngrx/store-devtools';

import {
DaffAuthorizeNetPaymentStateModule,
DaffAuthorizeNetStateModule,
} from '@daffodil/authorizenet/state';
import { daffCartProvideRetrievalActions } from '@daffodil/cart/state';
import { DaffPaymentStateModule } from '@daffodil/payment/state';

import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import { DemoCartRootModule } from './cart/cart-root.module';
import { CategoryModule } from './category/category.module';
import { DemoCheckoutStepActionTypes } from './checkout/actions/checkout-step.actions';
import { TemplateModule } from './core/template/template/template.module';
import { DemoDriverMap } from './drivers/map';
import { NotFoundModule } from './misc/not-found/not-found.module';
import { ProductModule } from './product/product.module';
import { DemoRoutingComponentModule } from './routing/routing-component.module';
import { ThankYouModule } from './thank-you/thank-you.module';
import { environment } from '../environments/environment';

@NgModule({
Expand Down Expand Up @@ -44,11 +52,26 @@ import { environment } from '../environments/environment';
DemoCartRootModule,
ProductModule,
CategoryModule,
ThankYouModule,
TemplateModule,
NotFoundModule,
DaffAuthorizeNetPaymentStateModule,
DaffAuthorizeNetStateModule,
DaffPaymentStateModule,
],
providers: [
daffCartProvideRetrievalActions(
{
type: DemoCheckoutStepActionTypes.CompleteAddressStepSuccessAction,
},
{
type: DemoCheckoutStepActionTypes.CompleteShippingStepSuccessAction,
},
{
type: DemoCheckoutStepActionTypes.CompleteBillingStepSuccessAction,
},
),
provideRouterStore(),
],
providers: [],
bootstrap: [AppComponent],
})
export class DemoModule {}
101 changes: 101 additions & 0 deletions apps/demo/src/app/checkout/actions/checkout-step.actions.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
import { Action } from '@ngrx/store';

import { DaffAuthorizenetPaymentRequest } from '@daffodil/authorizenet';
import { DaffCart } from '@daffodil/cart';
import {
DaffCartPaymentUpdateFailure,
DaffCartPaymentUpdateSuccess,
DaffCartShippingAddressUpdate,
DaffCartShippingAddressUpdateFailure,
DaffCartShippingAddressUpdateSuccess,
DaffCartShippingInformationUpdate,
DaffCartShippingInformationUpdateFailure,
DaffCartShippingInformationUpdateSuccess,
} from '@daffodil/cart/state';
import { DaffIdentifiable } from '@daffodil/core';
import { DaffStateError } from '@daffodil/core/state';
import { DaffPersonalAddress } from '@daffodil/geography';
import { DaffPaymentRequest } from '@daffodil/payment';
import { DaffPaymentGenerateToken } from '@daffodil/payment/state';

export enum DemoCheckoutStepActionTypes {
CompleteAddressStepAction = '[@daffodil/demo] Checkout Complete Address Step Action',
CompleteAddressStepSuccessAction = '[@daffodil/demo] Checkout Complete Address Step Success Action',
CompleteAddressStepFailureAction = '[@daffodil/demo] Checkout Complete Address Step Failure Action',

CompleteShippingStepAction = '[@daffodil/demo] Checkout Complete Shipping Step Action',
CompleteShippingStepSuccessAction = '[@daffodil/demo] Checkout Complete Shipping Step Success Action',
CompleteShippingStepFailureAction = '[@daffodil/demo] Checkout Complete Shipping Step Failure Action',

CompleteBillingStepAction = '[@daffodil/demo] Checkout Complete Billing Step Action',
CompleteBillingStepSuccessAction = '[@daffodil/demo] Checkout Complete Billing Step Success Action',
CompleteBillingStepFailureAction = '[@daffodil/demo] Checkout Complete Billing Step Failure Action',
}

export class DemoCompleteAddressStep implements Action, Omit<DaffCartShippingAddressUpdate, keyof Action> {
readonly type = DemoCheckoutStepActionTypes.CompleteAddressStepAction;

constructor(public payload: DaffCart['shipping_address']) {}
}

export class DemoCompleteAddressStepSuccess implements Action, Omit<DaffCartShippingAddressUpdateSuccess, keyof Action> {
readonly type = DemoCheckoutStepActionTypes.CompleteAddressStepSuccessAction;

constructor(public payload: Partial<DaffCart>) {}
}

export class DemoCompleteAddressStepFailure implements Action, Omit<DaffCartShippingAddressUpdateFailure, keyof Action> {
readonly type = DemoCheckoutStepActionTypes.CompleteAddressStepFailureAction;

constructor(public payload: Array<DaffStateError>) {}
}

export class DemoCompleteShippingStep implements Action, Omit<DaffCartShippingInformationUpdate, keyof Action> {
readonly type = DemoCheckoutStepActionTypes.CompleteShippingStepAction;

constructor(public payload: DaffCart['shipping_information']) {}
}

export class DemoCompleteShippingStepSuccess implements Action, Omit<DaffCartShippingInformationUpdateSuccess, keyof Action> {
readonly type = DemoCheckoutStepActionTypes.CompleteShippingStepSuccessAction;

constructor(public payload: Partial<DaffCart>) {}
}

export class DemoCompleteShippingStepFailure implements Action, Omit<DaffCartShippingInformationUpdateFailure, keyof Action> {
readonly type = DemoCheckoutStepActionTypes.CompleteShippingStepFailureAction;

constructor(public payload: Array<DaffStateError>) {}
}

export class DemoCompleteBillingStep implements DaffPaymentGenerateToken<DaffAuthorizenetPaymentRequest> {
readonly type = DemoCheckoutStepActionTypes.CompleteBillingStepAction;

constructor(
public request: DaffAuthorizenetPaymentRequest,
public address?: DaffPersonalAddress | DaffIdentifiable,
) {}
}

export class DemoCompleteBillingStepSuccess implements Action, Omit<DaffCartPaymentUpdateSuccess, keyof Action> {
readonly type = DemoCheckoutStepActionTypes.CompleteBillingStepSuccessAction;

constructor(public payload: Partial<DaffCart>) {}
}

export class DemoCompleteBillingStepFailure implements Action, Omit<DaffCartPaymentUpdateFailure, keyof Action> {
readonly type = DemoCheckoutStepActionTypes.CompleteBillingStepFailureAction;

constructor(public payload: Array<DaffStateError>) {}
}

export type DemoCheckoutStepActions =
| DemoCompleteAddressStep
| DemoCompleteAddressStepSuccess
| DemoCompleteAddressStepFailure
| DemoCompleteShippingStep
| DemoCompleteShippingStepSuccess
| DemoCompleteShippingStepFailure
| DemoCompleteBillingStep
| DemoCompleteBillingStepSuccess
| DemoCompleteBillingStepFailure;
38 changes: 31 additions & 7 deletions apps/demo/src/app/checkout/checkout-routing.module.ts
Original file line number Diff line number Diff line change
@@ -1,30 +1,54 @@
import { NgModule } from '@angular/core';
import {
NgModule,
inject,
} from '@angular/core';
import {
ActivatedRouteSnapshot,
RouterModule,
RouterStateSnapshot,
Routes,
} from '@angular/router';

import { CheckoutViewComponent } from './pages/checkout-view/checkout-view.component';
import { EmptyCartResolver } from '../cart/routing-resolvers/resolvers/empty-cart-resolver.service';
import {
DaffCartInStockItemsGuard,
DaffCartItemsGuard,
DaffCartRoutingModule,
DaffResolveCartGuard,
} from '@daffodil/cart/routing';
import { daffRouterComposeGuards } from '@daffodil/router';

import { DemoCheckoutViewComponent } from './pages/checkout-view/checkout-view.component';
import { ThankYouViewComponent } from '../thank-you/pages/thank-you-view.component';

const routes: Routes = [
{
path: '',
pathMatch: 'full',
children: [
{ path: '', component: CheckoutViewComponent },
{ path: '', component: DemoCheckoutViewComponent },
{ path: 'thank-you', component: ThankYouViewComponent },
],
resolve: {
cartItem: EmptyCartResolver,
},
canActivate: [
(route: ActivatedRouteSnapshot, state: RouterStateSnapshot) => {
const resolveCart = inject(DaffResolveCartGuard);
const cartItems = inject(DaffCartItemsGuard);
const inStock = inject(DaffCartInStockItemsGuard);

return daffRouterComposeGuards([
resolveCart.canActivate.bind(resolveCart),
], [
cartItems.canActivate.bind(cartItems),
inStock.canActivate.bind(inStock),
])(route, state);
},
],
},
];

@NgModule({
imports: [
RouterModule.forChild(routes),
DaffCartRoutingModule,
],
exports: [
RouterModule,
Expand Down
5 changes: 0 additions & 5 deletions apps/demo/src/app/checkout/checkout-state.module.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
import { NgModule } from '@angular/core';
import { EffectsModule } from '@ngrx/effects';
import { StoreModule } from '@ngrx/store';

import { CheckoutEffects } from './effects/checkout.effects';
import { reducers } from './reducers';
import { CartResolverEffects } from '../cart/routing-resolvers/effects/cart-resolver.effects';

@NgModule({
imports: [
StoreModule.forFeature('demoCheckout', reducers),
EffectsModule.forFeature([
CheckoutEffects,
CartResolverEffects,
]),
],
})
Expand Down
13 changes: 0 additions & 13 deletions apps/demo/src/app/checkout/checkout.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,39 +2,26 @@ import { CommonModule } from '@angular/common';
import { NgModule } from '@angular/core';

import { DaffCartStateModule } from '@daffodil/cart/state';
import { StateCheckoutModule } from '@daffodil/checkout';
import { DaffAccordionModule } from '@daffodil/design/accordion';
import { DaffContainerModule } from '@daffodil/design/container';
import { DaffLoadingIconModule } from '@daffodil/design/loading-icon';

import { CheckoutRoutingModule } from './checkout-routing.module';
import { DemoCheckoutStateModule } from './checkout-state.module';
import { PaymentModule } from './components/payment/payment/payment.module';
import { PlaceOrderModule } from './components/place-order/place-order.module';
import { ShippingModule } from './components/shipping/shipping/shipping.module';
import { CheckoutViewComponent } from './pages/checkout-view/checkout-view.component';
import { CartSummaryWrapperModule } from '../cart/components/cart-summary-wrapper/cart-summary-wrapper.module';

@NgModule({
imports: [
CommonModule,
StateCheckoutModule,
DaffCartStateModule,
DaffLoadingIconModule,
DemoCheckoutStateModule,
CartSummaryWrapperModule,
ShippingModule,
PaymentModule,
PlaceOrderModule,
DaffAccordionModule,
DaffContainerModule,
CheckoutRoutingModule,
],
declarations: [
CheckoutViewComponent,
],
exports: [
CheckoutViewComponent,
],
})
export class CheckoutModule { }

This file was deleted.

Loading
Loading