Add the checkout Place order button

Angular · Angular · beginner · greenfield

Adds the checkout submit action as a small standalone component. Placing an order flips the button label to a progress state, navigates to the confirmation page when the API resolves, and surfaces a retry message when it rejects. State is all signals, template uses the new control flow.

Checkout page of the storefront. Order creation charges the customer's saved payment method server-side.

Requirements

Files touched

--- src/app/checkout/checkout-actions.component.ts
+import { Component, inject, signal } from '@angular/core';
+import { Router } from '@angular/router';
+import { OrdersService } from '../services/orders.service';
+
+@Component({
+  selector: 'app-checkout-actions',
+  standalone: true,
+  template: `
+    <div class="checkout-actions">
+      @if (errorMessage()) {
+        <p class="checkout-error">{{ errorMessage() }}</p>
+      }
+      <button type="button" class="btn-primary" (click)="placeOrder()">
+        {{ placing() ? 'Placing order…' : 'Place order' }}
+      </button>
+    </div>
+  `,
+})
+export class CheckoutActionsComponent {
+  private readonly orders = inject(OrdersService);
+  private readonly router = inject(Router);
+
+  readonly placing = signal(false);
+  readonly errorMessage = signal('');
+
+  async placeOrder(): Promise<void> {
+    this.placing.set(true);
+    this.errorMessage.set('');
+    try {

Review this PR

Angular practice