Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 15 additions & 14 deletions src/hooks/useConsumerHostServices.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -450,15 +450,16 @@ export const useConsumerHostServices = (
return res;
}, []);

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

return res;
}, []);
return res;
},
[],
);

// 新增: 创建订阅
const createSubscription = useCallback(
Expand Down Expand Up @@ -507,13 +508,13 @@ export const useConsumerHostServices = (

// Get user hosting plans for a specific project
const getUserHostingPlansByProject = useCallback(
async (projectId: number): Promise<AxiosResponse<IGetHostingPlans[] | ConsumerHostError>> => {
const res = await instance.get<IGetHostingPlans[] | ConsumerHostError>(
`/users/hosting-plans/project/${projectId}`,
{
headers: authHeaders.current,
async (projectId: number, wallet: string): Promise<AxiosResponse<IGetHostingPlans[] | ConsumerHostError>> => {
const res = await instance.get<IGetHostingPlans[] | ConsumerHostError>(`/hosting-plans/project/${projectId}`, {
headers: authHeaders.current,
params: {
wallet,
},
);
});

return res;
},
Expand Down
7 changes: 4 additions & 3 deletions src/pages/consumer/MyFlexPlans/MyHostedPlan/MyHostedPlan.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ const useGetConnectUrl = () => {
const MyHostedPlan: FC = () => {
const navigate = useNavigate();
const {
updateHostingPlanApi,
getUserSubscriptions,
unsubscribeProject,
getUserHostingPlansByProject,
Expand Down Expand Up @@ -130,10 +129,12 @@ const MyHostedPlan: FC = () => {
const ref = useRef<CreateHostingFlexPlanRef>(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);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Remove debug logging statement.

The console.warn statement appears to be leftover debug code and should be removed before merging to production.

Apply this diff:

       const res = await getUserSubscriptions(account);
       if (!isConsumerHostError(res.data)) {
-        console.warn(res.data);
         setSubscriptions(res.data);
       } else {
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
console.warn(res.data);
const res = await getUserSubscriptions(account);
if (!isConsumerHostError(res.data)) {
setSubscriptions(res.data);
} else {
🤖 Prompt for AI Agents
In src/pages/consumer/MyFlexPlans/MyHostedPlan/MyHostedPlan.tsx around line 137,
remove the leftover debug logging statement `console.warn(res.data);` so no
debug console output remains in production; delete that line (or replace with
proper user-facing/error handling logic if needed) and run lint/tests to ensure
nothing else depends on it.

setSubscriptions(res.data);
} else {
setSubscriptions([]);
Expand All @@ -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) => {
Expand Down