Skip to content

Commit

Permalink
[@dhealthdapps/frontend] fix(screens): add storage for accepted docs
Browse files Browse the repository at this point in the history
  • Loading branch information
kravchenkodhealth authored and evias committed Jan 17, 2023
1 parent f85f974 commit d8846a7
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,14 @@ export default class LegalDisclaimer extends MetaView {
*/
legalAccepted = false;

/**
* This computed returns
* current configuration of the legal page
* configuration is getting according to route name
*
* @access public
* @returns {any}
*/
get legalData() {
const currentKey = this.$route.name?.split(".")[1];
const currentLegalItem = this.$t(`legal.${currentKey}`);
Expand All @@ -54,4 +62,23 @@ export default class LegalDisclaimer extends MetaView {

return this.$t("legal.terms-and-conditions");
}

/**
* This method handles submitting
* of accepted documents.
*
* @access public
* @returns {void}
*/
public handleAccept() {
// temporary storing of accepted Terms and Conditions in localStorage
// @todo discuss the way of storing accepted Terms and Conditions
const currentKey = this.$route.name?.split(".")[1];
localStorage.setItem(
`${currentKey}_accepted`,
JSON.stringify(this.legalAccepted)
);

this.$router.push({ name: "app.login" });
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
</div>
</div>
</div>
<UiButton :disabled="!legalAccepted" :to="{ name: 'app.login' }">{{
<UiButton :disabled="!legalAccepted" @click="handleAccept">{{
legalData.button
}}</UiButton>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,13 @@ export default class OnboardingScreen extends MetaView {
route: this.$route.name,
refCode: this.refCode,
});
this.$router.push({ name: "legal.terms-and-conditions" });
const termsAccepted = !!JSON.parse(
localStorage.getItem("terms-and-conditions_accepted") as string
);

termsAccepted
? this.$router.push({ name: "app.login" })
: this.$router.push({ name: "legal.terms-and-conditions" });
}

/**
Expand Down

0 comments on commit d8846a7

Please sign in to comment.