📘 Frontend Development: Components

This section provides an overview of the UI components in the Angular-based frontend application. These components are located in the src/app/components directory. Each component plays a specific role in rendering the user interface and managing interactions.


📂 Components Overview

Component Name Description File Path
OrdersComponent Manages and displays orders, including search and table-based order listings. src/app/components/orders/orders.component.ts【4:3†source】
AddTrackingComponent Handles adding tracking information for orders and supports multiple shipping services. src/app/components/add-tracking/add-tracking.component.ts【4:10†source】
BrandProfileComponent Displays and updates brand profile details like name, email, and website. src/app/components/brand-profile/brand-profile.component.ts【4:9†source】

🔍 Component Details

🛒 OrdersComponent

  • Purpose: Displays a list of orders with search and filtering capabilities.
  • Features:
    • Search orders by number.
    • Display order details such as customer, total price, items, and fulfillment status.
    • Actions for managing orders.
  • Code Snippet:
    <div class="container mw_1440">
      <div class="right_head">
        <h2 class="heading_main">Orders</h2>
      </div>
      <div class="row">
        <div class="col-3">
          <label>Order</label>:
          <input class="form-control" [(ngModel)]="search_order" placeholder="Search Order Exa. 1001">
        </div>
        <div class="col-6">
          <button class="btn btn-primary" (click)="searchOrder(true)">Search</button>
          <button class="btn btn-danger" (click)="searchOrder(false)">Clear</button>
        </div>
      </div>
      <div class="data_container">
        <table class="table table_ui_1">
          <thead>
            <tr>
              <th>Order</th>
              <th>Customer</th>
              <th>Total</th>
              <th>Order placed on</th>
              <th>Items</th>
              <th>Fulfillment Status</th>
              <th>Actions</th>
            </tr>
          </thead>
          <tbody>
            <tr *ngFor="let order of orders">
              <td>{{order.order_number}}</td>
              <td>{{order.email}}</td>
              <td>{{order.total_price}}</td>
              <td>{{order.created_at}}</td>
              <td>{{order.line_items.length}}</td>
              <td>
                <span *ngIf="order.fulfillment_status === 'fulfilled'">FULFILLED</span>
              </td>
            </tr>
          </tbody>
        </table>
      </div>
    </div>
    
  • File Path: src/app/components/orders/orders.component.html【4:3†source】

📦 AddTrackingComponent

  • Purpose: Allows users to add tracking information for order fulfillments.
  • Features:
    • Supports multiple shipping services (e.g., UPS, FedEx, and custom services).
    • Dynamically generates tracking URLs based on the selected service.
    • Validates form inputs.
  • Code Snippet:
    this.trackingForm = new FormGroup({
      trackingNo: new FormControl('', [Validators.required]),
      trackingUrl: new FormControl(''),
      shippingService: new FormControl('', [Validators.required]),
    });
    
    save() {
      if (this.trackingForm.invalid) {
        return;
      }
      this.helperService.addTracking(this.trackingForm.value).subscribe(
        (response) => {
          this.toastr.success('Tracking added successfully!');
        },
        (error) => {
          this.toastr.error('Failed to add tracking.');
        }
      );
    }
    
  • File Path: src/app/components/add-tracking/add-tracking.component.ts【4:10†source】

🏢 BrandProfileComponent

  • Purpose: Displays and allows editing of brand profile information.
  • Features:
    • Fetches brand data from the backend.
    • Allows updates to brand details such as name, email, contact, and website.
    • Provides a back navigation option.
  • Code Snippet:
    updateBrand() {
      const data = this.filterValidEntries({
        brandName: this.brandName,
        email: this.email,
        contact: this.contact,
        website: this.website,
      });
    
      this.brandService.updateBrand(data).subscribe(
        (res) => {
          this.toastr.success('Brand updated successfully!');
        },
        (error) => {
          this.toastr.error('Failed to update brand.');
        }
      );
    }
    
  • File Path: src/app/components/brand-profile/brand-profile.component.ts【4:9†source】

🎨 Styling

The components use SCSS for styling, ensuring a modular and maintainable CSS structure. Styles are organized into categories like:

  • Helpers for mixins and variables.
  • Base for icons and fonts.
  • Components for buttons, modals, etc.

Example SCSS for buttons:

.btn_1 {
  background-color: #2D9CDB;
  color: #FFFFFF;
  border-radius: 4px;
  &:hover {
    background-color: #2684b9;
  }
}

File Path: src/assets/scss/components/_buttons.scss【4:18†source】


🚀 Conclusion

These components form the backbone of the frontend application, offering a clean and interactive user interface for managing orders, tracking, and brand profiles. Each component is carefully designed with Angular best practices and integrates seamlessly with backend APIs.