Skip to content

Commit 360fd9f

Browse files
committed
fixes
1 parent c14f032 commit 360fd9f

File tree

6 files changed

+29
-24
lines changed

6 files changed

+29
-24
lines changed

Diff for: integration-libs/punchout/components/punchout-close-session/punchout-close-session.component.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<ng-container *ngIf="(isPunchoutSessionactive$ | async) === true">
1+
<ng-container *ngIf="(isPunchoutSessionActive$ | async) === true">
22
<div class="cx-punchout-close-session" (click)="clickCloseSessionButton()">
33
{{ 'punchout.closeSession' | cxTranslate }}
44
</div>

Diff for: integration-libs/punchout/components/punchout-close-session/punchout-close-session.component.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export class PunchoutCloseSessionComponent {
2020
protected authService = inject(AuthService);
2121
protected punchoutFacade = inject(PunchoutFacade);
2222

23-
isPunchoutSessionactive$: Observable<boolean> = this.authService
23+
isPunchoutSessionActive$: Observable<boolean> = this.authService
2424
.isUserLoggedIn()
2525
.pipe(
2626
switchMap((isLoggedIn) => {

Diff for: integration-libs/punchout/components/punchout-session/punchout-session.component.ts

+12-8
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import {
1212
} from '@angular/core';
1313
import { ActivatedRoute, Params } from '@angular/router';
1414
import { PUNCHOUT_SESSION_KEY, PunchoutFacade } from '@spartacus/punchout/root';
15-
import { take } from 'rxjs';
15+
import { switchMap, take } from 'rxjs';
1616
@Component({
1717
selector: 'cx-punchout-session',
1818
template: `<p>Punchout session loading</p> `,
@@ -24,12 +24,16 @@ export class PunchoutSessionComponent implements OnInit {
2424
protected punchoutFacade = inject(PunchoutFacade);
2525

2626
ngOnInit(): void {
27-
this.activatedRoute.queryParams.pipe(take(1)).subscribe((param: Params) => {
28-
const punchoutSessionId = param?.[PUNCHOUT_SESSION_KEY];
29-
this.punchoutFacade
30-
.getPunchoutSession({ punchoutSessionId })
31-
.pipe(take(1))
32-
.subscribe();
33-
});
27+
this.activatedRoute.queryParams
28+
.pipe(
29+
take(1),
30+
switchMap((param: Params) =>
31+
this.punchoutFacade.getPunchoutSession({
32+
punchoutSessionId: param?.[PUNCHOUT_SESSION_KEY],
33+
})
34+
),
35+
take(1)
36+
)
37+
.subscribe();
3438
}
3539
}

Diff for: integration-libs/punchout/core/facade/punchout.service.ts

+8-9
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ export class PunchoutService implements PunchoutFacade {
5555
* Logout silently
5656
* Login silently
5757
* Load Cart
58-
* store of initial cart entries for EDIT mode
58+
* Only for EDIT mode: Fetch Requisition to store initial cart in CXML format.
5959
* Route to target page based on punchout session info
6060
* Redirect to Punchout Error page if error occurs
6161
*/
@@ -99,8 +99,7 @@ export class PunchoutService implements PunchoutFacade {
9999
});
100100
if (
101101
punchoutSession.punchOutOperation === PunchOutOperation.EDIT &&
102-
punchoutSession?.cartId &&
103-
!payload?.isPageRefresh
102+
punchoutSession?.cartId
104103
) {
105104
this.setPunchoutInitialRequisition();
106105
}
@@ -169,12 +168,12 @@ export class PunchoutService implements PunchoutFacade {
169168

170169
/**
171170
* closePunchoutSession workflow:
172-
* for EDIT operation:
173-
* - initial Requisition is sent to ARIBA
174-
* for CREATE operation:
175-
* - do same Cancel punchout button
176-
* for INSPECT operation:
177-
* - do same as 'back to requition' button
171+
* For EDIT operation:
172+
* - Initial cart snapshot gets sent in CXML, driven by closePunchoutSession flag.
173+
* For CREATE operation:
174+
* - Empty cart gets sent in CXML, driven by cancelRequisition flag.
175+
* For INSPECT operation:
176+
* - Current cart gets sent in CXML.
178177
*/
179178

180179
protected closePunchoutSessionCommand: Command<undefined, boolean> =

Diff for: integration-libs/punchout/occ/adapters/occ-punchout.adapter.spec.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ const mockSid = 'mockSid';
3131
const discardCartEntries = false;
3232
const mockPunchoutSessionResponse: PunchoutSession = {
3333
customerId: '[email protected]',
34-
cartId: 'mockCaPunchoutLevel',
34+
cartId: 'mockCartId',
3535
punchOutLevel: PunchOutLevel.PRODUCT,
3636
punchOutOperation: PunchOutOperation.EDIT,
3737
selectedItem: 'mockItemId',

Diff for: integration-libs/punchout/root/services/punchout-store.service.spec.ts

+6-4
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const INITIAL_STATE: PunchoutState = {
1717

1818
const mockPunchoutSession: PunchoutSession = {
1919
customerId: '[email protected]',
20-
cartId: 'mockCaPunchoutLevel',
20+
cartId: 'mockCartId',
2121
punchOutLevel: PunchOutLevel.PRODUCT,
2222
punchOutOperation: PunchOutOperation.EDIT,
2323
selectedItem: 'mockItemId',
@@ -56,9 +56,11 @@ describe('PunchoutStoreService', () => {
5656
it('should return the current PunchoutStoreService as an observable', (done) => {
5757
service['punchoutState'].next(mockPunchoutState);
5858

59-
service.getPunchoutState().subscribe((state) => {
60-
expect(state).toEqual(mockPunchoutState);
61-
done();
59+
service.getPunchoutState().subscribe({
60+
next: (state) => {
61+
expect(state).toEqual(mockPunchoutState);
62+
done();
63+
},
6264
});
6365
});
6466

0 commit comments

Comments
 (0)