fix(frontend): Loading and removal of members of organization
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import type { LegalRole } from '~/server/utils/permissions'
|
||||
import type { ListMembersOptions } from '~/composables/useAuth'
|
||||
|
||||
export function useOrganizationApi() {
|
||||
const { organization } = useAuth()
|
||||
@@ -23,6 +24,10 @@ export function useOrganizationApi() {
|
||||
return organization.inviteMember({ email, role })
|
||||
}
|
||||
|
||||
async function removeMember(memberIdOrEmail: string) {
|
||||
return organization.removeMember({ memberIdOrEmail })
|
||||
}
|
||||
|
||||
async function acceptInvitation(invitationId: string) {
|
||||
return organization.acceptInvitation({ invitationId })
|
||||
}
|
||||
@@ -47,17 +52,23 @@ export function useOrganizationApi() {
|
||||
return organization.setActive({ organizationId })
|
||||
}
|
||||
|
||||
async function listMembers(options?: ListMembersOptions) {
|
||||
return organization.listMembers(options)
|
||||
}
|
||||
|
||||
return {
|
||||
createOrganization,
|
||||
deleteOrganization,
|
||||
getInvitation,
|
||||
listInvitations,
|
||||
inviteMember,
|
||||
removeMember,
|
||||
acceptInvitation,
|
||||
cancelSentInvitation,
|
||||
rejectInvitation,
|
||||
loadOrganizations,
|
||||
checkSlugAvailability,
|
||||
setActiveOrganization
|
||||
setActiveOrganization,
|
||||
listMembers
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@ import { createAuthClient } from 'better-auth/vue'
|
||||
import type { InferSessionFromClient, InferUserFromClient, ClientOptions } from 'better-auth/client'
|
||||
import { organizationClient, jwtClient } from 'better-auth/client/plugins'
|
||||
import type { RouteLocationRaw } from 'vue-router'
|
||||
import type { RouteLocationNormalizedLoaded } from '#vue-router'
|
||||
import {
|
||||
accessControl,
|
||||
employerRole,
|
||||
@@ -29,6 +28,10 @@ export type User = Session['user']
|
||||
export type ActiveOrganization = Client['$Infer']['ActiveOrganization']
|
||||
export type Organization = Client['$Infer']['Organization']
|
||||
export type Invitation = Client['$Infer']['Invitation']
|
||||
export type Member = Client['$Infer']['Member']
|
||||
export type ListMembersOptions = Parameters<Client['organization']['listMembers']>[0]
|
||||
export type ListMembersResponse = Awaited<ReturnType<Client['organization']['listMembers']>>
|
||||
export type ListMembersQuery = NonNullable<ListMembersOptions>['query']
|
||||
|
||||
// Extended invitation type with additional organization and inviter details
|
||||
export type CustomInvitation =
|
||||
@@ -45,14 +48,21 @@ const user = ref<InferUserFromClient<ClientOptions> | null>(null)
|
||||
const sessionFetching = import.meta.server ? ref(false) : ref(false)
|
||||
const jwt = ref<string | null>(null)
|
||||
const organizations = ref<
|
||||
{ id: string; name: string; createdAt: Date; slug: string; metadata?: any; logo?: string | null }[]
|
||||
{
|
||||
id: string
|
||||
name: string
|
||||
createdAt: Date
|
||||
slug: string
|
||||
metadata?: Record<string, unknown>
|
||||
logo?: string | null
|
||||
}[]
|
||||
>([])
|
||||
const selectedOrganization = ref<{
|
||||
id: string
|
||||
name: string
|
||||
createdAt: Date
|
||||
slug: string
|
||||
metadata?: any
|
||||
metadata?: Record<string, unknown>
|
||||
logo?: string | null
|
||||
} | null>(null)
|
||||
const activeMember = ref<{ role: string } | null>(null)
|
||||
|
||||
Reference in New Issue
Block a user