поменял формат адреса, починил тип доставки
This commit is contained in:
gofnnp 2023-02-19 22:23:20 +04:00
parent c282a6e521
commit c24e94c255
4 changed files with 186 additions and 179 deletions

View File

@ -8,7 +8,7 @@
<p сlass="form-row form-row-wide"> <p сlass="form-row form-row-wide">
<input formControlName="first_name" id="first_name" pInputText placeholder="Ваше имя" type="text"> <input formControlName="first_name" id="first_name" pInputText placeholder="Ваше имя" type="text">
</p> </p>
<div *ngIf="deliverData.deliveryType?.title === 'Доставка'"> <div *ngIf="deliverData.deliveryType?.name === 'Доставка'">
<p сlass="form-row form-row-last"> <p сlass="form-row form-row-last">
<input formControlName="flat" id="flat" pInputText placeholder="Квартира" type="number" min="1"> <input formControlName="flat" id="flat" pInputText placeholder="Квартира" type="number" min="1">
</p> </p>

View File

@ -134,15 +134,15 @@ export class UserDataOrderComponent implements OnInit, OnDestroy {
changeDeliveryType(event: any) { changeDeliveryType(event: any) {
this.deliverData.deliveryType = event.value; this.deliverData.deliveryType = event.value;
if (this.deliverData.deliveryType?.title) { if (this.deliverData.deliveryType?.name) {
this.changeValidators(this.deliverData.deliveryType.title) this.changeValidators(this.deliverData.deliveryType.name)
} }
} }
changeValidators(title: string) { changeValidators(name: string) {
const comment = this.mainFormGroup.controls['deliveryDataForm'].value.comment; const comment = this.mainFormGroup.controls['deliveryDataForm'].value.comment;
const streetValidators = title === 'Доставка' ? [Validators.required, Validators.minLength(2), Validators.maxLength(255),] : [] const streetValidators = name === 'Доставка' ? [Validators.required, Validators.minLength(2), Validators.maxLength(255),] : []
const houseValidators = title === 'Доставка' ? [Validators.required, Validators.maxLength(10),] : [] const houseValidators = name === 'Доставка' ? [Validators.required, Validators.maxLength(10),] : []
const userDataForm = this.fb.group({ const userDataForm = this.fb.group({
phone: [this.userData.phone], phone: [this.userData.phone],
first_name: [this.userData.first_name, [Validators.required, Validators.minLength(2), Validators.maxLength(255),]], 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.city = this.cities[0];
this.userData.phone = this.order.phone; this.userData.phone = this.order.phone;
// await this.autoCompleteService.setCity(this.userData.city); // 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({ return this.fb.group({
phone: [this.userData.phone], phone: [this.userData.phone],
first_name: [this.userData.first_name, [Validators.required, Validators.minLength(2), Validators.maxLength(255),]], first_name: [this.userData.first_name, [Validators.required, Validators.minLength(2), Validators.maxLength(255),]],

View File

@ -1,19 +1,18 @@
import { CartProduct } from "../models/cart-product"; import { CartProduct } from '../models/cart-product';
export enum PageCode { export enum PageCode {
// Auth, // Auth,
BonusProgram, BonusProgram,
Orders, Orders,
RefSystem, RefSystem,
UserData UserData,
} }
export enum MainPageCode { export enum MainPageCode {
Account, Account,
Products, Products,
Cart, Cart,
Info Info,
} }
export interface Page { export interface Page {
@ -23,7 +22,7 @@ export interface Page {
description?: string; description?: string;
getMethod?: string; getMethod?: string;
resName?: string; resName?: string;
onSideBar: boolean onSideBar: boolean;
icon?: string; icon?: string;
} }
@ -82,11 +81,14 @@ export interface OrderStatus {
} }
export interface DeliveryType { export interface DeliveryType {
cost: number; // cost: number;
title: string; // title: string;
id: number; // id: number;
type: string; // type: string;
name: string; name: string;
iikoId: string;
iikoName: string;
isPickUp: boolean;
} }
export interface AcceptedOrder { export interface AcceptedOrder {
@ -106,7 +108,7 @@ export interface AcceptedOrder {
total: number; total: number;
}; };
date_created: string; date_created: string;
items: OrderProduct[] items: OrderProduct[];
} }
export interface Product { export interface Product {
@ -132,7 +134,7 @@ export interface AllData {
products: Product[]; products: Product[];
modifiers_groups: ModifiersGroup[]; modifiers_groups: ModifiersGroup[];
modifiers: Modifier[]; modifiers: Modifier[];
categories: any[] categories: any[];
} }
export interface Group { export interface Group {
@ -141,30 +143,30 @@ export interface Group {
} }
export interface ModifiersGroup { export interface ModifiersGroup {
name: string, name: string;
id: string, id: string;
restrictions: { restrictions: {
minQuantity: number, minQuantity: number;
maxQuantity: number, maxQuantity: number;
freeQuantity: number, freeQuantity: number;
byDefault: number byDefault: number;
} };
} }
export interface Modifier { export interface Modifier {
id: string, id: string;
idLocal: string, idLocal: string;
name: string, name: string;
groupId: string, groupId: string;
price?: number, price?: number;
quantity?: number, quantity?: number;
image?: string; image?: string;
restrictions: { restrictions: {
minQuantity: number, minQuantity: number;
maxQuantity: number, maxQuantity: number;
freeQuantity: number, freeQuantity: number;
byDefault: number byDefault: number;
} };
} }
export interface CartModifier { export interface CartModifier {
@ -175,11 +177,11 @@ export interface CartModifier {
options: Modifier[]; options: Modifier[];
allQuantity: number; allQuantity: number;
restrictions: { restrictions: {
minQuantity: number, minQuantity: number;
maxQuantity: number, maxQuantity: number;
freeQuantity: number, freeQuantity: number;
byDefault: number byDefault: number;
} };
} }
export interface Cart { export interface Cart {
@ -203,11 +205,11 @@ export interface Option {
name: string; name: string;
groupId: string; groupId: string;
restrictions: { restrictions: {
minQuantity: number, minQuantity: number;
maxQuantity: number, maxQuantity: number;
freeQuantity: number, freeQuantity: number;
byDefault: number byDefault: number;
} };
} }
export interface OrderProduct { export interface OrderProduct {
@ -216,8 +218,8 @@ export interface OrderProduct {
name: string; name: string;
price: number; price: number;
modifiers: { modifiers: {
[name: string]: OrderModifier[] [name: string]: OrderModifier[];
} };
} }
export interface OrderModifier { export interface OrderModifier {

View File

@ -54,8 +54,13 @@ export class Order {
delivery_fio: this.userData?.first_name, delivery_fio: this.userData?.first_name,
subtotal: this.price, subtotal: this.price,
delivery_comment: this.deliveryData?.comment, delivery_comment: this.deliveryData?.comment,
delivery: this.deliveryData?.deliveryType?.type, delivery: this.deliveryData?.deliveryType?.name,
delivery_address: this.deliveryData?.deliveryType?.type === "self_delivery" ? '' : `${environment.cities[0]}, ул ${this.userData?.street}, ${this.userData?.house}`, delivery_address: {
street: this.userData?.street || '',
house: this.userData?.house || '',
flat: '',
city: ''
},
amount: this.price + 100, amount: this.price + 100,
terminal_id: this.terminal_id terminal_id: this.terminal_id
}, },