-
Notifications
You must be signed in to change notification settings - Fork 132
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #721 from Real-Dev-Squad/fix/chaincode-code
[Onboarding Flow]- Write test after the "Generate Chaincode" button is clicked
- Loading branch information
Showing
6 changed files
with
118 additions
and
66 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 |
---|---|---|
@@ -1,14 +1,62 @@ | ||
import Controller from '@ember/controller'; | ||
import { inject as service } from '@ember/service'; | ||
import { APPS } from '../constants/urls'; | ||
import { tracked } from '@glimmer/tracking'; | ||
import { action } from '@ember/object'; | ||
import { toastNotificationTimeoutOptions } from '../constants/toast-notification'; | ||
|
||
export default class JoinController extends Controller { | ||
@service router; | ||
@service login; | ||
@service featureFlag; | ||
@tracked chaincode = 'Generate chaincode'; | ||
@tracked isChaincodeClicked = false; | ||
@tracked isLoading = false; | ||
|
||
queryParams = ['step', 'dev']; | ||
|
||
get isDevMode() { | ||
return this.featureFlag.isDevMode; | ||
} | ||
|
||
@action async handleGenerateChaincode(e) { | ||
e.preventDefault(); | ||
|
||
this.isLoading = true; | ||
|
||
try { | ||
const response = await fetch(`${APPS.API_BACKEND}/users/chaincode`, { | ||
method: 'GET', | ||
headers: { | ||
'Content-Type': 'application/json', | ||
}, | ||
credentials: 'include', | ||
}); | ||
|
||
const { chaincode } = await response.json(); | ||
|
||
if (!response.ok) | ||
return this.toast.error( | ||
'Something went wrong. Please check console errors.', | ||
'', | ||
toastNotificationTimeoutOptions | ||
); | ||
|
||
this.chaincode = chaincode; | ||
this.isChaincodeClicked = true; | ||
this.toast.info( | ||
'Generated New Chaincode!!', | ||
'', | ||
toastNotificationTimeoutOptions | ||
); | ||
} catch (error) { | ||
this.toast.error( | ||
'Something went wrong. Please check console errors.', | ||
'', | ||
toastNotificationTimeoutOptions | ||
); | ||
} finally { | ||
this.isLoading = false; | ||
} | ||
} | ||
} |
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