Skip to content

Commit befd7f2

Browse files
authored
Merge pull request #876 from subquery/feat/subscription
Feat/subscription
2 parents 0f9fbdb + d4f47a4 commit befd7f2

File tree

2 files changed

+19
-17
lines changed

2 files changed

+19
-17
lines changed

src/hooks/useConsumerHostServices.tsx

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -450,15 +450,16 @@ export const useConsumerHostServices = (
450450
return res;
451451
}, []);
452452

453-
const getUserSubscriptions = useCallback(async (): Promise<
454-
AxiosResponse<IGetUserSubscription[] | ConsumerHostError>
455-
> => {
456-
const res = await instance.get<IGetUserSubscription[] | ConsumerHostError>('/users/subscriptions', {
457-
headers: authHeaders.current,
458-
});
453+
const getUserSubscriptions = useCallback(
454+
async (address: string): Promise<AxiosResponse<IGetUserSubscription[] | ConsumerHostError>> => {
455+
const res = await instance.get<IGetUserSubscription[] | ConsumerHostError>(`/subscriptions/wallet/${address}`, {
456+
headers: authHeaders.current,
457+
});
459458

460-
return res;
461-
}, []);
459+
return res;
460+
},
461+
[],
462+
);
462463

463464
// 新增: 创建订阅
464465
const createSubscription = useCallback(
@@ -507,13 +508,13 @@ export const useConsumerHostServices = (
507508

508509
// Get user hosting plans for a specific project
509510
const getUserHostingPlansByProject = useCallback(
510-
async (projectId: number): Promise<AxiosResponse<IGetHostingPlans[] | ConsumerHostError>> => {
511-
const res = await instance.get<IGetHostingPlans[] | ConsumerHostError>(
512-
`/users/hosting-plans/project/${projectId}`,
513-
{
514-
headers: authHeaders.current,
511+
async (projectId: number, wallet: string): Promise<AxiosResponse<IGetHostingPlans[] | ConsumerHostError>> => {
512+
const res = await instance.get<IGetHostingPlans[] | ConsumerHostError>(`/hosting-plans/project/${projectId}`, {
513+
headers: authHeaders.current,
514+
params: {
515+
wallet,
515516
},
516-
);
517+
});
517518

518519
return res;
519520
},

src/pages/consumer/MyFlexPlans/MyHostedPlan/MyHostedPlan.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,6 @@ const useGetConnectUrl = () => {
100100
const MyHostedPlan: FC = () => {
101101
const navigate = useNavigate();
102102
const {
103-
updateHostingPlanApi,
104103
getUserSubscriptions,
105104
unsubscribeProject,
106105
getUserHostingPlansByProject,
@@ -130,10 +129,12 @@ const MyHostedPlan: FC = () => {
130129
const ref = useRef<CreateHostingFlexPlanRef>(null);
131130

132131
const initSubscriptions = async () => {
132+
if (!account) return;
133133
try {
134134
setLoading(true);
135-
const res = await getUserSubscriptions();
135+
const res = await getUserSubscriptions(account || '');
136136
if (!isConsumerHostError(res.data)) {
137+
console.warn(res.data);
137138
setSubscriptions(res.data);
138139
} else {
139140
setSubscriptions([]);
@@ -148,7 +149,7 @@ const MyHostedPlan: FC = () => {
148149
const fetchHostingPlans = async (projectId: number) => {
149150
try {
150151
setExpandLoading(true);
151-
const res = await getUserHostingPlansByProject(projectId);
152+
const res = await getUserHostingPlansByProject(projectId, account || '');
152153
if (!isConsumerHostError(res.data)) {
153154
const allMetadata = await Promise.allSettled(
154155
res.data.map((i) => {

0 commit comments

Comments
 (0)