feat: Added the option to restore subscription, and updated the relevant description and confirmation information.

This commit is contained in:
web@ppanel 2025-12-29 05:59:30 +00:00
parent bc451eea16
commit 5f5c33987e
5 changed files with 47 additions and 18 deletions

View File

@ -79,6 +79,10 @@
"stopSubscribeDescription": "This will stop the subscription temporarily. User will not be able to use it.", "stopSubscribeDescription": "This will stop the subscription temporarily. User will not be able to use it.",
"stopSubscribeSuccess": "Subscription stopped successfully", "stopSubscribeSuccess": "Subscription stopped successfully",
"confirmStopSubscribe": "Confirm Stop Subscription", "confirmStopSubscribe": "Confirm Stop Subscription",
"resumeSubscribe": "Resume Subscription",
"resumeSubscribeDescription": "This will resume the subscription and allow the user to use it.",
"resumeSubscribeSuccess": "Subscription resumed successfully",
"confirmResumeSubscribe": "Confirm Resume Subscription",
"status": "Status", "status": "Status",
"statusPending": "Pending", "statusPending": "Pending",
"statusActive": "Active", "statusActive": "Active",

View File

@ -79,6 +79,10 @@
"stopSubscribeDescription": "这将暂时停止订阅。用户将无法使用。", "stopSubscribeDescription": "这将暂时停止订阅。用户将无法使用。",
"stopSubscribeSuccess": "订阅已暂停", "stopSubscribeSuccess": "订阅已暂停",
"confirmStopSubscribe": "确认暂停订阅", "confirmStopSubscribe": "确认暂停订阅",
"resumeSubscribe": "恢复订阅",
"resumeSubscribeDescription": "这将恢复订阅,允许用户继续使用。",
"resumeSubscribeSuccess": "订阅已恢复",
"confirmResumeSubscribe": "确认恢复订阅",
"status": "状态", "status": "状态",
"statusPending": "待处理", "statusPending": "待处理",
"statusActive": "活跃", "statusActive": "活跃",

View File

@ -17,7 +17,7 @@ import {
deleteUserSubscribe, deleteUserSubscribe,
getUserSubscribe, getUserSubscribe,
resetUserSubscribeToken, resetUserSubscribeToken,
stopUserSubscribe, toggleUserSubscribeStatus,
updateUserSubscribe, updateUserSubscribe,
} from "@workspace/ui/services/admin/user"; } from "@workspace/ui/services/admin/user";
import { useRef, useState } from "react"; import { useRef, useState } from "react";
@ -99,22 +99,43 @@ export default function UserSubscription({ userId }: { userId: number }) {
<ConfirmButton <ConfirmButton
cancelText={t("cancel", "Cancel")} cancelText={t("cancel", "Cancel")}
confirmText={t("confirm", "Confirm")} confirmText={t("confirm", "Confirm")}
description={t( description={
"stopSubscribeDescription", row.status === 5
"This will stop the subscription temporarily. User will not be able to use it." ? t(
)} "resumeSubscribeDescription",
key="stop" "This will resume the subscription and allow the user to use it."
)
: t(
"stopSubscribeDescription",
"This will stop the subscription temporarily. User will not be able to use it."
)
}
key="toggle"
onConfirm={async () => { onConfirm={async () => {
await stopUserSubscribe({ user_subscribe_id: row.id }); await toggleUserSubscribeStatus({ user_subscribe_id: row.id });
toast.success( toast.success(
t("stopSubscribeSuccess", "Subscription stopped successfully") row.status === 5
? t(
"resumeSubscribeSuccess",
"Subscription resumed successfully"
)
: t(
"stopSubscribeSuccess",
"Subscription stopped successfully"
)
); );
ref.current?.refresh(); ref.current?.refresh();
}} }}
title={t("confirmStopSubscribe", "Confirm Stop Subscription")} title={
row.status === 5
? t("confirmResumeSubscribe", "Confirm Resume Subscription")
: t("confirmStopSubscribe", "Confirm Stop Subscription")
}
trigger={ trigger={
<Button variant="secondary"> <Button variant="secondary">
{t("stopSubscribe", "Stop Subscription")} {row.status === 5
? t("resumeSubscribe", "Resume Subscription")
: t("stopSubscribe", "Stop Subscription")}
</Button> </Button>
} }
/>, />,

View File

@ -2004,10 +2004,6 @@ declare namespace API {
id: number; id: number;
}; };
type StopUserSubscribeRequest = {
user_subscribe_id: number;
};
type StripePayment = { type StripePayment = {
method: string; method: string;
client_secret: string; client_secret: string;
@ -2167,6 +2163,10 @@ declare namespace API {
enable: boolean; enable: boolean;
}; };
type ToggleUserSubscribeStatusRequest = {
user_subscribe_id: number;
};
type TosConfig = { type TosConfig = {
tos_content: string; tos_content: string;
}; };

View File

@ -465,13 +465,13 @@ export async function resetUserSubscribeTraffic(
); );
} }
/** Stop user subscribe POST /v1/admin/user/subscribe/stop */ /** Stop user subscribe POST /v1/admin/user/subscribe/toggle */
export async function stopUserSubscribe( export async function toggleUserSubscribeStatus(
body: API.StopUserSubscribeRequest, body: API.ToggleUserSubscribeStatusRequest,
options?: { [key: string]: any } options?: { [key: string]: any }
) { ) {
return request<API.Response & { data?: any }>( return request<API.Response & { data?: any }>(
`${import.meta.env.VITE_API_PREFIX || ""}/v1/admin/user/subscribe/stop`, `${import.meta.env.VITE_API_PREFIX || ""}/v1/admin/user/subscribe/toggle`,
{ {
method: "POST", method: "POST",
headers: { headers: {