feat(subscribe): Add reset_time to API typings and update unsubscribe logic

This commit is contained in:
web@ppanel 2025-01-04 20:57:37 +07:00
parent 25ce37ea05
commit eeea165f7e
7 changed files with 17 additions and 5 deletions

View File

@ -1,5 +1,5 @@
// @ts-ignore
// API 更新时间:
// API 唯一标识:
import * as announcement from './announcement';

View File

@ -1067,6 +1067,7 @@ declare namespace API {
subscribe: Subscribe;
start_time: number;
expire_time: number;
reset_time: number;
traffic: number;
download: number;
upload: number;

View File

@ -473,6 +473,7 @@ declare namespace API {
subscribe: Subscribe;
start_time: number;
expire_time: number;
reset_time: number;
traffic: number;
download: number;
upload: number;

View File

@ -171,7 +171,11 @@ export default function Content() {
</li>
<li>
<span className='text-muted-foreground'>{t('nextResetDays')}</span>
<span className='text-2xl font-semibold'>{t('unknown')}</span>
<span className='text-2xl font-semibold'>
{item.reset_time
? differenceInDays(new Date(item.reset_time), new Date())
: t('unknown')}
</span>
</li>
<li>
<span className='text-muted-foreground'>{t('expirationDays')}</span>

View File

@ -1,5 +1,6 @@
'use client';
import useGlobalStore from '@/config/use-global';
import { preUnsubscribe, unsubscribe } from '@/services/user/user';
import { useQuery } from '@tanstack/react-query';
import { Button } from '@workspace/ui/components/button';
@ -24,9 +25,12 @@ interface UnsubscribeProps {
}
export default function Unsubscribe({ id, allowDeduction }: Readonly<UnsubscribeProps>) {
const [open, setOpen] = useState(false);
const router = useRouter();
const t = useTranslations('subscribe.unsubscribe');
const router = useRouter();
const { common } = useGlobalStore();
const single_model = common.subscribe.single_model;
const [open, setOpen] = useState(false);
const { data } = useQuery({
enabled: Boolean(open && id && allowDeduction),
@ -53,7 +57,7 @@ export default function Unsubscribe({ id, allowDeduction }: Readonly<Unsubscribe
}
};
if (!allowDeduction) return null;
if (!single_model && !allowDeduction) return null;
return (
<Dialog open={open} onOpenChange={setOpen}>

View File

@ -473,6 +473,7 @@ declare namespace API {
subscribe: Subscribe;
start_time: number;
expire_time: number;
reset_time: number;
traffic: number;
download: number;
upload: number;

View File

@ -654,6 +654,7 @@ declare namespace API {
subscribe: Subscribe;
start_time: number;
expire_time: number;
reset_time: number;
traffic: number;
download: number;
upload: number;