mirror of
https://github.com/whekin/household-bot.git
synced 2026-03-31 21:14:02 +00:00
feat(member): add household lifecycle states
This commit is contained in:
@@ -6,6 +6,7 @@ export interface MiniAppSession {
|
||||
id: string
|
||||
householdId: string
|
||||
displayName: string
|
||||
status: 'active' | 'away' | 'left'
|
||||
isAdmin: boolean
|
||||
preferredLocale: 'en' | 'ru' | null
|
||||
householdDefaultLocale: 'en' | 'ru'
|
||||
@@ -39,6 +40,7 @@ export interface MiniAppPendingMember {
|
||||
export interface MiniAppMember {
|
||||
id: string
|
||||
displayName: string
|
||||
status: 'active' | 'away' | 'left'
|
||||
rentShareWeight: number
|
||||
isAdmin: boolean
|
||||
}
|
||||
@@ -514,6 +516,37 @@ export async function updateMiniAppMemberRentWeight(
|
||||
return payload.member
|
||||
}
|
||||
|
||||
export async function updateMiniAppMemberStatus(
|
||||
initData: string,
|
||||
memberId: string,
|
||||
status: 'active' | 'away' | 'left'
|
||||
): Promise<MiniAppMember> {
|
||||
const response = await fetch(`${apiBaseUrl()}/api/miniapp/admin/members/status`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'content-type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify({
|
||||
initData,
|
||||
memberId,
|
||||
status
|
||||
})
|
||||
})
|
||||
|
||||
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 status')
|
||||
}
|
||||
|
||||
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