Skip to content

Commit

Permalink
chore: potential solution
Browse files Browse the repository at this point in the history
  • Loading branch information
theClarkSell committed Nov 7, 2023
1 parent 22407ca commit 610127a
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 5 deletions.
21 changes: 19 additions & 2 deletions src/lib/claimTicket/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ function createConfig(metaContext) {
onDone: [
{
cond: 'wasTicketClaimed',
actions: ['claimTicketSuccess', 'clearCart', 'clearLocalStorage'],
actions: ['claimTicketSuccess'],
target: 'ticketClaimed'
},
{
Expand All @@ -83,7 +83,24 @@ function createConfig(metaContext) {
},

ticketClaimed: {
entry: 'redirectToSuccess'
entry: ['clearCart', 'clearLocalStorage'],
always: [
{
cond: 'isExpoHallTicket',
target: '.expoHall'
},
{
target: '.defaultRedirect'
}
],
states: {
expoHall: {
entry: 'expoHallRedirect'
},
default: {
entry: 'defaultRedirect'
}
}
},

ticketClaimIssue: {},
Expand Down
9 changes: 6 additions & 3 deletions src/lib/claimTicket/machine.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ function createServices() {
return {
guards: {
isPendingClaim: (context) => context.pendingClaim,
wasTicketClaimed: (_, { data }) => data.result
wasTicketClaimed: (_, { data }) => data.result,
isExpoHallTicket: (_, { data }) => data.results.ticketType === 'expo-hall'
},

services: {
Expand Down Expand Up @@ -85,10 +86,12 @@ function createServices() {
}),

claimTicketSuccess: assign({
claimResults: (_, { data }) => data.results
claimResults: (_, { data }) => data.results,
ticketType: (_, { data }) => data.results.ticketType
}),

redirectToSuccess: () => goto('/orders/success/claim-ticket/')
defaultRedirect: () => goto('/orders/success/claim-ticket/'),
expoHallRedirect: () => goto('/orders/success/expo-hall-ticket')
}
};
}
Expand Down

0 comments on commit 610127a

Please sign in to comment.