Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(/welcome): add messages for new intents and results #482

Merged
merged 3 commits into from
Dec 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 39 additions & 3 deletions src/pages/welcome.astro
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,19 @@ const description = t("site.description");
ERROR = 'grant_error',
REJECTED = 'grant_rejected',
INVALID = 'grant_invalid',
KEY_SUCCESS = 'key_add_success',
KEY_ERROR = 'key_add_error',
}

type Intent = 'connect' | 'funds'
type Intent = 'connect' | 'reconnect' | 'funds' | 'update_budget'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to add messages for reconnect and update_budget as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added messages for update_budget intent.
for the reconnect intent we don't need messages as we reuse the grant we have (we do not ask to accept/reject grant), KEY_SUCCESS and KEY_ERROR act as messages for reconnect


const DEFAULT_ERROR_MESSAGE = function (_version: string, intent: Intent) {
if(intent === 'funds') {
return 'Something went wrong. Please try adding funds again.'
}
if(intent === 'update_budget') {
return 'Something went wrong. Please try updating your budget again.'
}
return 'Something went wrong. Please try reconnecting your wallet.'
}
const CLOSE_TAB_MESSAGE = 'You may safely close this tab.'
Expand All @@ -80,13 +85,19 @@ const description = t("site.description");
const ERROR_MESSAGES = {
continuation_failed(_version: string, intent: Intent): string {
if(intent === 'funds') {
return 'An error occured. Please try adding funds again.'
return 'An error occurred. Please try adding funds again.'
}
if(intent === 'update_budget') {
return 'An error occurred. Please try updating your budget again.'
}
return 'An error occurred. Please try reconnecting the wallet.'
},
hash_failed(_version: string, intent: Intent): string {
if(intent === 'funds') {
return 'An error occured. Please try adding funds again.'
return 'An error occurred. Please try adding funds again.'
}
if(intent === 'update_budget') {
return 'An error occurred. Please try updating your budget again.'
}
return 'An error occurred. Please try reconnecting the wallet.'
},
Expand All @@ -97,18 +108,33 @@ const description = t("site.description");
if(intent === 'funds') {
return 'You have successfully added more funds.'
}
if(intent === 'update_budget') {
return 'You have successfully updated your budget.'
}
return 'Your wallet is now successfully connected to the extension.'
},
key_add_success(_version: string): string {
return 'Your wallet is now successfully reconnected to the extension.'
},
grant_rejected(_version: string, intent: Intent): string {
if(intent === 'funds') {
return 'No funds were added.'
}
if(intent === 'update_budget') {
return 'Your budget was not updated.'
}
return 'Your request was successfully rejected.'
},
key_add_error(_version: string): string {
return 'Something went wrong with your request. Please try reconnecting your wallet.'
},
grant_invalid(_version: string, intent: Intent): string {
if(intent === 'funds') {
return 'Something went wrong with your request. Please try adding funds again.'
}
if(intent === 'update_budget') {
return 'Something went wrong with your request. Please try updating your budget again.'
}
return 'Something went wrong with your request. Please try reconnecting your wallet.'
}
}
Expand All @@ -134,11 +160,21 @@ const description = t("site.description");
heroInfo.textContent = CLOSE_TAB_MESSAGE
heroHeading.textContent = MESSAGES[SuccessParam.SUCCESS](version, intent)
break
case SuccessParam.KEY_SUCCESS:
updateImage('success')
heroInfo.textContent = CLOSE_TAB_MESSAGE
heroHeading.textContent = MESSAGES[SuccessParam.KEY_SUCCESS](version)
break
case SuccessParam.REJECTED:
updateImage('warning')
heroInfo.textContent = CLOSE_TAB_MESSAGE
heroHeading.textContent = MESSAGES[SuccessParam.REJECTED](version, intent)
break
case SuccessParam.KEY_ERROR:
updateImage('error')
heroInfo.textContent = CLOSE_TAB_MESSAGE
heroHeading.textContent = MESSAGES[SuccessParam.KEY_ERROR](version)
break
case SuccessParam.INVALID:
updateImage('error')
heroInfo.textContent = CLOSE_TAB_MESSAGE
Expand Down
Loading