diff --git a/src/hooks/useConsumerHostServices.tsx b/src/hooks/useConsumerHostServices.tsx index 196c1da8..2f16b7f9 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( @@ -507,13 +508,13 @@ export const useConsumerHostServices = ( // Get user hosting plans for a specific project 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) => {