MCPcopy Create free account
hub / github.com/Kilo-Org/cloud / saveEdit

Function saveEdit

apps/web/src/app/admin/components/ModelStatsTable.tsx:119–161  ·  view source on GitHub ↗
(
    modelId: string,
    currentIsActiveValue: boolean | null,
    currentIsFeaturedValue?: boolean | null,
    currentIsStealthValue?: boolean | null
  )

Source from the content-addressed store, hash-verified

117 };
118
119 const saveEdit = async (
120 modelId: string,
121 currentIsActiveValue: boolean | null,
122 currentIsFeaturedValue?: boolean | null,
123 currentIsStealthValue?: boolean | null
124 ) => {
125 if (!editingField) return;
126
127 if (updatingModelId) return;
128
129 setUpdatingModelId(modelId);
130 try {
131 if (editingField.field === 'aaSlug') {
132 await updateModel.mutateAsync({
133 id: modelId,
134 aaSlug: editValue || null,
135 });
136 } else if (editingField.field === 'isActive') {
137 await updateModel.mutateAsync({
138 id: modelId,
139 isActive: !currentIsActiveValue,
140 });
141 } else if (editingField.field === 'isFeatured') {
142 await updateModel.mutateAsync({
143 id: modelId,
144 isFeatured: !currentIsFeaturedValue,
145 });
146 } else if (editingField.field === 'isStealth') {
147 await updateModel.mutateAsync({
148 id: modelId,
149 isStealth: !currentIsStealthValue,
150 });
151 }
152 toast.success('Model updated successfully');
153 setEditingField(null);
154 setEditValue('');
155 } catch (error) {
156 toast.error(error instanceof Error ? error.message : 'Failed to update model');
157 } finally {
158 setUpdatingModelId(null);
159 }
160 };
161
162 const handleCreateModel = async (e: React.FormEvent<HTMLFormElement>) => {
163 e.preventDefault();
164 const formData = new FormData(e.currentTarget);

Callers 1

ModelStatsTableFunction · 0.85

Calls 1

errorMethod · 0.65

Tested by

no test coverage detected