🐛 fix: Add onSuccess callback to Unsubscribe component and conditionally render Renewal component

This commit is contained in:
web@ppanel 2025-12-22 04:38:16 +00:00
parent 71cb827918
commit 7b5367a9a9
2 changed files with 7 additions and 2 deletions

View File

@ -21,11 +21,13 @@ import { useGlobalStore } from "@/stores/global";
interface UnsubscribeProps {
id: number;
allowDeduction?: boolean;
onSuccess?: () => void;
}
export default function Unsubscribe({
id,
allowDeduction,
onSuccess,
}: Readonly<UnsubscribeProps>) {
const { t } = useTranslation("subscribe");
const { common, getUserInfo } = useGlobalStore();
@ -52,6 +54,7 @@ export default function Unsubscribe({
);
toast.success(t("unsubscribe.success", "Unsubscribed successfully"));
await getUserInfo();
onSuccess?.();
setOpen(false);
} catch (_error) {
toast.error(t("unsubscribe.failed", "Unsubscribe failed"));

View File

@ -313,11 +313,13 @@ export default function Content() {
id={item.id}
replacement={item.subscribe.replacement}
/>
{item.expire_time !== 0 && (
<Renewal id={item.id} subscribe={item.subscribe} />
)}
<Unsubscribe
allowDeduction={item.subscribe.allow_deduction}
id={item.id}
onSuccess={refetch}
/>
</div>
)}