MCPcopy Create free account
hub / github.com/astercloud/aster / Settings

Function Settings

studio/src/pages/Settings.tsx:7–265  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

5import type { ModelPricing } from '../api/types';
6
7export function Settings() {
8 const { data: pricing, isLoading, refetch } = usePricing();
9 const updatePricing = useUpdatePricing();
10
11 const [editingModel, setEditingModel] = useState<string | null>(null);
12 const [editValues, setEditValues] = useState<Partial<ModelPricing>>({});
13 const [newModel, setNewModel] = useState({
14 model: '',
15 input_price_per_m: 0,
16 output_price_per_m: 0,
17 currency: 'USD',
18 });
19 const [showAddForm, setShowAddForm] = useState(false);
20
21 const handleEdit = (model: string, current: ModelPricing) => {
22 setEditingModel(model);
23 setEditValues(current);
24 };
25
26 const handleSave = async (model: string) => {
27 if (!editValues.input_price_per_m || !editValues.output_price_per_m) return;
28
29 try {
30 await updatePricing.mutateAsync({
31 model,
32 input_price_per_m: editValues.input_price_per_m,
33 output_price_per_m: editValues.output_price_per_m,
34 currency: editValues.currency || 'USD',
35 });
36 setEditingModel(null);
37 refetch();
38 } catch (error) {
39 console.error('Failed to update pricing:', error);
40 }
41 };
42
43 const handleAddModel = async () => {
44 if (!newModel.model) return;
45
46 try {
47 await updatePricing.mutateAsync(newModel);
48 setShowAddForm(false);
49 setNewModel({
50 model: '',
51 input_price_per_m: 0,
52 output_price_per_m: 0,
53 currency: 'USD',
54 });
55 refetch();
56 } catch (error) {
57 console.error('Failed to add model:', error);
58 }
59 };
60
61 return (
62 <div className="flex flex-col h-full">
63 <Header title="Settings" subtitle="系统配置" />
64

Callers

nothing calls this directly

Calls 4

usePricingFunction · 0.90
useUpdatePricingFunction · 0.90
handleSaveFunction · 0.85
handleEditFunction · 0.85

Tested by

no test coverage detected