Skip to content

Commit e7fe04a

Browse files
committed
fix update control
1 parent 9699e49 commit e7fe04a

File tree

7 files changed

+26
-25
lines changed

7 files changed

+26
-25
lines changed

src/app/guard/auth.service.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export class AuthService {
3333
role: WritableSignal<string | null> = signal(null);
3434

3535
checkAuth(): Observable<boolean> {
36-
return this.oidc.checkAuth().pipe(
36+
/*return this.oidc.checkAuth().pipe(
3737
take(1),
3838
catchError(() => of({ isAuthenticated: false, accessToken: '', userData: {} } as any)),
3939
switchMap(async ({ isAuthenticated, accessToken, userData }) => {
@@ -62,7 +62,16 @@ export class AuthService {
6262
6363
return true;
6464
})
65-
);
65+
);*/
66+
67+
// FAKE AUTH FOR DEV PURPOSES ONLY
68+
const fakeAccessToken = "eyJhbGciOiJFUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJodHRwczovL2NhdGFsb2cuaXNiZW9uYm9hcmQuY29tIiwiZXhwIjoxNzYyNTI0NTMxLCJpYXQiOjE3NjI1MjA5MzEsImlzcyI6Imh0dHBzOi8vY2VydGF1dGguZXZpZGVuY2VsZWRnZXIuZXUiLCJqdGkiOiJIVlFYV1dOV1ZHS1M3NE1YWEpDRjZKVUtKNSIsIm5vbmNlIjoiMzllYzViYzdhN2VhM2YzMDg2YTUzNDMyNWU1ODRjNTE1MGhPUmg3UWciLCJzY29wZSI6Im9wZW5pZCBlaWRhcyIsInN1YiI6Imh0dHBzOi8vY2F0YWxvZy5pc2Jlb25ib2FyZC5jb20iLCJ2YyI6eyJAY29udGV4dCI6WyJodHRwczovL3d3dy53My5vcmcvbnMvY3JlZGVudGlhbHMvIiwiaHR0cHM6Ly9jcmVkZW50aWFscy5ldWRpc3RhY2suZXUvLndlbGwta25vd24vY3JlZGVudGlhbHMvbGVhcl9jcmVkZW50aWFsX2VtcGxveWVlL3czYy92MyJdLCJjcmVkZW50aWFsU3RhdHVzIjp7ImlkIjoiaH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6IkRPTUUiLCJmdW5jdGlvbiI6IlByb2R1Y3RPZmZlcmluZyIsInR5cGUiOiJkb21haW4ifV19fSwiZGVzY3JpcHRpb24iOiJWZXJpZmlhYmxlIENyZWRlbnRpYWwgZm9yIGVtcGxveWVlcyBvZiBhbiBvcmdhbml6YXRpb24iLCJpZCI6InVybjp1dWlkM09NTFdFUVFKTjI2WlJQUkJGWTJBQVg2RFIiLCJpc3N1ZXIiOnsiY29tbW9uTmFtZSI6IkNlcnRBdXRoIElkZW50aXR5IFByb3ZpZGVyIGZvciBJU0JFIiwiY291bnRyeSI6IkVTIiwiaWQiOiJkaWQ6ZWxzaTpWQVRFUy1CNjA2NDU5MDAiLCJvcmdhbml6YXRpb24iOiJJTjIiLCJvcmdhbml6YXRpb25JZGVudGlmaWVyIjoiVkFURVMtQjYwNjQ1OTAwIiwic2VyaWFsTnVtYmVyIjoiQjQ3NDQ3NTYwIn0sInR5cGUiOlsiTEVBUkNyZWRlbnRpYWxFbXBsb3llZSIsIlZlcmlmaWFibGVDcmVkZW50aWFsIl0sInZhbGlkRnJvbSI6IjIwMjUtMTEtMDRUMTg6MzY6NTBaIiwidmFsaWRVbnRpbCI6IjIwMjYtMTItMDZUMTg6MzY6NTBaIn19.K7OaHIWw1Z1TCUxWjm0n7WZJAlxQVO2e9ZvEtf8FTiNJ0K4rx1gdg_Do6SXqRnHTlx9aRdZQ1muD7wGNbcaseg";
69+
let claims: any = this.decodeJwtPayload(fakeAccessToken);
70+
const u = this.mapUserFromClaims(claims);
71+
this.setState(true, u, fakeAccessToken ?? '', this.pickPrimaryRole(u));
72+
const li = claimsToLoginInfo(claims, fakeAccessToken ?? '');
73+
this.loginInfoSubject.next(li);
74+
return of(true);
6675
}
6776

6877
sellerId$ = combineLatest([this.loginInfo$, this.orgCtx.getOrganization()]).pipe(
@@ -139,4 +148,4 @@ export class AuthService {
139148
return null;
140149
}
141150
}
142-
}
151+
}

src/app/offerings/gallery/gallery.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@
8383

8484
</section>
8585

86-
@if (products.length === 0){
86+
@if (products.length === 0 && !loading) {
8787
<div class="py-8 flex justify-center w-full lg:py-16">
8888
<div class="flex items-center p-4 mb-4 text-sm text-primary-100 rounded-lg bg-purple-50 dark:bg-secondary-200 dark:text-primary-50" role="alert">
8989
<svg class="flex-shrink-0 inline w-4 h-4 me-3" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 20 20">

src/app/pages/admin/categories/update-category/update-category.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ <h2 class="text-3xl font-bold text-primary-100 ml-4 dark:text-white">{{ 'UPDATE_
181181

182182

183183
<div class="flex w-full justify-items-end justify-end ml-4">
184-
<button type="button" (click)="updateCategory();" [disabled]="isCatValid()" [ngClass]="isCatValid() ? 'opacity-50' : 'hover:bg-primary-50'" class="flex text-white justify-end bg-primary-100 hover:bg-primary-50 focus:ring-4 focus:outline-none focus:ring-purple-300 font-medium rounded-lg text-sm px-5 py-2.5 text-center inline-flex items-center">
184+
<button type="button" (click)="updateCategory();" [disabled]="!isCatValid()" [ngClass]="!isCatValid() ? 'opacity-50' : 'hover:bg-primary-50'" class="flex text-white justify-end bg-primary-100 hover:bg-primary-50 focus:ring-4 focus:outline-none focus:ring-purple-300 font-medium rounded-lg text-sm px-5 py-2.5 text-center inline-flex items-center">
185185
{{ 'UPDATE_CATEGORIES._update' | translate }}
186186
<svg class="rtl:rotate-180 w-3.5 h-3.5 ms-2" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 14 10">
187187
<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M1 5h12m0 0L9 1m4 4L9 9"/>

src/app/pages/admin/categories/update-category/update-category.component.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -459,9 +459,9 @@ export class UpdateCategoryComponent implements OnInit {
459459
}
460460

461461
isCatValid(){
462-
if((this.edited && this.catStatusDraft !== 'Active')|| !this.generalForm.valid){
463-
return true;
462+
if((this.edited && this.catStatusDraft === 'Launched')|| !this.generalForm.valid){
463+
return false;
464464
}
465-
return false;
465+
return true;
466466
}
467467
}

src/app/pages/seller-offerings/offerings/seller-product-spec/update-product-spec/update-product-spec.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1296,7 +1296,7 @@ <h2 class="text-3xl font-bold text-primary-100 ml-4 dark:text-white">{{ 'UPDATE_
12961296
</div>
12971297
}
12981298
<div class="flex w-full justify-items-end justify-end ml-4">
1299-
<button type="button" (click)="updateProduct();" [disabled]="isProdValid()" [ngClass]="isProdValid() ? 'opacity-50' : 'hover:bg-primary-50'" class="flex text-white justify-end bg-primary-100 hover:bg-primary-50 focus:ring-4 focus:outline-none focus:ring-purple-300 font-medium rounded-lg text-sm px-5 py-2.5 text-center inline-flex items-center">
1299+
<button type="button" (click)="updateProduct();" [disabled]="!isProdValid()" [ngClass]="!isProdValid() ? 'opacity-50' : 'hover:bg-primary-50'" class="flex text-white justify-end bg-primary-100 hover:bg-primary-50 focus:ring-4 focus:outline-none focus:ring-purple-300 font-medium rounded-lg text-sm px-5 py-2.5 text-center inline-flex items-center">
13001300
{{ 'UPDATE_PROD_SPEC._update_prod' | translate }}
13011301
<svg class="rtl:rotate-180 w-3.5 h-3.5 ms-2" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 14 10">
13021302
<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M1 5h12m0 0L9 1m4 4L9 9"/>

src/app/pages/seller-offerings/offerings/seller-product-spec/update-product-spec/update-product-spec.component.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1144,21 +1144,21 @@ export class UpdateProductSpecComponent implements OnInit {
11441144
}
11451145

11461146
isProdValid(){
1147-
if(this.edited && this.prodStatusDraft !== 'Active'){
1148-
return true;
1147+
if (this.edited && this.prodStatusDraft === 'Launched') {
1148+
return false;
11491149
}
11501150
if(this.generalForm.valid){
11511151
if(this.bundleChecked){
11521152
if(this.prodSpecsBundle.length<2){
1153-
return true;
1154-
} else {
11551153
return false;
1154+
} else {
1155+
return true;
11561156
}
11571157
} else {
1158-
return false;
1158+
return true;
11591159
}
11601160
} else {
1161-
return true;
1161+
return false;
11621162
}
11631163
}
11641164

src/app/shared/forms/offer/offer.component.ts

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1175,17 +1175,9 @@ export class OfferComponent implements OnInit, OnDestroy{
11751175
if (this.formType === 'create') {
11761176
return true;
11771177
}
1178-
1179-
const currentStatus = this.productOfferForm.get('generalInfo')?.value?.status;
1180-
const originalStatus = this.offer?.lifecycleStatus;
1181-
const edited = hasNonStatusChanges(
1182-
this.buildSnapshot('offer'),
1183-
this.buildSnapshot('form')
1184-
);
1185-
if (originalStatus === 'Launched' && edited && currentStatus !== 'Active') {
1186-
return false;
1178+
if (this.edited && this.productOfferForm.get('generalInfo')?.value?.status === 'Launched') {
1179+
return false;
11871180
}
1188-
11891181
return true;
11901182
}
11911183

0 commit comments

Comments
 (0)