refactor: Extract Invitation routes to InvitationController (no-changelog) (#7726)
This PR: - Creates `InvitationController` - Moves `POST /users` to `POST /invitations` and move related test to `invitations.api.tests` - Moves `POST /users/:id` to `POST /invitations/:id/accept` and move related test to `invitations.api.tests` - Adjusts FE to use new endpoints - Moves all the invitation logic to the `UserService` --------- Co-authored-by: कारतोफ्फेलस्क्रिप्ट™ <aditya@netroy.in>
This commit is contained in:
@@ -83,14 +83,8 @@ export default defineComponent({
|
||||
};
|
||||
},
|
||||
async mounted() {
|
||||
const inviterId =
|
||||
!this.$route.query.inviterId || typeof this.$route.query.inviterId !== 'string'
|
||||
? null
|
||||
: this.$route.query.inviterId;
|
||||
const inviteeId =
|
||||
!this.$route.query.inviteeId || typeof this.$route.query.inviteeId !== 'string'
|
||||
? null
|
||||
: this.$route.query.inviteeId;
|
||||
const inviterId = this.getQueryParameter('inviterId');
|
||||
const inviteeId = this.getQueryParameter('inviteeId');
|
||||
try {
|
||||
if (!inviterId || !inviteeId) {
|
||||
throw new Error(this.$locale.baseText('auth.signup.missingTokenError'));
|
||||
@@ -129,7 +123,7 @@ export default defineComponent({
|
||||
|
||||
try {
|
||||
this.loading = true;
|
||||
await this.usersStore.signup({
|
||||
await this.usersStore.acceptInvitation({
|
||||
...values,
|
||||
inviterId: this.inviterId,
|
||||
inviteeId: this.inviteeId,
|
||||
@@ -153,6 +147,11 @@ export default defineComponent({
|
||||
}
|
||||
this.loading = false;
|
||||
},
|
||||
getQueryParameter(key: 'inviterId' | 'inviteeId'): string | null {
|
||||
return !this.$route.query[key] || typeof this.$route.query[key] !== 'string'
|
||||
? null
|
||||
: (this.$route.query[key] as string);
|
||||
},
|
||||
},
|
||||
});
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user