feat(frontend): add guild join flow, members panel, and channel-create member modal
This commit is contained in:
@@ -20,6 +20,11 @@ type RefreshResponse = {
|
||||
expiresIn?: number
|
||||
}
|
||||
|
||||
type MeGuildsResponse = {
|
||||
guilds: Array<{ nodeId: string; name: string; endpoint: string; status: 'active' | 'offline' | 'revoked' }>
|
||||
guildAccessTokens: Array<{ guildNodeId: string; token: string; tokenType: string; expiresIn?: number }>
|
||||
}
|
||||
|
||||
function centerClient(centerApiBase: string) {
|
||||
const client = axios.create({
|
||||
baseURL: centerApiBase,
|
||||
@@ -49,3 +54,30 @@ export async function refreshCenter(centerApiBase: string, refreshToken: string)
|
||||
export async function logoutCenter(centerApiBase: string, refreshToken: string): Promise<void> {
|
||||
await centerClient(centerApiBase).post('/auth/logout', { refreshToken })
|
||||
}
|
||||
|
||||
export async function meGuildsCenter(centerApiBase: string, accessToken: string): Promise<MeGuildsResponse> {
|
||||
const res = await centerClient(centerApiBase).get<MeGuildsResponse>('/auth/me/guilds', {
|
||||
headers: { Authorization: `Bearer ${accessToken}` },
|
||||
})
|
||||
return res.data
|
||||
}
|
||||
|
||||
export async function joinGuildCenter(centerApiBase: string, accessToken: string, guildNodeId: string): Promise<void> {
|
||||
await centerClient(centerApiBase).post(
|
||||
'/auth/me/guilds/join',
|
||||
{ guildNodeId },
|
||||
{ headers: { Authorization: `Bearer ${accessToken}` } },
|
||||
)
|
||||
}
|
||||
|
||||
export async function guildMembersCenter(
|
||||
centerApiBase: string,
|
||||
accessToken: string,
|
||||
guildNodeId: string,
|
||||
): Promise<Array<{ userId: string; email: string; status: string }>> {
|
||||
const res = await centerClient(centerApiBase).get<Array<{ userId: string; email: string; status: string }>>(
|
||||
`/auth/guilds/${encodeURIComponent(guildNodeId)}/members`,
|
||||
{ headers: { Authorization: `Bearer ${accessToken}` } },
|
||||
)
|
||||
return Array.isArray(res.data) ? res.data : []
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user