Skip to content

Commit bf20589

Browse files
authored
refactor(demo): convert checkout to standalone (#4307)
1 parent fcc04e4 commit bf20589

14 files changed

Lines changed: 34 additions & 92 deletions

File tree

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,11 @@ export const appRoutes: Routes = [
3535
},
3636
{
3737
path: 'category',
38-
loadChildren: () => import('./category/category.routes').then(m => m.demoCategoryRoutes),
38+
loadChildren: () => import('./category/category.routes').then(r => r.demoCategoryRoutes),
3939
},
4040
{
4141
path: 'checkout',
42-
loadChildren: () => import('./checkout/checkout.module').then(m => m.CheckoutModule),
42+
loadChildren: () => import('./checkout/checkout.routes').then(r => r.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: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
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]));

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

Lines changed: 0 additions & 25 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: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import {
1313
import { DaffAuthorizeNetCreditCard } from '@daffodil/authorizenet';
1414
import { DaffCartAddress } from '@daffodil/cart';
1515
import { DaffButtonComponent } from '@daffodil/design/button';
16-
import { DaffCheckboxModule } from '@daffodil/design/checkbox';
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';
@@ -32,7 +32,7 @@ import { PaymentInfoFormFactory } from '../payment-info-form/factories/payment-i
3232
DaffInputComponent,
3333
DemoCheckoutPaymentInfoFormComponent,
3434
DaffButtonComponent,
35-
DaffCheckboxModule,
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: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,23 +22,20 @@ import { PlaceOrderComponent } from './place-order.component';
2222
describe('PlaceOrderComponent', () => {
2323
let fixture: ComponentFixture<PlaceOrderComponent>;
2424
let component: PlaceOrderComponent;
25-
const stubEnablePlaceOrderButton = true;
2625
let store: MockStore<any>;
2726
let cartFactory: DaffCartFactory;
2827
let stubCart: DaffCart;
2928
let cartFacade: MockDaffCartFacade;
3029

3130
beforeEach(waitForAsync(() => {
3231
TestBed.configureTestingModule({
33-
declarations: [
32+
imports: [
33+
DaffCartStateTestingModule,
3434
PlaceOrderComponent,
3535
],
3636
providers: [
3737
provideMockStore({}),
3838
],
39-
imports: [
40-
DaffCartStateTestingModule,
41-
],
4239
})
4340
.compileComponents();
4441
}));

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 { DaffButtonComponent } 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+
DaffButtonComponent,
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)