2023-08-20 22:35:58 +00:00
|
|
|
import { http } from '@/services'
|
|
|
|
import { userStore } from '@/stores'
|
|
|
|
|
|
|
|
export const invitationService = {
|
2023-08-23 22:25:18 +00:00
|
|
|
getUserProspect: async (token: string) => await http.get<User>(`invitations?token=${token}`),
|
2023-08-20 22:35:58 +00:00
|
|
|
|
|
|
|
async accept (token: string, name: string, password: string) {
|
|
|
|
await http.post<User>('invitations/accept', { token, name, password })
|
|
|
|
},
|
|
|
|
|
|
|
|
invite: async (emails: string[], isAdmin: boolean) => {
|
|
|
|
const users = await http.post<User[]>('invitations', { emails, is_admin: isAdmin })
|
|
|
|
users.forEach(user => userStore.add(user))
|
|
|
|
},
|
|
|
|
|
2023-08-23 21:46:44 +00:00
|
|
|
revoke: async (user: User) => {
|
|
|
|
await http.delete(`invitations`, { email: user.email })
|
|
|
|
userStore.remove(user)
|
|
|
|
}
|
2023-08-20 22:35:58 +00:00
|
|
|
}
|