Skip to content

Commit

Permalink
feat(com-pwa/new-order): orderId context
Browse files Browse the repository at this point in the history
  • Loading branch information
njfamirm authored and alimd committed Mar 7, 2023
1 parent ad3d145 commit 88afae3
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions uniquely/com-pwa/src/manager/controller/new-order.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export const pageNewOrderStateMachine = new FiniteStateMachine({
id: 'page-order-detail',
initial: 'unresolved',
context: {
orderId: 'new',
order: <OrderDraft>getLocalStorageItem('draft-order-x1', {id: 'new', status: 'draft'}),
productStorage: <AlwatrDocumentStorage<Product> | null>null,
priceStorage: <AlwatrDocumentStorage<ProductPrice> | null>null,
Expand Down Expand Up @@ -179,6 +180,7 @@ pageNewOrderStateMachine.signal.subscribe(async (state) => {

case 'NEW_ORDER': {
pageNewOrderStateMachine.context.order = getLocalStorageItem('draft-order-x1', {id: 'new', status: 'draft'});
pageNewOrderStateMachine.context.orderId = 'new';
break;
}

Expand All @@ -188,7 +190,7 @@ pageNewOrderStateMachine.signal.subscribe(async (state) => {
pageNewOrderStateMachine.transition('SUBMIT_FAILED');
break;
}

pageNewOrderStateMachine.context.orderId = order.id;
pageNewOrderStateMachine.transition('SUBMIT_SUCCESS');
break;
}
Expand Down Expand Up @@ -260,13 +262,13 @@ eventListener.subscribe<ClickSignalType>(buttons.submitShippingForm.clickSignalI
});

eventListener.subscribe<ClickSignalType>(buttons.tracking.clickSignalId, () => {
const orderId = pageNewOrderStateMachine.context.order.id;
const orderId = pageNewOrderStateMachine.context.orderId;
pageNewOrderStateMachine.transition('NEW_ORDER');
redirect('/order-tracking/' + orderId);
});

eventListener.subscribe<ClickSignalType>(buttons.detail.clickSignalId, () => {
const orderId = pageNewOrderStateMachine.context.order.id;
const orderId = pageNewOrderStateMachine.context.orderId;
pageNewOrderStateMachine.transition('NEW_ORDER');
redirect('/order-detail/' + orderId);
});
Expand Down

0 comments on commit 88afae3

Please sign in to comment.