Rename tenant fields to tenant_pubkey and plan to plan_id
This commit is contained in:
@@ -44,9 +44,9 @@ export type PlanId = string
|
||||
|
||||
export type Relay = {
|
||||
id: string
|
||||
tenant: string
|
||||
tenant_pubkey: string
|
||||
subdomain: string
|
||||
plan: PlanId
|
||||
plan_id: PlanId
|
||||
status: string
|
||||
sync_error: string
|
||||
synced: number
|
||||
@@ -63,9 +63,9 @@ export type Relay = {
|
||||
}
|
||||
|
||||
export type CreateRelayInput = {
|
||||
tenant?: string
|
||||
tenant_pubkey?: string
|
||||
subdomain: string
|
||||
plan: string
|
||||
plan_id: string
|
||||
info_name?: string
|
||||
info_icon?: string
|
||||
info_description?: string
|
||||
@@ -80,7 +80,7 @@ export type CreateRelayInput = {
|
||||
|
||||
export type UpdateRelayInput = {
|
||||
subdomain?: string
|
||||
plan?: string
|
||||
plan_id?: string
|
||||
info_name?: string
|
||||
info_icon?: string
|
||||
info_description?: string
|
||||
@@ -115,7 +115,7 @@ export type Invoice = {
|
||||
|
||||
export type Activity = {
|
||||
id: string
|
||||
tenant: string
|
||||
tenant_pubkey: string
|
||||
created_at: number
|
||||
activity_type: string
|
||||
resource_type: string
|
||||
|
||||
@@ -116,8 +116,8 @@ export const createRelayForActiveTenant = (input: CreateRelayInput) => {
|
||||
|
||||
const overrides = {
|
||||
tenant: account()!.pubkey,
|
||||
blossom_enabled: input.plan === "free" ? 0 : 1,
|
||||
livekit_enabled: input.plan === "free" ? 0 : 1,
|
||||
blossom_enabled: input.plan_id === "free" ? 0 : 1,
|
||||
livekit_enabled: input.plan_id === "free" ? 0 : 1,
|
||||
}
|
||||
|
||||
return createRelay({...defaults, ...input, ...overrides})
|
||||
@@ -127,7 +127,7 @@ export const updateActiveTenant = (input: { nwc_url?: string }) => updateTenant(
|
||||
|
||||
export const updateRelayById = (id: string, input: UpdateRelayInput) => updateRelay(id, input)
|
||||
|
||||
export const updateRelayPlanById = (id: string, plan: string) => updateRelay(id, { plan })
|
||||
export const updateRelayPlanById = (id: string, plan_id: string) => updateRelay(id, { plan_id })
|
||||
|
||||
export const deactivateRelayById = (id: string) => deactivateRelay(id)
|
||||
|
||||
|
||||
@@ -77,14 +77,14 @@ export default function useRelayToggles(
|
||||
}
|
||||
}
|
||||
|
||||
async function handleUpdatePlan(plan: PlanId) {
|
||||
async function handleUpdatePlan(plan_id: PlanId) {
|
||||
const current = relay()
|
||||
if (!current) return
|
||||
|
||||
const previous = current
|
||||
const next = { ...current, plan }
|
||||
const update: Record<string, unknown> = { plan }
|
||||
if (plan === "free") {
|
||||
const next = { ...current, plan_id }
|
||||
const update: Record<string, unknown> = { plan_id }
|
||||
if (plan_id === "free") {
|
||||
next.blossom_enabled = 0
|
||||
next.livekit_enabled = 0
|
||||
update.blossom_enabled = 0
|
||||
@@ -101,7 +101,7 @@ export default function useRelayToggles(
|
||||
throw e
|
||||
}
|
||||
|
||||
if (plan !== "free") {
|
||||
if (plan_id !== "free") {
|
||||
const needsSetup = await tenantNeedsPaymentSetup()
|
||||
if (needsSetup) {
|
||||
const invoice = await getLatestOpenInvoice()
|
||||
@@ -116,9 +116,9 @@ export default function useRelayToggles(
|
||||
onToggleStripSignatures: () => toggle("policy_strip_signatures", false),
|
||||
onToggleGroups: () => toggle("groups_enabled", true),
|
||||
onToggleManagement: () => toggle("management_enabled", true),
|
||||
onToggleMediaStorage: () => toggle("blossom_enabled", relay()?.plan !== "free"),
|
||||
onToggleMediaStorage: () => toggle("blossom_enabled", relay()?.plan_id !== "free"),
|
||||
onTogglePushNotifications: () => toggle("push_enabled", true),
|
||||
onToggleLivekitSupport: () => toggle("livekit_enabled", relay()?.plan !== "free"),
|
||||
onToggleLivekitSupport: () => toggle("livekit_enabled", relay()?.plan_id !== "free"),
|
||||
}
|
||||
|
||||
return { busy, handleDeactivate, handleReactivate, handleUpdatePlan, pendingInvoice, clearPendingInvoice: () => setPendingInvoice(undefined), pendingPaymentSetup, clearPendingPaymentSetup: () => setPendingPaymentSetup(false), toggles }
|
||||
|
||||
Reference in New Issue
Block a user