mirror of
https://github.com/whekin/household-bot.git
synced 2026-03-31 14:04:04 +00:00
feat(miniapp): show topic routing in admin settings
This commit is contained in:
@@ -272,6 +272,19 @@ function App() {
|
||||
: copy().paymentLedgerRent
|
||||
}
|
||||
|
||||
function topicRoleLabel(role: 'purchase' | 'feedback' | 'reminders' | 'payments'): string {
|
||||
switch (role) {
|
||||
case 'purchase':
|
||||
return copy().topicPurchase
|
||||
case 'feedback':
|
||||
return copy().topicFeedback
|
||||
case 'reminders':
|
||||
return copy().topicReminders
|
||||
case 'payments':
|
||||
return copy().topicPayments
|
||||
}
|
||||
}
|
||||
|
||||
async function loadDashboard(initData: string) {
|
||||
try {
|
||||
setDashboard(await fetchMiniAppDashboard(initData))
|
||||
@@ -1393,6 +1406,33 @@ function App() {
|
||||
</button>
|
||||
</div>
|
||||
</article>
|
||||
|
||||
<article class="balance-item">
|
||||
<header>
|
||||
<strong>{copy().topicBindingsTitle}</strong>
|
||||
<span>{String(adminSettings()?.topics.length ?? 0)}/4</span>
|
||||
</header>
|
||||
<p>{copy().topicBindingsBody}</p>
|
||||
<div class="balance-list admin-sublist">
|
||||
{(['purchase', 'feedback', 'reminders', 'payments'] as const).map((role) => {
|
||||
const binding = adminSettings()?.topics.find((topic) => topic.role === role)
|
||||
|
||||
return (
|
||||
<article class="ledger-item">
|
||||
<header>
|
||||
<strong>{topicRoleLabel(role)}</strong>
|
||||
<span>{binding ? copy().topicBound : copy().topicUnbound}</span>
|
||||
</header>
|
||||
<p>
|
||||
{binding
|
||||
? `${binding.topicName ?? `Topic #${binding.telegramThreadId}`} · #${binding.telegramThreadId}`
|
||||
: copy().topicUnbound}
|
||||
</p>
|
||||
</article>
|
||||
)
|
||||
})}
|
||||
</div>
|
||||
</article>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
|
||||
@@ -71,6 +71,15 @@ export const dictionary = {
|
||||
latestActivityEmpty: 'Recent utility and purchase entries will appear here.',
|
||||
householdSettingsTitle: 'Household settings',
|
||||
householdSettingsBody: 'Control household defaults and approve roommates who requested access.',
|
||||
topicBindingsTitle: 'Topic bindings',
|
||||
topicBindingsBody:
|
||||
'Review which Telegram topics are currently connected for purchases, feedback, reminders, and payments.',
|
||||
topicPurchase: 'Purchases',
|
||||
topicFeedback: 'Feedback',
|
||||
topicReminders: 'Reminders',
|
||||
topicPayments: 'Payments',
|
||||
topicBound: 'Bound',
|
||||
topicUnbound: 'Unbound',
|
||||
billingSettingsTitle: 'Billing settings',
|
||||
settlementCurrency: 'Settlement currency',
|
||||
billingCycleTitle: 'Current billing cycle',
|
||||
@@ -194,6 +203,15 @@ export const dictionary = {
|
||||
latestActivityEmpty: 'Здесь появятся последние коммунальные платежи и покупки.',
|
||||
householdSettingsTitle: 'Настройки household',
|
||||
householdSettingsBody: 'Здесь можно менять язык household и подтверждать новых соседей.',
|
||||
topicBindingsTitle: 'Привязанные топики',
|
||||
topicBindingsBody:
|
||||
'Проверь, какие Telegram-топики сейчас подключены для покупок, обратной связи, напоминаний и оплат.',
|
||||
topicPurchase: 'Покупки',
|
||||
topicFeedback: 'Обратная связь',
|
||||
topicReminders: 'Напоминания',
|
||||
topicPayments: 'Оплаты',
|
||||
topicBound: 'Привязан',
|
||||
topicUnbound: 'Не привязан',
|
||||
billingSettingsTitle: 'Настройки биллинга',
|
||||
settlementCurrency: 'Валюта расчёта',
|
||||
billingCycleTitle: 'Текущий billing cycle',
|
||||
|
||||
@@ -64,6 +64,12 @@ export interface MiniAppUtilityCategory {
|
||||
isActive: boolean
|
||||
}
|
||||
|
||||
export interface MiniAppTopicBinding {
|
||||
role: 'purchase' | 'feedback' | 'reminders' | 'payments'
|
||||
telegramThreadId: string
|
||||
topicName: string | null
|
||||
}
|
||||
|
||||
export interface MiniAppDashboard {
|
||||
period: string
|
||||
currency: 'USD' | 'GEL'
|
||||
@@ -104,6 +110,7 @@ export interface MiniAppDashboard {
|
||||
|
||||
export interface MiniAppAdminSettingsPayload {
|
||||
settings: MiniAppBillingSettings
|
||||
topics: readonly MiniAppTopicBinding[]
|
||||
categories: readonly MiniAppUtilityCategory[]
|
||||
members: readonly MiniAppMember[]
|
||||
}
|
||||
@@ -349,6 +356,7 @@ export async function fetchMiniAppAdminSettings(
|
||||
ok: boolean
|
||||
authorized?: boolean
|
||||
settings?: MiniAppBillingSettings
|
||||
topics?: MiniAppTopicBinding[]
|
||||
categories?: MiniAppUtilityCategory[]
|
||||
members?: MiniAppMember[]
|
||||
error?: string
|
||||
@@ -358,6 +366,7 @@ export async function fetchMiniAppAdminSettings(
|
||||
!response.ok ||
|
||||
!payload.authorized ||
|
||||
!payload.settings ||
|
||||
!payload.topics ||
|
||||
!payload.categories ||
|
||||
!payload.members
|
||||
) {
|
||||
@@ -366,6 +375,7 @@ export async function fetchMiniAppAdminSettings(
|
||||
|
||||
return {
|
||||
settings: payload.settings,
|
||||
topics: payload.topics,
|
||||
categories: payload.categories,
|
||||
members: payload.members
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user