-
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixing minor state machine bug in SignInForm (#21)
* Ability to search for existing HME addresses * Linting * Last item borderless * Fix borders, error refresh * Fixing minor state machine bug in SignInForm
- Loading branch information
Showing
4 changed files
with
119 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
export enum PopupState { | ||
SignedIn, | ||
Verified, | ||
SignedOut, | ||
VerifiedAndManaging, | ||
} | ||
|
||
export type SignedOutAction = 'SUCCESSFUL_SIGN_IN' | 'SUCCESSFUL_VERIFICATION'; | ||
export type SignedInAction = 'SUCCESSFUL_VERIFICATION' | 'SUCCESSFUL_SIGN_OUT'; | ||
export type VerifiedAction = 'MANAGE' | 'SUCCESSFUL_SIGN_OUT'; | ||
export type VerifiedAndManagingAction = 'GENERATE' | 'SUCCESSFUL_SIGN_OUT'; | ||
export type PopupAction = | ||
| SignedOutAction | ||
| SignedInAction | ||
| VerifiedAction | ||
| VerifiedAndManagingAction; | ||
|
||
type GenericTranstitions<Actions extends PopupAction> = { | ||
[key in Actions]: PopupState; | ||
}; | ||
|
||
type SignedOutTransitions = GenericTranstitions<SignedOutAction>; | ||
type SignedInTransitions = GenericTranstitions<SignedInAction>; | ||
type VerifiedTransitions = GenericTranstitions<VerifiedAction>; | ||
type VerifiedAndManagingTransition = | ||
GenericTranstitions<VerifiedAndManagingAction>; | ||
|
||
type Transitions = { | ||
[PopupState.SignedOut]: SignedOutTransitions; | ||
[PopupState.SignedIn]: SignedInTransitions; | ||
[PopupState.Verified]: VerifiedTransitions; | ||
[PopupState.VerifiedAndManaging]: VerifiedAndManagingTransition; | ||
} & { [key in PopupState]: unknown }; | ||
|
||
export const STATE_MACHINE_TRANSITIONS: Transitions = { | ||
[PopupState.SignedOut]: { | ||
SUCCESSFUL_SIGN_IN: PopupState.SignedIn, | ||
SUCCESSFUL_VERIFICATION: PopupState.Verified, | ||
}, | ||
[PopupState.SignedIn]: { | ||
SUCCESSFUL_VERIFICATION: PopupState.Verified, | ||
SUCCESSFUL_SIGN_OUT: PopupState.SignedOut, | ||
}, | ||
[PopupState.Verified]: { | ||
MANAGE: PopupState.VerifiedAndManaging, | ||
SUCCESSFUL_SIGN_OUT: PopupState.SignedOut, | ||
}, | ||
[PopupState.VerifiedAndManaging]: { | ||
GENERATE: PopupState.Verified, | ||
SUCCESSFUL_SIGN_OUT: PopupState.SignedOut, | ||
}, | ||
}; |