mirror of
https://github.com/whekin/household-bot.git
synced 2026-03-31 15:54:03 +00:00
feat(miniapp): add member rent weight controls
This commit is contained in:
@@ -37,6 +37,7 @@ export interface MiniAppPendingMember {
|
||||
export interface MiniAppMember {
|
||||
id: string
|
||||
displayName: string
|
||||
rentShareWeight: number
|
||||
isAdmin: boolean
|
||||
}
|
||||
|
||||
@@ -452,6 +453,37 @@ export async function promoteMiniAppMember(
|
||||
return payload.member
|
||||
}
|
||||
|
||||
export async function updateMiniAppMemberRentWeight(
|
||||
initData: string,
|
||||
memberId: string,
|
||||
rentShareWeight: number
|
||||
): Promise<MiniAppMember> {
|
||||
const response = await fetch(`${apiBaseUrl()}/api/miniapp/admin/members/rent-weight`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'content-type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify({
|
||||
initData,
|
||||
memberId,
|
||||
rentShareWeight
|
||||
})
|
||||
})
|
||||
|
||||
const payload = (await response.json()) as {
|
||||
ok: boolean
|
||||
authorized?: boolean
|
||||
member?: MiniAppMember
|
||||
error?: string
|
||||
}
|
||||
|
||||
if (!response.ok || !payload.member) {
|
||||
throw new Error(payload.error ?? 'Failed to update member rent weight')
|
||||
}
|
||||
|
||||
return payload.member
|
||||
}
|
||||
|
||||
export async function fetchMiniAppBillingCycle(initData: string): Promise<MiniAppAdminCycleState> {
|
||||
const response = await fetch(`${apiBaseUrl()}/api/miniapp/admin/billing-cycle`, {
|
||||
method: 'POST',
|
||||
|
||||
Reference in New Issue
Block a user