diff --git a/angular/src/app/components/user-data-order/user-data-order.component.html b/angular/src/app/components/user-data-order/user-data-order.component.html index a5f8d7e..4049439 100644 --- a/angular/src/app/components/user-data-order/user-data-order.component.html +++ b/angular/src/app/components/user-data-order/user-data-order.component.html @@ -8,7 +8,7 @@
-
diff --git a/angular/src/app/components/user-data-order/user-data-order.component.ts b/angular/src/app/components/user-data-order/user-data-order.component.ts index 5e7bbe6..b5226b1 100644 --- a/angular/src/app/components/user-data-order/user-data-order.component.ts +++ b/angular/src/app/components/user-data-order/user-data-order.component.ts @@ -134,15 +134,15 @@ export class UserDataOrderComponent implements OnInit, OnDestroy { changeDeliveryType(event: any) { this.deliverData.deliveryType = event.value; - if (this.deliverData.deliveryType?.title) { - this.changeValidators(this.deliverData.deliveryType.title) + if (this.deliverData.deliveryType?.name) { + this.changeValidators(this.deliverData.deliveryType.name) } } - changeValidators(title: string) { + changeValidators(name: string) { const comment = this.mainFormGroup.controls['deliveryDataForm'].value.comment; - const streetValidators = title === 'Доставка' ? [Validators.required, Validators.minLength(2), Validators.maxLength(255),] : [] - const houseValidators = title === 'Доставка' ? [Validators.required, Validators.maxLength(10),] : [] + const streetValidators = name === 'Доставка' ? [Validators.required, Validators.minLength(2), Validators.maxLength(255),] : [] + const houseValidators = name === 'Доставка' ? [Validators.required, Validators.maxLength(10),] : [] const userDataForm = this.fb.group({ phone: [this.userData.phone], first_name: [this.userData.first_name, [Validators.required, Validators.minLength(2), Validators.maxLength(255),]], @@ -233,7 +233,7 @@ export class UserDataOrderComponent implements OnInit, OnDestroy { this.userData.city = this.cities[0]; this.userData.phone = this.order.phone; // await this.autoCompleteService.setCity(this.userData.city); - const isSelfDelivery = this.deliverData.deliveryType?.type === "self_delivery" + const isSelfDelivery = this.deliverData.deliveryType?.name === "Самовывоз" return this.fb.group({ phone: [this.userData.phone], first_name: [this.userData.first_name, [Validators.required, Validators.minLength(2), Validators.maxLength(255),]], diff --git a/angular/src/app/interface/data.ts b/angular/src/app/interface/data.ts index c766072..8256ce9 100644 --- a/angular/src/app/interface/data.ts +++ b/angular/src/app/interface/data.ts @@ -1,189 +1,191 @@ -import { CartProduct } from "../models/cart-product"; - +import { CartProduct } from '../models/cart-product'; export enum PageCode { - // Auth, - BonusProgram, - Orders, - RefSystem, - UserData + // Auth, + BonusProgram, + Orders, + RefSystem, + UserData, } export enum MainPageCode { - Account, - Products, - Cart, - Info + Account, + Products, + Cart, + Info, } export interface Page { - code: PageCode | MainPageCode; - component?: any; - name: string; - description?: string; - getMethod?: string; - resName?: string; - onSideBar: boolean - icon?: string; + code: PageCode | MainPageCode; + component?: any; + name: string; + description?: string; + getMethod?: string; + resName?: string; + onSideBar: boolean; + icon?: string; } export interface UserDataForm { - first_name: string; - birthdate: string; - gender: string; + first_name: string; + birthdate: string; + gender: string; } export interface BonusProgramAccount { - // BonusProgramName: string; - // BonusProgramTypeID: string; - CardNumber: number; - Bonuses: number; - // HoldedBonuses: number; - // BonusProgramAccounts: BonusProgramAccount[]; - // DateBonusBurn: string; - // _links: any[]; - // _embedded: any; + // BonusProgramName: string; + // BonusProgramTypeID: string; + CardNumber: number; + Bonuses: number; + // HoldedBonuses: number; + // BonusProgramAccounts: BonusProgramAccount[]; + // DateBonusBurn: string; + // _links: any[]; + // _embedded: any; } export interface Purchase { - // PurchaseId?: string; - // CustomerId?: string; - // PurchaseDate: string; - // PurchaseState?: number; - // CardNumber?: number; - // Address?: string - // CheckSummary?: number - // BonusSummary?: number - // ID: string; - // Transactions: Transaction[]; - // IsSingleTransaction?: boolean; - transactionCreateDate: string; - orderSum: number; - transactionSum: number; + // PurchaseId?: string; + // CustomerId?: string; + // PurchaseDate: string; + // PurchaseState?: number; + // CardNumber?: number; + // Address?: string + // CheckSummary?: number + // BonusSummary?: number + // ID: string; + // Transactions: Transaction[]; + // IsSingleTransaction?: boolean; + transactionCreateDate: string; + orderSum: number; + transactionSum: number; } export interface Transaction { - User: string; - Purchase: string; - Date: string; - Value: number; - TransactionType: number; - UserBonusesSnapshot: number; - BonusPercent: number; - DateActiveBonus: string; - AccountBonus: string; - Bonus: string; - ID: string; - HasPurchase?: boolean; + User: string; + Purchase: string; + Date: string; + Value: number; + TransactionType: number; + UserBonusesSnapshot: number; + BonusPercent: number; + DateActiveBonus: string; + AccountBonus: string; + Bonus: string; + ID: string; + HasPurchase?: boolean; } export interface OrderStatus { - [key: string]: string; + [key: string]: string; } export interface DeliveryType { - cost: number; - title: string; - id: number; - type: string; - name: string; +// cost: number; +// title: string; +// id: number; +// type: string; + name: string; + iikoId: string; + iikoName: string; + isPickUp: boolean; } export interface AcceptedOrder { - id: number; - status: string; - currency_symbol: string; + id: number; + status: string; + currency_symbol: string; + total: number; + address: { + city: string; + street: string; + house: number; + flat: number; + }; + payment_method: string; + shipping: { + name: string; total: number; - address: { - city: string; - street: string; - house: number; - flat: number; - }; - payment_method: string; - shipping: { - name: string; - total: number; - }; - date_created: string; - items: OrderProduct[] + }; + date_created: string; + items: OrderProduct[]; } export interface Product { - id: string; - name: string; - price: number; - image: string; - image_gallery: string[]; - category_id: number; - description: string; - stock_status: string; - currency_symbol: string; - modifier_data: CartModifier[]; - short_description: string; - guid: string; - groupId: string; - modifiers_group: string[]; + id: string; + name: string; + price: number; + image: string; + image_gallery: string[]; + category_id: number; + description: string; + stock_status: string; + currency_symbol: string; + modifier_data: CartModifier[]; + short_description: string; + guid: string; + groupId: string; + modifiers_group: string[]; } export interface AllData { - datetime: string; - groups: Group[]; - products: Product[]; - modifiers_groups: ModifiersGroup[]; - modifiers: Modifier[]; - categories: any[] + datetime: string; + groups: Group[]; + products: Product[]; + modifiers_groups: ModifiersGroup[]; + modifiers: Modifier[]; + categories: any[]; } export interface Group { - id: string; - label: string; + id: string; + label: string; } export interface ModifiersGroup { - name: string, - id: string, - restrictions: { - minQuantity: number, - maxQuantity: number, - freeQuantity: number, - byDefault: number - } + name: string; + id: string; + restrictions: { + minQuantity: number; + maxQuantity: number; + freeQuantity: number; + byDefault: number; + }; } export interface Modifier { - id: string, - idLocal: string, - name: string, - groupId: string, - price?: number, - quantity?: number, - image?: string; - restrictions: { - minQuantity: number, - maxQuantity: number, - freeQuantity: number, - byDefault: number - } + id: string; + idLocal: string; + name: string; + groupId: string; + price?: number; + quantity?: number; + image?: string; + restrictions: { + minQuantity: number; + maxQuantity: number; + freeQuantity: number; + byDefault: number; + }; } export interface CartModifier { - lastChangeOption?: string; - id: string; - idLocal: string; - name: string; - options: Modifier[]; - allQuantity: number; - restrictions: { - minQuantity: number, - maxQuantity: number, - freeQuantity: number, - byDefault: number - } + lastChangeOption?: string; + id: string; + idLocal: string; + name: string; + options: Modifier[]; + allQuantity: number; + restrictions: { + minQuantity: number; + maxQuantity: number; + freeQuantity: number; + byDefault: number; + }; } export interface Cart { - products: CartProduct[]; + products: CartProduct[]; } // export interface Modifier { @@ -199,53 +201,53 @@ export interface Cart { // } export interface Option { - id: number; - name: string; - groupId: string; - restrictions: { - minQuantity: number, - maxQuantity: number, - freeQuantity: number, - byDefault: number - } + id: number; + name: string; + groupId: string; + restrictions: { + minQuantity: number; + maxQuantity: number; + freeQuantity: number; + byDefault: number; + }; } export interface OrderProduct { - id: number; - amount: number; - name: string; - price: number; - modifiers: { - [name: string]: OrderModifier[] - } + id: number; + amount: number; + name: string; + price: number; + modifiers: { + [name: string]: OrderModifier[]; + }; } export interface OrderModifier { - name: string; - id: number; - price: number; + name: string; + id: number; + price: number; } export interface DeliveryData { - paymentMethod: PaymentMethod | null; - deliveryDate: Date | null; - deliveryType: DeliveryType | null; - persons: number; - comment: string; - orderid: number; + paymentMethod: PaymentMethod | null; + deliveryDate: Date | null; + deliveryType: DeliveryType | null; + persons: number; + comment: string; + orderid: number; } export interface PaymentMethod { - type: string; - label: string; + type: string; + label: string; } export interface UserData { - first_name: string | null; - last_name: string | null; - street: string | null; - house: string | null; - flat: string | null; - city: string; - phone: string | null; -} \ No newline at end of file + first_name: string | null; + last_name: string | null; + street: string | null; + house: string | null; + flat: string | null; + city: string; + phone: string | null; +} diff --git a/angular/src/app/models/order.ts b/angular/src/app/models/order.ts index e5795c3..c238659 100644 --- a/angular/src/app/models/order.ts +++ b/angular/src/app/models/order.ts @@ -54,8 +54,13 @@ export class Order { delivery_fio: this.userData?.first_name, subtotal: this.price, delivery_comment: this.deliveryData?.comment, - delivery: this.deliveryData?.deliveryType?.type, - delivery_address: this.deliveryData?.deliveryType?.type === "self_delivery" ? '' : `${environment.cities[0]}, ул ${this.userData?.street}, ${this.userData?.house}`, + delivery: this.deliveryData?.deliveryType?.name, + delivery_address: { + street: this.userData?.street || '', + house: this.userData?.house || '', + flat: '', + city: '' + }, amount: this.price + 100, terminal_id: this.terminal_id },