Skip to content
New issue

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

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

Already on GitHub? # to your account

Account fixes #859

Merged
merged 17 commits into from
Apr 29, 2023
Merged
Show file tree
Hide file tree
Changes from 13 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
75 changes: 75 additions & 0 deletions client/src/api/account/request.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
import { url } from "@port-of-mars/client/util";
import { ProfileData } from "@port-of-mars/shared/types";
import { TStore } from "@port-of-mars/client/plugins/tstore";
import { AjaxRequest } from "@port-of-mars/client/plugins/ajax";

export class AccountAPI {
constructor(public store: TStore, public ajax: AjaxRequest) {}

async grantConsent(): Promise<void> {
try {
await this.ajax.post(url("/account/grant-consent"), ({ data }) => {
this.store.commit("SET_USER", data);
this.store.commit("SET_DASHBOARD_MESSAGE", {
kind: "info",
message:
"You have granted consent to participate in this research project. Welcome to the Port of Mars!",
});
});
} catch (e) {
console.log("Unable to deny consent");
console.log(e);
throw e;
}
}

async denyConsent(): Promise<void> {
try {
await this.ajax.post(url("/account/deny-consent"), ({ data }) => {
this.store.commit("SET_USER", data);
this.store.commit("SET_DASHBOARD_MESSAGE", {
kind: "info",
message:
"You have denied consent to participate in this research project. Sorry to see you go!",
});
});
} catch (e) {
console.log("Unable to deny consent");
console.log(e);
throw e;
}
}

async updateProfile(profileData: ProfileData) {
try {
await this.ajax.post(
url("/account/update-profile"),
({ data, status }) => {
if (status !== 200) {
throw new Error("Unable to update profile");
}
this.store.commit("SET_USER", data);
if (data.isVerified) {
this.store.commit("SET_DASHBOARD_MESSAGE", {
kind: "success",
message: "Profile updated successfully.",
});
} else {
this.store.commit("SET_DASHBOARD_MESSAGE", {
kind: "success",
message: `Profile updated successfully, however you must verify your email.
We have sent a confirmation email to ${profileData.email}.
Please wait for it to arrive then click on the link inside to verify your email.
It may take some time to arrive, and you may need to check your spam folder as well.
You can close this browser window as the link will take you back to Port of Mars again.`,
});
}
},
profileData
);
} catch (e) {
console.log(e);
throw e;
}
}
}
4 changes: 2 additions & 2 deletions client/src/components/global/AgeTooltip.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@

<script lang="ts">
import { Component, Prop, Vue } from "vue-property-decorator";
import { REGISTER_PAGE } from "@port-of-mars/shared/routes";
import { CONSENT_PAGE } from "@port-of-mars/shared/routes";

@Component({})
export default class Home extends Vue {
@Prop({ default: "top" })
placement!: string;

consent = { name: REGISTER_PAGE };
consent = { name: CONSENT_PAGE };
}
</script>

Expand Down
Loading