fixed some bug change get by id to get by product code
This commit is contained in:
parent
7450796a6b
commit
d5cfdf496f
5 changed files with 30 additions and 29 deletions
|
|
@ -14,8 +14,8 @@ import { environment } from 'src/environments/environment';
|
|||
|
||||
@Injectable({ providedIn: 'root' })
|
||||
export class UserService {
|
||||
private currnetUserSubject = new BehaviorSubject<User | null>(null);
|
||||
public currentUser = this.currnetUserSubject
|
||||
private currentUserSubject = new BehaviorSubject<User | null>(null);
|
||||
public currentUser = this.currentUserSubject
|
||||
.asObservable()
|
||||
.pipe(distinctUntilChanged());
|
||||
|
||||
|
|
@ -54,10 +54,10 @@ export class UserService {
|
|||
}
|
||||
|
||||
setAuth(user: User): void {
|
||||
void this.currnetUserSubject.next(user);
|
||||
void this.currentUserSubject.next(user);
|
||||
}
|
||||
|
||||
purgeAuth(): void {
|
||||
void this.currnetUserSubject.next(null);
|
||||
void this.currentUserSubject.next(null);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -142,7 +142,7 @@
|
|||
{{ recipe.LastChange | date : "dd-MMM-yyyy hh:mm:ss" }}
|
||||
</td>
|
||||
<td class="px-4 py-4 flex">
|
||||
<recipe-modal id="{{ recipe.id }}"></recipe-modal>
|
||||
<recipe-modal productCode="{{ recipe.productCode }}"></recipe-modal>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
|
|
|
|||
|
|
@ -101,8 +101,8 @@
|
|||
</div>
|
||||
</div>
|
||||
<div class="modal-action">
|
||||
<a class="btn px-10" (click)="onConfirmSave()">Save</a>
|
||||
<a class="btn" (click)="onConfirmClose()">Close</a>
|
||||
<a class="btn px-10" (click)="onPressConfirmSave()">Save</a>
|
||||
<a class="btn" (click)="onPressConfirmClose()">Close</a>
|
||||
</div>
|
||||
<confirm-modal
|
||||
[title]="confirmSave.title"
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ interface RecipeMetaData {
|
|||
standalone: true,
|
||||
})
|
||||
export class RecipeModalComponent {
|
||||
@Input({ required: true }) id!: string;
|
||||
@Input({ required: true }) productCode!: string;
|
||||
|
||||
title: string = 'Recipe Detail';
|
||||
|
||||
|
|
@ -73,23 +73,20 @@ export class RecipeModalComponent {
|
|||
|
||||
if (this.detailModal?.nativeElement.open) {
|
||||
this.recipeService
|
||||
.getRecipesById(this.id)
|
||||
.getRecipesById(this.productCode)
|
||||
.subscribe(({ recipe, recipeMetaData }) => {
|
||||
this.title = recipe.name + ' | ' + recipe.productCode;
|
||||
this.recipeDetail.patchValue(
|
||||
{
|
||||
productCode: recipe.productCode,
|
||||
name: recipe.name,
|
||||
otherName: recipe.otherName,
|
||||
description: recipe.Description,
|
||||
otherDescription: recipe.otherDescription,
|
||||
price: recipe.cashPrice,
|
||||
isUse: recipe.isUse,
|
||||
isShow: recipe.isShow,
|
||||
disable: recipe.disable,
|
||||
},
|
||||
{ emitEvent: false }
|
||||
);
|
||||
this.recipeDetail.patchValue({
|
||||
productCode: recipe.productCode,
|
||||
name: recipe.name,
|
||||
otherName: recipe.otherName,
|
||||
description: recipe.Description,
|
||||
otherDescription: recipe.otherDescription,
|
||||
price: recipe.cashPrice,
|
||||
isUse: recipe.isUse,
|
||||
isShow: recipe.isShow,
|
||||
disable: recipe.disable,
|
||||
});
|
||||
this.originalRecipeDetail = {
|
||||
productCode: recipe.productCode,
|
||||
name: recipe.name,
|
||||
|
|
@ -102,6 +99,7 @@ export class RecipeModalComponent {
|
|||
disable: recipe.disable,
|
||||
};
|
||||
this.recipeMetaData = recipeMetaData;
|
||||
console.log(this.recipeDetail.value);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -127,7 +125,7 @@ export class RecipeModalComponent {
|
|||
},
|
||||
};
|
||||
|
||||
onConfirmSave() {
|
||||
onPressConfirmSave() {
|
||||
if (!isEqual(this.recipeDetail.value, this.originalRecipeDetail)) {
|
||||
this.showConfirmSaveModal.emit(true);
|
||||
} else {
|
||||
|
|
@ -135,7 +133,7 @@ export class RecipeModalComponent {
|
|||
}
|
||||
}
|
||||
|
||||
onConfirmClose() {
|
||||
onPressConfirmClose() {
|
||||
if (!isEqual(this.recipeDetail.value, this.originalRecipeDetail)) {
|
||||
this.showConfirmCloseModal.emit(true);
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -80,12 +80,12 @@ func (rr *RecipeRouter) Route(r chi.Router) {
|
|||
recipe := rr.data.GetRecipe01()
|
||||
recipeMetaData := rr.sheetService.GetSheet(r.Context(), "1rSUKcc5POR1KeZFGoeAZIoVoI7LPGztBhPw5Z_ConDE")
|
||||
|
||||
recipeResult := models.Recipe01{}
|
||||
var recipeResult *models.Recipe01
|
||||
recipeMetaDataResult := map[string]string{}
|
||||
|
||||
for _, v := range recipe {
|
||||
if v.ProductCode == productCode {
|
||||
recipeResult = v
|
||||
recipeResult = &v
|
||||
break
|
||||
}
|
||||
}
|
||||
|
|
@ -104,12 +104,15 @@ func (rr *RecipeRouter) Route(r chi.Router) {
|
|||
}
|
||||
}
|
||||
|
||||
if recipeResult == nil {
|
||||
http.Error(w, "Not Found", http.StatusNotFound)
|
||||
return
|
||||
}
|
||||
|
||||
json.NewEncoder(w).Encode(map[string]interface{}{
|
||||
"recipe": recipeResult,
|
||||
"recipeMetaData": recipeMetaDataResult,
|
||||
})
|
||||
|
||||
http.Error(w, "Recipe not found", http.StatusNotFound)
|
||||
})
|
||||
|
||||
r.Get("/{version}/json", func(w http.ResponseWriter, r *http.Request) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue