mirror of
https://github.com/QuantumNous/new-api.git
synced 2026-09-07 01:56:53 +00:00
feat(default): reorganize system settings pricing UI
Refine the default system settings structure and model pricing editor so pricing configuration is easier to scan and edit.
This commit is contained in:
@@ -1,88 +0,0 @@
|
||||
import { SettingsPage } from '../components/settings-page'
|
||||
import type { IntegrationSettings as IntegrationSettingsType } from '../types'
|
||||
import {
|
||||
INTEGRATIONS_DEFAULT_SECTION,
|
||||
getIntegrationsSectionContent,
|
||||
} from './section-registry.tsx'
|
||||
|
||||
const defaultIntegrationSettings: IntegrationSettingsType = {
|
||||
SMTPServer: '',
|
||||
SMTPPort: '',
|
||||
SMTPAccount: '',
|
||||
SMTPFrom: '',
|
||||
SMTPToken: '',
|
||||
SMTPSSLEnabled: false,
|
||||
SMTPForceAuthLogin: false,
|
||||
WorkerUrl: '',
|
||||
WorkerValidKey: '',
|
||||
WorkerAllowHttpImageRequestEnabled: false,
|
||||
ChannelDisableThreshold: '',
|
||||
QuotaRemindThreshold: '',
|
||||
AutomaticDisableChannelEnabled: false,
|
||||
AutomaticEnableChannelEnabled: false,
|
||||
AutomaticDisableKeywords: '',
|
||||
AutomaticDisableStatusCodes: '401',
|
||||
AutomaticRetryStatusCodes:
|
||||
'100-199,300-399,401-407,409-499,500-503,505-523,525-599',
|
||||
'monitor_setting.auto_test_channel_enabled': false,
|
||||
'monitor_setting.auto_test_channel_minutes': 10,
|
||||
'model_deployment.ionet.api_key': '',
|
||||
'model_deployment.ionet.enabled': false,
|
||||
PayAddress: '',
|
||||
EpayId: '',
|
||||
EpayKey: '',
|
||||
Price: 7.3,
|
||||
MinTopUp: 1,
|
||||
CustomCallbackAddress: '',
|
||||
PayMethods: '',
|
||||
'payment_setting.amount_options': '',
|
||||
'payment_setting.amount_discount': '',
|
||||
StripeApiSecret: '',
|
||||
StripeWebhookSecret: '',
|
||||
StripePriceId: '',
|
||||
StripeUnitPrice: 8.0,
|
||||
StripeMinTopUp: 1,
|
||||
StripePromotionCodesEnabled: false,
|
||||
CreemApiKey: '',
|
||||
CreemWebhookSecret: '',
|
||||
CreemTestMode: false,
|
||||
CreemProducts: '[]',
|
||||
WaffoEnabled: false,
|
||||
WaffoApiKey: '',
|
||||
WaffoPrivateKey: '',
|
||||
WaffoPublicCert: '',
|
||||
WaffoSandboxPublicCert: '',
|
||||
WaffoSandboxApiKey: '',
|
||||
WaffoSandboxPrivateKey: '',
|
||||
WaffoSandbox: false,
|
||||
WaffoMerchantId: '',
|
||||
WaffoCurrency: 'USD',
|
||||
WaffoUnitPrice: 1,
|
||||
WaffoMinTopUp: 1,
|
||||
WaffoNotifyUrl: '',
|
||||
WaffoReturnUrl: '',
|
||||
WaffoPayMethods: '[]',
|
||||
WaffoPancakeEnabled: false,
|
||||
WaffoPancakeSandbox: false,
|
||||
WaffoPancakeMerchantID: '',
|
||||
WaffoPancakePrivateKey: '',
|
||||
WaffoPancakeWebhookPublicKey: '',
|
||||
WaffoPancakeWebhookTestKey: '',
|
||||
WaffoPancakeStoreID: '',
|
||||
WaffoPancakeProductID: '',
|
||||
WaffoPancakeReturnURL: '',
|
||||
WaffoPancakeCurrency: 'USD',
|
||||
WaffoPancakeUnitPrice: 1,
|
||||
WaffoPancakeMinTopUp: 1,
|
||||
}
|
||||
|
||||
export function IntegrationSettings() {
|
||||
return (
|
||||
<SettingsPage
|
||||
routePath='/_authenticated/system-settings/integrations/$section'
|
||||
defaultSettings={defaultIntegrationSettings}
|
||||
defaultSection={INTEGRATIONS_DEFAULT_SECTION}
|
||||
getSectionContent={getIntegrationsSectionContent}
|
||||
/>
|
||||
)
|
||||
}
|
||||
@@ -1,160 +0,0 @@
|
||||
import type { IntegrationSettings } from '../types'
|
||||
import { createSectionRegistry } from '../utils/section-registry'
|
||||
import { EmailSettingsSection } from './email-settings-section'
|
||||
import { IoNetDeploymentSettingsSection } from './ionet-deployment-settings-section'
|
||||
import { MonitoringSettingsSection } from './monitoring-settings-section'
|
||||
import { PaymentSettingsSection } from './payment-settings-section'
|
||||
import { WorkerSettingsSection } from './worker-settings-section'
|
||||
|
||||
const INTEGRATIONS_SECTIONS = [
|
||||
{
|
||||
id: 'payment',
|
||||
titleKey: 'Payment Gateway',
|
||||
descriptionKey: 'Configure payment gateway integrations',
|
||||
build: (settings: IntegrationSettings) => (
|
||||
<PaymentSettingsSection
|
||||
defaultValues={{
|
||||
PayAddress: settings.PayAddress,
|
||||
EpayId: settings.EpayId,
|
||||
EpayKey: settings.EpayKey,
|
||||
Price: settings.Price,
|
||||
MinTopUp: settings.MinTopUp,
|
||||
CustomCallbackAddress: settings.CustomCallbackAddress,
|
||||
PayMethods: settings.PayMethods,
|
||||
AmountOptions: settings['payment_setting.amount_options'],
|
||||
AmountDiscount: settings['payment_setting.amount_discount'],
|
||||
StripeApiSecret: settings.StripeApiSecret,
|
||||
StripeWebhookSecret: settings.StripeWebhookSecret,
|
||||
StripePriceId: settings.StripePriceId,
|
||||
StripeUnitPrice: settings.StripeUnitPrice,
|
||||
StripeMinTopUp: settings.StripeMinTopUp,
|
||||
StripePromotionCodesEnabled: settings.StripePromotionCodesEnabled,
|
||||
CreemApiKey: settings.CreemApiKey,
|
||||
CreemWebhookSecret: settings.CreemWebhookSecret,
|
||||
CreemTestMode: settings.CreemTestMode,
|
||||
CreemProducts: settings.CreemProducts,
|
||||
}}
|
||||
waffoDefaultValues={{
|
||||
WaffoEnabled: settings.WaffoEnabled ?? false,
|
||||
WaffoApiKey: settings.WaffoApiKey ?? '',
|
||||
WaffoPrivateKey: settings.WaffoPrivateKey ?? '',
|
||||
WaffoPublicCert: settings.WaffoPublicCert ?? '',
|
||||
WaffoSandboxPublicCert: settings.WaffoSandboxPublicCert ?? '',
|
||||
WaffoSandboxApiKey: settings.WaffoSandboxApiKey ?? '',
|
||||
WaffoSandboxPrivateKey: settings.WaffoSandboxPrivateKey ?? '',
|
||||
WaffoSandbox: settings.WaffoSandbox ?? false,
|
||||
WaffoMerchantId: settings.WaffoMerchantId ?? '',
|
||||
WaffoCurrency: settings.WaffoCurrency ?? 'USD',
|
||||
WaffoUnitPrice: settings.WaffoUnitPrice ?? 1,
|
||||
WaffoMinTopUp: settings.WaffoMinTopUp ?? 1,
|
||||
WaffoNotifyUrl: settings.WaffoNotifyUrl ?? '',
|
||||
WaffoReturnUrl: settings.WaffoReturnUrl ?? '',
|
||||
WaffoPayMethods: settings.WaffoPayMethods ?? '[]',
|
||||
}}
|
||||
waffoPancakeDefaultValues={{
|
||||
WaffoPancakeEnabled: settings.WaffoPancakeEnabled ?? false,
|
||||
WaffoPancakeSandbox: settings.WaffoPancakeSandbox ?? false,
|
||||
WaffoPancakeMerchantID: settings.WaffoPancakeMerchantID ?? '',
|
||||
WaffoPancakePrivateKey: settings.WaffoPancakePrivateKey ?? '',
|
||||
WaffoPancakeWebhookPublicKey:
|
||||
settings.WaffoPancakeWebhookPublicKey ?? '',
|
||||
WaffoPancakeWebhookTestKey: settings.WaffoPancakeWebhookTestKey ?? '',
|
||||
WaffoPancakeStoreID: settings.WaffoPancakeStoreID ?? '',
|
||||
WaffoPancakeProductID: settings.WaffoPancakeProductID ?? '',
|
||||
WaffoPancakeReturnURL: settings.WaffoPancakeReturnURL ?? '',
|
||||
WaffoPancakeCurrency: settings.WaffoPancakeCurrency ?? 'USD',
|
||||
WaffoPancakeUnitPrice: settings.WaffoPancakeUnitPrice ?? 1,
|
||||
WaffoPancakeMinTopUp: settings.WaffoPancakeMinTopUp ?? 1,
|
||||
}}
|
||||
/>
|
||||
),
|
||||
},
|
||||
{
|
||||
id: 'email',
|
||||
titleKey: 'SMTP Email',
|
||||
descriptionKey: 'Configure SMTP email settings',
|
||||
build: (settings: IntegrationSettings) => (
|
||||
<EmailSettingsSection
|
||||
defaultValues={{
|
||||
SMTPServer: settings.SMTPServer,
|
||||
SMTPPort: settings.SMTPPort,
|
||||
SMTPAccount: settings.SMTPAccount,
|
||||
SMTPFrom: settings.SMTPFrom,
|
||||
SMTPToken: settings.SMTPToken,
|
||||
SMTPSSLEnabled: settings.SMTPSSLEnabled,
|
||||
SMTPForceAuthLogin: settings.SMTPForceAuthLogin,
|
||||
}}
|
||||
/>
|
||||
),
|
||||
},
|
||||
{
|
||||
id: 'worker',
|
||||
titleKey: 'Worker Proxy',
|
||||
descriptionKey: 'Configure worker service settings',
|
||||
build: (settings: IntegrationSettings) => (
|
||||
<WorkerSettingsSection
|
||||
defaultValues={{
|
||||
WorkerUrl: settings.WorkerUrl,
|
||||
WorkerValidKey: settings.WorkerValidKey,
|
||||
WorkerAllowHttpImageRequestEnabled:
|
||||
settings.WorkerAllowHttpImageRequestEnabled,
|
||||
}}
|
||||
/>
|
||||
),
|
||||
},
|
||||
{
|
||||
id: 'ionet',
|
||||
titleKey: 'io.net Deployments',
|
||||
descriptionKey: 'Configure IoNet model deployment settings',
|
||||
build: (settings: IntegrationSettings) => (
|
||||
<IoNetDeploymentSettingsSection
|
||||
defaultValues={{
|
||||
enabled: settings['model_deployment.ionet.enabled'],
|
||||
apiKey: settings['model_deployment.ionet.api_key'],
|
||||
}}
|
||||
/>
|
||||
),
|
||||
},
|
||||
{
|
||||
id: 'monitoring',
|
||||
titleKey: 'Monitoring & Alerts',
|
||||
descriptionKey: 'Configure channel monitoring and automation',
|
||||
build: (settings: IntegrationSettings) => (
|
||||
<MonitoringSettingsSection
|
||||
defaultValues={{
|
||||
ChannelDisableThreshold: settings.ChannelDisableThreshold,
|
||||
QuotaRemindThreshold: settings.QuotaRemindThreshold,
|
||||
AutomaticDisableChannelEnabled:
|
||||
settings.AutomaticDisableChannelEnabled,
|
||||
AutomaticEnableChannelEnabled: settings.AutomaticEnableChannelEnabled,
|
||||
AutomaticDisableKeywords: settings.AutomaticDisableKeywords,
|
||||
AutomaticDisableStatusCodes: settings.AutomaticDisableStatusCodes,
|
||||
AutomaticRetryStatusCodes: settings.AutomaticRetryStatusCodes,
|
||||
'monitor_setting.auto_test_channel_enabled':
|
||||
settings['monitor_setting.auto_test_channel_enabled'],
|
||||
'monitor_setting.auto_test_channel_minutes':
|
||||
settings['monitor_setting.auto_test_channel_minutes'],
|
||||
}}
|
||||
/>
|
||||
),
|
||||
},
|
||||
] as const
|
||||
|
||||
export type IntegrationSectionId = (typeof INTEGRATIONS_SECTIONS)[number]['id']
|
||||
|
||||
const integrationsRegistry = createSectionRegistry<
|
||||
IntegrationSectionId,
|
||||
IntegrationSettings
|
||||
>({
|
||||
sections: INTEGRATIONS_SECTIONS,
|
||||
defaultSection: 'payment',
|
||||
basePath: '/system-settings/integrations',
|
||||
urlStyle: 'path',
|
||||
})
|
||||
|
||||
export const INTEGRATIONS_SECTION_IDS = integrationsRegistry.sectionIds
|
||||
export const INTEGRATIONS_DEFAULT_SECTION = integrationsRegistry.defaultSection
|
||||
export const getIntegrationsSectionNavItems =
|
||||
integrationsRegistry.getSectionNavItems
|
||||
export const getIntegrationsSectionContent =
|
||||
integrationsRegistry.getSectionContent
|
||||
Reference in New Issue
Block a user