mirror of
https://github.com/Nezumi-2711/foodify-frontend.git
synced 2026-09-22 13:38:44 +00:00
Deployment 1.5.2023
Fix update product imgs
This commit is contained in:
@@ -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<any>;
|
||||
|
||||
//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
|
||||
|
||||
@@ -372,4 +372,12 @@
|
||||
tục
|
||||
</button>
|
||||
</div>
|
||||
</ng-template>
|
||||
|
||||
<ng-template #need_img>
|
||||
<div class="modal-body text-center">
|
||||
<h5 class="text-dark font-weight-bold mb-4">Vui lòng thêm ảnh của sản phẩm</h5>
|
||||
<button type=" button" class="btn btn-primary" (click)="closeLayer1()">Tiếp tục
|
||||
</button>
|
||||
</div>
|
||||
</ng-template>
|
||||
@@ -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<string>;
|
||||
|
||||
@ViewChild('need_img') needImageModal: TemplateRef<any>
|
||||
|
||||
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<string> {
|
||||
@@ -193,6 +197,7 @@ export class EditProductComponent {
|
||||
}
|
||||
|
||||
openImgModal(id: number, imageTemplate: TemplateRef<any>) {
|
||||
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<any>) {
|
||||
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<any>) {
|
||||
|
||||
@@ -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'
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user