From 35f4b4a9f2913cde1e188516792d96c9017817f2 Mon Sep 17 00:00:00 2001 From: cyrbuzz Date: Wed, 5 Nov 2025 15:30:46 +0800 Subject: [PATCH] feat: hosting plan --- src/hooks/useConsumerHostServices.tsx | 31 +++++++++---------- .../MyFlexPlans/MyHostedPlan/MyHostedPlan.tsx | 7 +++-- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/hooks/useConsumerHostServices.tsx b/src/hooks/useConsumerHostServices.tsx index 81b896f2..7c24cdcd 100644 --- a/src/hooks/useConsumerHostServices.tsx +++ b/src/hooks/useConsumerHostServices.tsx @@ -450,15 +450,16 @@ export const useConsumerHostServices = ( return res; }, []); - const getUserSubscriptions = useCallback(async (): Promise< - AxiosResponse - > => { - const res = await instance.get('/users/subscriptions', { - headers: authHeaders.current, - }); + const getUserSubscriptions = useCallback( + async (address: string): Promise> => { + const res = await instance.get(`/subscriptions/wallet/${address}`, { + headers: authHeaders.current, + }); - return res; - }, []); + return res; + }, + [], + ); // 新增: 创建订阅 const createSubscription = useCallback( @@ -488,7 +489,6 @@ export const useConsumerHostServices = ( [], ); - // 新增: 获取当前用户指定项目订阅信息 const getUserSubscriptionByProject = useCallback( async ( projectId: number, @@ -505,15 +505,14 @@ export const useConsumerHostServices = ( [], ); - // 新增: 获取当前用户指定项目的托管计划 const getUserHostingPlansByProject = useCallback( - async (projectId: number): Promise> => { - const res = await instance.get( - `/users/hosting-plans/project/${projectId}`, - { - headers: authHeaders.current, + async (projectId: number, wallet: string): Promise> => { + const res = await instance.get(`/hosting-plans/project/${projectId}`, { + headers: authHeaders.current, + params: { + wallet, }, - ); + }); return res; }, diff --git a/src/pages/consumer/MyFlexPlans/MyHostedPlan/MyHostedPlan.tsx b/src/pages/consumer/MyFlexPlans/MyHostedPlan/MyHostedPlan.tsx index 0d178903..ba71e14c 100644 --- a/src/pages/consumer/MyFlexPlans/MyHostedPlan/MyHostedPlan.tsx +++ b/src/pages/consumer/MyFlexPlans/MyHostedPlan/MyHostedPlan.tsx @@ -100,7 +100,6 @@ const useGetConnectUrl = () => { const MyHostedPlan: FC = () => { const navigate = useNavigate(); const { - updateHostingPlanApi, getUserSubscriptions, unsubscribeProject, getUserHostingPlansByProject, @@ -130,10 +129,12 @@ const MyHostedPlan: FC = () => { const ref = useRef(null); const initSubscriptions = async () => { + if (!account) return; try { setLoading(true); - const res = await getUserSubscriptions(); + const res = await getUserSubscriptions(account || ''); if (!isConsumerHostError(res.data)) { + console.warn(res.data); setSubscriptions(res.data); } else { setSubscriptions([]); @@ -148,7 +149,7 @@ const MyHostedPlan: FC = () => { const fetchHostingPlans = async (projectId: number) => { try { setExpandLoading(true); - const res = await getUserHostingPlansByProject(projectId); + const res = await getUserHostingPlansByProject(projectId, account || ''); if (!isConsumerHostError(res.data)) { const allMetadata = await Promise.allSettled( res.data.map((i) => {