🐛 fix: Add onSuccess callback to Unsubscribe component and conditionally render Renewal component
This commit is contained in:
parent
71cb827918
commit
7b5367a9a9
@ -21,11 +21,13 @@ import { useGlobalStore } from "@/stores/global";
|
|||||||
interface UnsubscribeProps {
|
interface UnsubscribeProps {
|
||||||
id: number;
|
id: number;
|
||||||
allowDeduction?: boolean;
|
allowDeduction?: boolean;
|
||||||
|
onSuccess?: () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function Unsubscribe({
|
export default function Unsubscribe({
|
||||||
id,
|
id,
|
||||||
allowDeduction,
|
allowDeduction,
|
||||||
|
onSuccess,
|
||||||
}: Readonly<UnsubscribeProps>) {
|
}: Readonly<UnsubscribeProps>) {
|
||||||
const { t } = useTranslation("subscribe");
|
const { t } = useTranslation("subscribe");
|
||||||
const { common, getUserInfo } = useGlobalStore();
|
const { common, getUserInfo } = useGlobalStore();
|
||||||
@ -52,6 +54,7 @@ export default function Unsubscribe({
|
|||||||
);
|
);
|
||||||
toast.success(t("unsubscribe.success", "Unsubscribed successfully"));
|
toast.success(t("unsubscribe.success", "Unsubscribed successfully"));
|
||||||
await getUserInfo();
|
await getUserInfo();
|
||||||
|
onSuccess?.();
|
||||||
setOpen(false);
|
setOpen(false);
|
||||||
} catch (_error) {
|
} catch (_error) {
|
||||||
toast.error(t("unsubscribe.failed", "Unsubscribe failed"));
|
toast.error(t("unsubscribe.failed", "Unsubscribe failed"));
|
||||||
|
|||||||
@ -313,11 +313,13 @@ export default function Content() {
|
|||||||
id={item.id}
|
id={item.id}
|
||||||
replacement={item.subscribe.replacement}
|
replacement={item.subscribe.replacement}
|
||||||
/>
|
/>
|
||||||
<Renewal id={item.id} subscribe={item.subscribe} />
|
{item.expire_time !== 0 && (
|
||||||
|
<Renewal id={item.id} subscribe={item.subscribe} />
|
||||||
|
)}
|
||||||
<Unsubscribe
|
<Unsubscribe
|
||||||
allowDeduction={item.subscribe.allow_deduction}
|
allowDeduction={item.subscribe.allow_deduction}
|
||||||
id={item.id}
|
id={item.id}
|
||||||
|
onSuccess={refetch}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user