diff --git a/src/app/custom-selector/custom-selector.component.ts b/src/app/custom-selector/custom-selector.component.ts index 91548dc..34e85ba 100644 --- a/src/app/custom-selector/custom-selector.component.ts +++ b/src/app/custom-selector/custom-selector.component.ts @@ -15,7 +15,7 @@ export class CustomSelectorComponent implements OnInit { @Input() defaultOptionId: string; selectedOption: { name: string, - id: string + id: string | number }; showDropdown: boolean = false; diff --git a/src/app/dashboard/dashboard.component.html b/src/app/dashboard/dashboard.component.html index 918ee2d..e3b959c 100644 --- a/src/app/dashboard/dashboard.component.html +++ b/src/app/dashboard/dashboard.component.html @@ -20,15 +20,15 @@
- +
  • -
    Confirmed
    -

    To be Packed

    +
    Accepted
    +

    To be Cooked / Packed

    @@ -37,7 +37,7 @@
    - +
  • @@ -54,7 +54,7 @@
    - +
    diff --git a/src/app/dashboard/dashboard.component.ts b/src/app/dashboard/dashboard.component.ts index d160bd9..c5f3745 100644 --- a/src/app/dashboard/dashboard.component.ts +++ b/src/app/dashboard/dashboard.component.ts @@ -1,4 +1,4 @@ -import { Component, OnInit } from '@angular/core'; +import { Component, OnInit, Output, EventEmitter } from '@angular/core'; import { IFilterOption } from '../models/filter-option'; import { OrderService } from '../services/order.service'; import * as moment from 'moment'; @@ -13,6 +13,8 @@ export class DashboardComponent implements OnInit { orderList: any = []; orderStatus: any = []; + @Output() dashboardEvents = new EventEmitter(); + constructor( private orderService: OrderService ) { } @@ -68,4 +70,11 @@ export class DashboardComponent implements OnInit { }) } + goToOrdersPage(type: 'pending' | 'delivered' | 'confirmed') { + this.dashboardEvents.emit({ + nav: 'orders', + type: type + }); + } + } diff --git a/src/app/models/filter-option.ts b/src/app/models/filter-option.ts index 4f6236f..d04bc42 100644 --- a/src/app/models/filter-option.ts +++ b/src/app/models/filter-option.ts @@ -1,4 +1,4 @@ export type IFilterOption = { name: string, - id: string + id: string | number }; diff --git a/src/app/orders/orders.component.html b/src/app/orders/orders.component.html index b0c6ed2..779131e 100644 --- a/src/app/orders/orders.component.html +++ b/src/app/orders/orders.component.html @@ -2,19 +2,33 @@
    Order List
    - - +
    +
    +
    + Status : {{ filterOption.orderStatus }} +
    + +
    +
      +
    • + {{ option.orderStatus }} +
    • +
    +
    +
    - +
    - +
    @@ -25,7 +39,7 @@ - +
    Order ID Action
    {{ order.orders_id }}
    @@ -52,7 +66,7 @@
    - +
      -
    • -
      - Order ID : 29320 - Order Time: 2 Mins ago -
      - - - - - - -
      -
      KFC Bucket
      -
      -
      Qty: 1
      -
      -
      ₹ 250
      -
      -
      -
      - Paid online -
      -
      - - -
      -
      -
    • - -
    • +
    • - Order ID : 29320 - Order Time: 2 Mins ago + Order ID : {{ order.orders_id }}
      - - - - - - -
      -
      KFC Bucket
      -
      -
      Qty: 1
      -
      -
      ₹ 250
      -
      +
      +
      {{ item.menu_item_name }} x {{ item.quantity }} = ₹ {{ getFixedDecimalPoints(item.total_price) }}
      +
      -
      - Paid online -
      -
      - - -
      -
      -
    • - -
    • -
      - Order ID : 29320 - Order Time: 2 Mins ago -
      - - - - - - -
      -
      KFC Bucket
      -
      -
      Qty: 1
      -
      -
      ₹ 250
      -
      -
      -
      - Paid online -
      -
      - - +
      + {{ getOrderStatus(order.orderstatus.orderstatus_id).orderStatus }} +
      +
      + +
    • diff --git a/src/app/orders/orders.component.scss b/src/app/orders/orders.component.scss index 550fc9f..b1ce9b5 100644 --- a/src/app/orders/orders.component.scss +++ b/src/app/orders/orders.component.scss @@ -16,14 +16,12 @@ display: flex; flex-grow: 1; - app-custom-selector { + .selector { margin: 0 10px; flex-grow: 1; @media screen and (max-width: 1023px) { margin: 0; - width: 45%; - flex-grow: 0; } } @@ -186,31 +184,13 @@ letter-spacing: 1px; } - table { - padding: 10px 15px; - width: 100%; - - td { - font-size: 14px; - color: var(--dark-grey); - font-weight: 500; - letter-spacing: 0.5px; - - &:nth-child(1) { - width: 50%; - } - - &:nth-child(2) { - width: 25%; - text-align: center; - } - - &:nth-child(3) { - width: 25%; - text-align: right; - } - } - } + .info { + font-size: 14px; + color: var(--dark-grey); + font-weight: 500; + letter-spacing: 0.5px; + padding: 10px 15px; + } .order-status-holder { background-color: #efefef; @@ -223,6 +203,17 @@ justify-content: space-between; align-items: center; + .status { + + &.success { + color: green; + } + + &.failed { + color: red; + } + } + .action-buttons { display: flex; width: auto; diff --git a/src/app/orders/orders.component.ts b/src/app/orders/orders.component.ts index 8e84d1c..539294f 100644 --- a/src/app/orders/orders.component.ts +++ b/src/app/orders/orders.component.ts @@ -1,5 +1,4 @@ -import { Component, OnInit } from '@angular/core'; -import { IFilterOption } from '../models/filter-option'; +import { Component, OnInit, Input } from '@angular/core'; import { OrderService } from '../services/order.service'; import * as moment from 'moment'; @@ -9,26 +8,54 @@ import * as moment from 'moment'; styleUrls: ['./orders.component.scss'] }) export class OrdersComponent implements OnInit { - statusOptions: Array; - dateOptions: Array; showRejectionPopup: boolean = false; orderList: any = []; + tempOrderList: any = []; orderStatus: any = []; + searchTerm: string = ''; + showFilter: boolean = false; + filterOption: { + orderStatus: string, + orderstatus_id: number + } = { + orderStatus: 'All', + orderstatus_id: 0 + }; + + @Input() params: any; constructor( private orderService: OrderService ) { } ngOnInit() { - this.statusOptions = [{ - name: 'All', - id: 'all' - }]; - - this.dateOptions = [{ - name: 'Today', - id: 'today' - }]; + if (this.params) { + try { + switch(this.params.filterType) { + case 'pending': this.filterOption = { + orderStatus: 'Pending', + orderstatus_id: 6 + }; break; + case 'delivered': this.filterOption = { + orderStatus: 'Delivered', + orderstatus_id: 3 + }; break; + case 'confirmed': this.filterOption = { + orderStatus: 'Accepted', + orderstatus_id: 1 + }; break; + default: this.filterOption = { + orderStatus: 'All', + orderstatus_id: 0 + }; break; + } + } catch { + this.filterOption = { + orderStatus: 'All', + orderstatus_id: 0 + }; + } + } this.orderService.getOrders().then((data) => { this.orderList = data; @@ -36,13 +63,21 @@ export class OrdersComponent implements OnInit { this.orderList = this.orderList.filter((order) => { return order.orderstatus; }); + + this.tempOrderList = this.orderList.filter((order) => { + return order.orderstatus; + }); }, () => { alert("Error getting the orders"); }); - this.orderService.getallOrderStatus().then((data) => { - console.log(data); + this.orderService.getallOrderStatus().then((data: any) => { this.orderStatus = data; + + this.orderStatus.push({ + orderStatus: 'All', + orderstatus_id: 0 + }); }, () => { alert("Error getting the order statuses"); }); @@ -71,4 +106,20 @@ export class OrdersComponent implements OnInit { }) } + getFilteredOrders(id: number, orders?: any) { + if (id > 0) { + return this.tempOrderList.filter((order) => { + return order.orderstatus.orderstatus_id === id; + }); + } else { + return this.tempOrderList; + } + } + + searchOrders() { + this.tempOrderList = this.orderList.filter((order: any) => { + return order.orders_id.toString().toLowerCase().includes(this.searchTerm.toLowerCase()); + }); + } + } diff --git a/src/app/widgets-holder/widgets-holder.component.html b/src/app/widgets-holder/widgets-holder.component.html index 183135b..f4d47af 100644 --- a/src/app/widgets-holder/widgets-holder.component.html +++ b/src/app/widgets-holder/widgets-holder.component.html @@ -5,7 +5,7 @@ (click)="selected_nav = 'faq'"> FAQ's Support - + @@ -21,37 +21,37 @@
        -
      • +
      • -
      • +
      • -
      • +
      • -
      • +
      • -
      • +
      • -
      • +
      • -
      • +
      - - - - - - + + + + + +
    diff --git a/src/app/widgets-holder/widgets-holder.component.scss b/src/app/widgets-holder/widgets-holder.component.scss index 284a9a6..e3e3548 100644 --- a/src/app/widgets-holder/widgets-holder.component.scss +++ b/src/app/widgets-holder/widgets-holder.component.scss @@ -244,6 +244,8 @@ .widgets { width: 80%; + height: calc(100vh - 70px); + overflow: auto; @media screen and (max-width: 1023px) { width: 100%; diff --git a/src/app/widgets-holder/widgets-holder.component.ts b/src/app/widgets-holder/widgets-holder.component.ts index d3b3f81..623a794 100644 --- a/src/app/widgets-holder/widgets-holder.component.ts +++ b/src/app/widgets-holder/widgets-holder.component.ts @@ -1,4 +1,5 @@ import { Component, OnInit } from '@angular/core'; +import { Router } from '@angular/router'; @Component({ selector: 'app-widgets-holder', @@ -6,10 +7,18 @@ import { Component, OnInit } from '@angular/core'; styleUrls: ['./widgets-holder.component.scss'] }) export class WidgetsHolderComponent implements OnInit { - selected_nav: string = 'dashboard'; + selected_nav: { + name: string, + params: any + } = { + name: 'orders', + params: '' + }; vendor_info: any; - constructor() { } + constructor( + private router: Router + ) { } ngOnInit() { let data = JSON.parse(localStorage.vendor_info); @@ -17,7 +26,21 @@ export class WidgetsHolderComponent implements OnInit { } getNavPage(page: string) { - this.selected_nav = page; + this.selected_nav.name = page; } + getWidgetsEvents(event: any) { + if (event.nav === 'orders') { + this.selected_nav.name = 'orders' + this.selected_nav.params = { + filterType: event.type + }; + } + } + + logout() { + localStorage.clear(); + this.router.navigate(['/']); + } + } diff --git a/src/styles.scss b/src/styles.scss index ff897af..6d5b0e1 100644 --- a/src/styles.scss +++ b/src/styles.scss @@ -180,3 +180,71 @@ button { transform: translateX(2px); } } + + +.selector { + position: relative; + + .container { + display: flex; + width: 100%; + border-radius: 20px; + background-color: white; + color: var(--brand-blue); + align-items: center; + justify-content: space-between; + position: relative; + + .selected-value { + font-weight: 500; + margin-left: 20px; + font-size: 14px; + + span { + margin-left: 5px; + } + } + + button { + border-radius: 50%; + width: 30px; + height: 30px; + color: var(--brand-blue); + font-size: 20px; + border: 1px solid var(--brand-blue); + background-color: white; + transition: background-color 0.3s, color 0.3s; + + &:hover { + background-color: var(--brand-blue); + color: white; + } + } + } + + ul { + list-style: none; + background-color: white; + width: 80%; + margin: 0 auto; + border-bottom-left-radius: 10px; + border-bottom-right-radius: 10px; + overflow: hidden; + position: absolute; + left: 10%; + top: 100%; + } + + li { + padding: 10px; + font-size: 14px; + color: var(--brand-blue); + cursor: pointer; + transition: background-color 0.3s, color 0.3s; + + &:hover { + background-color: var(--brand-blue); + color: white; + } + } +}