Skip to content

Commit d4599ae

Browse files
committed
Convert checkout to standalone
1 parent 89b9f06 commit d4599ae

14 files changed

Lines changed: 35 additions & 107 deletions

File tree

apps/demo/src/app/app-routing.module.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export const appRoutes: Routes = [
3939
},
4040
{
4141
path: 'checkout',
42-
loadChildren: () => import('./checkout/checkout.module').then(m => m.CheckoutModule),
42+
loadChildren: () => import('./checkout/checkout.routes').then(m => m.demoCheckoutRoutes),
4343
},
4444
{ path: '404', component: NotFoundComponent },
4545
{

apps/demo/src/app/checkout/checkout-state.module.ts

Lines changed: 0 additions & 13 deletions
This file was deleted.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { importProvidersFrom } from '@angular/core';
2+
import { EffectsModule } from '@ngrx/effects';
3+
4+
import { CheckoutEffects } from './effects/checkout.effects';
5+
6+
export const provideDemoCheckoutState = () => [
7+
importProvidersFrom(EffectsModule.forFeature([CheckoutEffects])),
8+
];

apps/demo/src/app/checkout/checkout.module.ts

Lines changed: 0 additions & 27 deletions
This file was deleted.
Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,33 @@
11
import {
2-
NgModule,
2+
importProvidersFrom,
33
inject,
44
} from '@angular/core';
55
import {
66
ActivatedRouteSnapshot,
7-
RouterModule,
8-
RouterStateSnapshot,
97
Routes,
8+
RouterStateSnapshot,
109
} from '@angular/router';
1110

1211
import {
1312
DaffCartInStockItemsGuard,
1413
DaffCartItemsGuard,
15-
DaffCartRoutingModule,
1614
DaffResolveCartGuard,
15+
DaffCartRoutingModule,
1716
} from '@daffodil/cart/routing';
1817
import { daffRouterComposeGuards } from '@daffodil/router';
1918

19+
import { provideDemoCheckoutState } from './checkout-state.provider';
2020
import { DemoCheckoutViewComponent } from './pages/checkout-view/checkout-view.component';
2121
import { ThankYouViewComponent } from '../thank-you/pages/thank-you-view.component';
2222

23-
const routes: Routes = [
23+
export const demoCheckoutRoutes: Routes = [
2424
{
2525
path: '',
2626
pathMatch: 'full',
27+
providers: [
28+
provideDemoCheckoutState(),
29+
importProvidersFrom(DaffCartRoutingModule),
30+
],
2731
children: [
2832
{ path: '', component: DemoCheckoutViewComponent },
2933
{ path: 'thank-you', component: ThankYouViewComponent },
@@ -44,14 +48,3 @@ const routes: Routes = [
4448
],
4549
},
4650
];
47-
48-
@NgModule({
49-
imports: [
50-
RouterModule.forChild(routes),
51-
DaffCartRoutingModule,
52-
],
53-
exports: [
54-
RouterModule,
55-
],
56-
})
57-
export class CheckoutRoutingModule { }

apps/demo/src/app/checkout/components/payment/payment-form/payment-form.component.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ import {
1212

1313
import { DaffAuthorizeNetCreditCard } from '@daffodil/authorizenet';
1414
import { DaffCartAddress } from '@daffodil/cart';
15-
import { DaffButtonComponent } from '@daffodil/design/button';
16-
import { DaffCheckboxModule } from '@daffodil/design/checkbox';
15+
import { DAFF_BUTTON_COMPONENTS } from '@daffodil/design/button';
16+
import { DAFF_CHECKBOX_COMPONENTS } from '@daffodil/design/checkbox';
1717
import { DaffInputComponent } from '@daffodil/design/input';
1818

1919
import { DemoGeographyAddressSummaryComponent } from '../../../../geography/components/address-summary/address-summary.component';
@@ -31,8 +31,8 @@ import { PaymentInfoFormFactory } from '../payment-info-form/factories/payment-i
3131
ReactiveFormsModule,
3232
DaffInputComponent,
3333
DemoCheckoutPaymentInfoFormComponent,
34-
DaffButtonComponent,
35-
DaffCheckboxModule,
34+
DAFF_BUTTON_COMPONENTS,
35+
DAFF_CHECKBOX_COMPONENTS,
3636
DemoCheckoutAddressFormComponent,
3737
DemoGeographyAddressSummaryComponent,
3838
],

apps/demo/src/app/checkout/components/payment/payment-summary/payment-summary.component.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import { DaffAuthorizeNetCreditCard } from '@daffodil/authorizenet';
1111
selector: 'demo-checkout-payment-summary',
1212
templateUrl: './payment-summary.component.html',
1313
styleUrls: ['./payment-summary.component.scss'],
14-
standalone: true,
1514
})
1615
export class DemoCheckoutPaymentSummaryComponent {
1716
@Input() paymentInfo: DaffAuthorizeNetCreditCard;

apps/demo/src/app/checkout/components/place-order/place-order.component.spec.ts

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,6 @@ import {
44
TestBed,
55
} from '@angular/core/testing';
66
import { By } from '@angular/platform-browser';
7-
import {
8-
provideMockStore,
9-
MockStore,
10-
} from '@ngrx/store/testing';
117
import { of } from 'rxjs';
128

139
import { DaffCart } from '@daffodil/cart';
@@ -22,22 +18,15 @@ import { PlaceOrderComponent } from './place-order.component';
2218
describe('PlaceOrderComponent', () => {
2319
let fixture: ComponentFixture<PlaceOrderComponent>;
2420
let component: PlaceOrderComponent;
25-
const stubEnablePlaceOrderButton = true;
26-
let store: MockStore<any>;
2721
let cartFactory: DaffCartFactory;
2822
let stubCart: DaffCart;
2923
let cartFacade: MockDaffCartFacade;
3024

3125
beforeEach(waitForAsync(() => {
3226
TestBed.configureTestingModule({
33-
declarations: [
34-
PlaceOrderComponent,
35-
],
36-
providers: [
37-
provideMockStore({}),
38-
],
3927
imports: [
4028
DaffCartStateTestingModule,
29+
PlaceOrderComponent,
4130
],
4231
})
4332
.compileComponents();
@@ -46,7 +35,6 @@ describe('PlaceOrderComponent', () => {
4635
beforeEach(() => {
4736
fixture = TestBed.createComponent(PlaceOrderComponent);
4837
component = fixture.componentInstance;
49-
store = TestBed.inject(MockStore);
5038
cartFactory = TestBed.inject(DaffCartFactory);
5139
stubCart = cartFactory.create();
5240
cartFacade = TestBed.inject(MockDaffCartFacade);
@@ -57,10 +45,6 @@ describe('PlaceOrderComponent', () => {
5745
fixture.detectChanges();
5846
});
5947

60-
afterAll(() => {
61-
store.resetSelectors();
62-
});
63-
6448
it('should create', () => {
6549
expect(component).toBeTruthy();
6650
});

apps/demo/src/app/checkout/components/place-order/place-order.component.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { AsyncPipe } from '@angular/common';
12
import {
23
Component,
34
OnInit,
@@ -9,12 +10,16 @@ import {
910
DaffCartFacade,
1011
DaffCartPlaceOrder,
1112
} from '@daffodil/cart/state';
13+
import { DAFF_BUTTON_COMPONENTS } from '@daffodil/design/button';
1214

1315
@Component({
1416
selector: 'demo-place-order',
1517
templateUrl: './place-order.component.html',
1618
styleUrls: ['./place-order.component.scss'],
17-
standalone: false,
19+
imports: [
20+
DAFF_BUTTON_COMPONENTS,
21+
AsyncPipe,
22+
],
1823
})
1924
export class PlaceOrderComponent implements OnInit {
2025
enablePlaceOrderButton$: Observable<boolean>;

apps/demo/src/app/checkout/components/place-order/place-order.module.ts

Lines changed: 0 additions & 20 deletions
This file was deleted.

0 commit comments

Comments
 (0)