From 1bd3ab0a7d3372689306cf43cc49c3f6995045f7 Mon Sep 17 00:00:00 2001 From: allence Date: Mon, 29 May 2023 15:16:07 +0800 Subject: [PATCH] fix(web): id -> _id --- .../pages/app/functions/mods/FunctionPanel/index.tsx | 2 +- .../pages/app/functions/mods/TriggerModal/index.tsx | 4 ++-- web/src/pages/app/functions/service.ts | 2 +- web/src/pages/app/mods/SideBar/index.tsx | 4 +++- web/src/pages/app/setting/PATList/index.tsx | 10 +++++----- .../pages/app/storages/mods/StorageListPanel/index.tsx | 2 +- web/src/pages/home/mods/CreateAppModal/index.tsx | 2 +- 7 files changed, 14 insertions(+), 12 deletions(-) diff --git a/web/src/pages/app/functions/mods/FunctionPanel/index.tsx b/web/src/pages/app/functions/mods/FunctionPanel/index.tsx index 51001ed0682..1357e04784d 100644 --- a/web/src/pages/app/functions/mods/FunctionPanel/index.tsx +++ b/web/src/pages/app/functions/mods/FunctionPanel/index.tsx @@ -195,7 +195,7 @@ export default function FunctionList() { {func?.name} - {functionCache.getCache(func?.id, func?.source?.code) !== + {functionCache.getCache(func?._id, func?.source?.code) !== func?.source?.code && ( )} diff --git a/web/src/pages/app/functions/mods/TriggerModal/index.tsx b/web/src/pages/app/functions/mods/TriggerModal/index.tsx index 70455fe80a2..517c45bbc43 100644 --- a/web/src/pages/app/functions/mods/TriggerModal/index.tsx +++ b/web/src/pages/app/functions/mods/TriggerModal/index.tsx @@ -108,7 +108,7 @@ export default function TriggerModal(props: { children: React.ReactElement }) { return item.desc.indexOf(searchKey) > -1; }) .map((item: any) => ( - + {item.desc} @@ -128,7 +128,7 @@ export default function TriggerModal(props: { children: React.ReactElement }) { - deleteTriggerMutation.mutate({ id: item.id }) + deleteTriggerMutation.mutate({ id: item._id }) } headerText={String(t("Delete"))} bodyText={t("TriggerPanel.DeleteConfirm")} diff --git a/web/src/pages/app/functions/service.ts b/web/src/pages/app/functions/service.ts index a3e3d649cf5..a51abf527ca 100644 --- a/web/src/pages/app/functions/service.ts +++ b/web/src/pages/app/functions/service.ts @@ -88,7 +88,7 @@ export const useDeleteFunctionMutation = () => { if (!data.error) { queryClient.invalidateQueries(queryKeys.useFunctionListQuery); store.setCurrentFunction({}); - functionCache.removeCache(data?.data?.id); + functionCache.removeCache(data?.data?._id); } }, }, diff --git a/web/src/pages/app/mods/SideBar/index.tsx b/web/src/pages/app/mods/SideBar/index.tsx index f7d04e12dd6..e96217c497c 100644 --- a/web/src/pages/app/mods/SideBar/index.tsx +++ b/web/src/pages/app/mods/SideBar/index.tsx @@ -26,7 +26,9 @@ export default function SideBar() { const { pageId } = useParams(); const navigate = useNavigate(); const { currentApp, setCurrentPage, userInfo, regions = [] } = useGlobalStore(); - const currentRegion = regions.find((item: any) => item.id === currentApp?.regionId) || regions[0]; + const currentRegion = + regions.find((item: any) => item._id === currentApp?.regionId) || regions[0]; + const ICONS: TIcon[] = [ { pageId: "nav", diff --git a/web/src/pages/app/setting/PATList/index.tsx b/web/src/pages/app/setting/PATList/index.tsx index b2524c19f6f..811e8cff704 100644 --- a/web/src/pages/app/setting/PATList/index.tsx +++ b/web/src/pages/app/setting/PATList/index.tsx @@ -26,7 +26,7 @@ const PATList = () => { const addPATMutation = useAddPATMutation((data: any) => { const newTokenList = [...tokenList]; newTokenList.push({ - id: data.id, + id: data._id, token: data.token, }); setTokenList(newTokenList); @@ -70,13 +70,13 @@ const PATList = () => { }, ]} configuration={{ - key: "id", + key: "_id", tableHeight: "40vh", hiddenEditButton: true, addButtonText: t("Add") + "Token", saveButtonText: t("Generate") + "Token", operationButtonsRender: (data: any) => { - const tokenItem = tokenList?.filter((item) => item.id === data.id); + const tokenItem = tokenList?.filter((item: any) => item._id === data._id); return tokenItem?.length === 1 ? ( @@ -88,8 +88,8 @@ const PATList = () => { onEdit={async () => {}} onDelete={async (data) => { await delPATMutation.mutateAsync({ id: data }); - const newTokenList = tokenList.filter((token) => { - return token.id !== data; + const newTokenList = tokenList.filter((token: any) => { + return token._id !== data; }); setTokenList(newTokenList); }} diff --git a/web/src/pages/app/storages/mods/StorageListPanel/index.tsx b/web/src/pages/app/storages/mods/StorageListPanel/index.tsx index f7ded870f06..6fb42aa9b69 100644 --- a/web/src/pages/app/storages/mods/StorageListPanel/index.tsx +++ b/web/src/pages/app/storages/mods/StorageListPanel/index.tsx @@ -34,7 +34,7 @@ export default function StorageListPanel() { store.setCurrentStorage(data?.data[0]); } else { store.setCurrentStorage( - data?.data?.filter((item: any) => item.id === store?.currentStorage?._id)[0], + data?.data?.filter((item: any) => item._id === store?.currentStorage?._id)[0], ); } } else { diff --git a/web/src/pages/home/mods/CreateAppModal/index.tsx b/web/src/pages/home/mods/CreateAppModal/index.tsx index 9fd60f78c3e..18fe791503b 100644 --- a/web/src/pages/home/mods/CreateAppModal/index.tsx +++ b/web/src/pages/home/mods/CreateAppModal/index.tsx @@ -90,7 +90,7 @@ const CreateAppModal = (props: { }; const currentRegion = - regions.find((item: any) => item.id === application?.regionId) || regions[0]; + regions.find((item: any) => item._id === application?.regionId) || regions[0]; const bundles = currentRegion.bundles;