diff --git a/src/app/components/auth/signup/signup.component.ts b/src/app/components/auth/signup/signup.component.ts index 41da3d4..c6d58da 100644 --- a/src/app/components/auth/signup/signup.component.ts +++ b/src/app/components/auth/signup/signup.component.ts @@ -20,6 +20,7 @@ import { Shop } from "src/app/shared/tables/shop"; import { User } from "src/app/shared/tables/user"; import { Ward } from "src/app/shared/tables/ward"; import { environment } from "src/environments/environment"; +import { response } from "express"; @Component({ selector: "app-signup", @@ -71,7 +72,6 @@ export class SignupComponent { @ViewChild('miss_otp') missOTPModal: TemplateRef; //Phonenumber - isVerified: boolean = false; reCaptchaVerifier; verify; @@ -209,7 +209,6 @@ export class SignupComponent { const credential = firebase.auth.PhoneAuthProvider.credential(this.verify, this.otpCode.value); firebase.auth().signInWithCredential(credential).then((credential) => { credential.user.delete(); - this.isVerified = true; if (this.userImageChoosen && this.shopImageChoosen) { this.uploadUserImage(this.userImageFile).then((url) => { @@ -351,8 +350,6 @@ export class SignupComponent { .then((confirmationResult) => { this.verify = confirmationResult.verificationId; - - console.log("send code!"); }) .catch((error) => { //Catch error diff --git a/src/app/components/products/physical/edit-product/edit-product.component.html b/src/app/components/products/physical/edit-product/edit-product.component.html index 385e50f..a1cb437 100644 --- a/src/app/components/products/physical/edit-product/edit-product.component.html +++ b/src/app/components/products/physical/edit-product/edit-product.component.html @@ -372,4 +372,12 @@ tục + + + + \ No newline at end of file diff --git a/src/app/components/products/physical/edit-product/edit-product.component.ts b/src/app/components/products/physical/edit-product/edit-product.component.ts index 390b216..d67da1c 100644 --- a/src/app/components/products/physical/edit-product/edit-product.component.ts +++ b/src/app/components/products/physical/edit-product/edit-product.component.ts @@ -1,4 +1,4 @@ -import { Component, TemplateRef } from '@angular/core'; +import { Component, TemplateRef, ViewChild } from '@angular/core'; import { FormArray, FormControl, FormGroup, UntypedFormBuilder, UntypedFormGroup, Validators } from '@angular/forms'; import { ChangeEvent } from '@ckeditor/ckeditor5-angular'; import { BsModalRef, BsModalService } from 'ngx-bootstrap/modal'; @@ -26,6 +26,7 @@ export class EditProductComponent { active = 1; oldRandomImg: string; editOrDeleteId: number; + isEdited: boolean = false; editProductId: number; product: Product; @@ -35,6 +36,8 @@ export class EditProductComponent { imageUploadFile: File; downloadURL: Observable; + @ViewChild('need_img') needImageModal: TemplateRef + constructor( private fb: UntypedFormBuilder, private productService: ProductService, @@ -136,6 +139,7 @@ export class EditProductComponent { //Image onFileSelected(event) { this.imageUploadFile = (event.target as HTMLInputElement).files[0]; + this.isEdited = true; } uploadProductImage(fileUpload: File): Promise { @@ -193,6 +197,7 @@ export class EditProductComponent { } openImgModal(id: number, imageTemplate: TemplateRef) { + this.isEdited = false; if (this.editProductForm.invalid) { this.editProductForm.markAllAsTouched() return; @@ -205,26 +210,36 @@ export class EditProductComponent { this.imageContent = "Thêm ảnh"; const newImage = new ProductImage(); newImage.productId = this.product.id; - this.uploadProductImage(this.imageUploadFile).then((url) => { - newImage.imageUrl = url; - this.productImageService.addProductImage(newImage, this.product.id).subscribe(() => { - this.layer1.hide(); - this.layer1 = this.modalService.show(successTemplate, { class: 'modal-sm' }); + if (this.isEdited) { + this.uploadProductImage(this.imageUploadFile).then((url) => { + newImage.imageUrl = url; + this.productImageService.addProductImage(newImage, this.product.id).subscribe(() => { + this.layer1.hide(); + this.layer1 = this.modalService.show(successTemplate, { class: 'modal-sm' }); + }) }) - }) + } + else { + this.layer1 = this.modalService.show(this.needImageModal, { class: 'modal-sm' }) + } } updateImage(successTemplate: TemplateRef) { this.imageContent = "Chỉnh sửa ảnh"; const editImage = new ProductImage(); editImage.productId = this.product.id; - this.uploadProductImage(this.imageUploadFile).then((url) => { - editImage.imageUrl = url; - this.productImageService.updateProductImage(this.product.id, this.editOrDeleteId, editImage).subscribe(() => { - this.layer1.hide(); - this.layer1 = this.modalService.show(successTemplate, { class: 'modal-sm' }); + if (this.isEdited) { + this.uploadProductImage(this.imageUploadFile).then((url) => { + editImage.imageUrl = url; + this.productImageService.updateProductImage(this.product.id, this.editOrDeleteId, editImage).subscribe(() => { + this.layer1.hide(); + this.layer1 = this.modalService.show(successTemplate, { class: 'modal-sm' }); + }) }) - }) + } + else { + this.layer1 = this.modalService.show(this.needImageModal, { class: 'modal-sm' }) + } } deleteImage(successTemplate: TemplateRef) { diff --git a/src/environments/environment.ts b/src/environments/environment.ts index f0a7c9e..d1eb802 100644 --- a/src/environments/environment.ts +++ b/src/environments/environment.ts @@ -17,7 +17,7 @@ export const environment = { measurementId: 'G-TV0D4CW51W' }, adminImg: 'https://firebasestorage.googleapis.com/v0/b/foodify-55954.appspot.com/o/Admin%2Ffooder.png?alt=media&token=2e24c25a-bbfb-4ceb-9e9b-bb47e348b6cf', - userDefaultImg: 'https://firebasestorage.googleapis.com/v0/b/foodify-55954.appspot.com/o/Admin%2Fdefault-ava-01.png?alt=media&token=90202711-4b1a-4665-a941-a65bf6c2002e', + userDefaultImg: 'https://firebasestorage.googleapis.com/v0/b/foodify-55954.appspot.com/o/Admin%2Fdefault%2Fdefault-ava-01.png?alt=media&token=7175d053-86b9-4bee-8efa-221c2e2b8da9', shopDefaultImg: 'https://firebasestorage.googleapis.com/v0/b/foodify-55954.appspot.com/o/Admin%2Fdefault-shop-01.png?alt=media&token=2eb5629a-730b-4611-a564-05deb29c9217' };