2525 color =" error"
2626 data-test =" decline-btn"
2727 :text =" isUserValid ? 'Decline Invitation' : 'Back to Home Page'"
28- @click =" close ()"
28+ @click =" declineInvite ()"
2929 />
3030 <v-spacer data-test =" spacer" />
3131 <v-btn
3232 variant =" text"
3333 color =" primary"
3434 data-test =" accept-btn"
35+ text =" Accept Invitation"
3536 :disabled =" !isUserValid"
3637 @click =" acceptInvite()"
37- >
38- Accept Invitation
39- </v-btn >
38+ />
4039 </v-card-actions >
4140</template >
4241
@@ -45,10 +44,10 @@ import { computed, onMounted, ref } from "vue";
4544import axios from " axios" ;
4645import { useRouter , useRoute } from " vue-router" ;
4746import useAuthStore from " @/store/modules/auth" ;
48- import useNamespacesStore from " @/store/modules/namespaces " ;
47+ import useInvitationsStore from " @/store/modules/invitations " ;
4948
5049const authStore = useAuthStore ();
51- const namespacesStore = useNamespacesStore ();
50+ const invitationsStore = useInvitationsStore ();
5251const router = useRouter ();
5352const route = useRoute ();
5453
@@ -85,27 +84,37 @@ const handleInviteError = (error: unknown) => {
8584 }
8685};
8786
87+ const declineInvite = async () => {
88+ try {
89+ const tenant = (route .query [" tenant-id" ] || route .query .tenantid ) as string ;
90+ const sig = route .query .sig as string ;
91+
92+ await invitationsStore .declineInvitation ({ tenant , sig });
93+
94+ await close ();
95+ } catch (error ) {
96+ handleInviteError (error );
97+ }
98+ };
99+
88100const acceptInvite = async () => {
89101 try {
90102 const tenant = (route .query [" tenant-id" ] || route .query .tenantid ) as string ;
91103 const sig = route .query .sig as string ;
92104
93- await namespacesStore . acceptInvite ({ tenant , sig });
105+ await invitationsStore . acceptInvitation ({ tenant , sig });
94106
95107 message .value = " Your invitation has been successfully accepted! You are now a member of the namespace." ;
96108
97109 await authStore .enterInvitedNamespace (tenant );
98- await namespacesStore .fetchNamespaceList ();
99110 await close ();
100111 } catch (error ) {
101112 handleInviteError (error );
102113 }
103114};
104115
105116onMounted (() => {
106- if (isUserValid .value ) {
107- return ;
108- }
117+ if (isUserValid .value ) return ;
109118 errorAlert .value = " You aren't logged in the account meant for this invitation." ;
110119});
111120
0 commit comments