fix: custom endpoints not saved when creating new provider
When creating a new provider, custom endpoints added in the speed test modal were not being saved properly. The issue was in ProviderForm.tsx where the CustomEndpoint object was constructed without the optional lastUsed field. This caused inconsistency between: - Edit mode: uses backend API (addCustomEndpoint) which correctly constructs complete CustomEndpoint objects - Create mode: directly constructs objects in frontend, missing the lastUsed field Fixed by explicitly setting lastUsed to undefined when constructing custom endpoints in create mode, ensuring structural consistency with the TypeScript CustomEndpoint interface.
This commit is contained in:
@@ -615,7 +615,7 @@ const ProviderForm: React.FC<ProviderFormProps> = ({
|
||||
...(category ? { category } : {}),
|
||||
};
|
||||
|
||||
// 若为“新建供应商”,且已在弹窗中添加了自定义端点,则随提交一并落盘
|
||||
// 若为"新建供应商",且已在弹窗中添加了自定义端点,则随提交一并落盘
|
||||
if (!initialData && draftCustomEndpoints.length > 0) {
|
||||
const now = Date.now();
|
||||
const customMap: Record<string, CustomEndpoint> = {};
|
||||
@@ -623,7 +623,7 @@ const ProviderForm: React.FC<ProviderFormProps> = ({
|
||||
const url = raw.trim().replace(/\/+$/, "");
|
||||
if (!url) continue;
|
||||
if (!customMap[url]) {
|
||||
customMap[url] = { url, addedAt: now };
|
||||
customMap[url] = { url, addedAt: now, lastUsed: undefined };
|
||||
}
|
||||
}
|
||||
onSubmit({ ...basePayload, meta: { custom_endpoints: customMap } });
|
||||
|
||||
Reference in New Issue
Block a user