import { useMemo } from 'react';

import { userConfigModel } from '@/models/userConfigModel';

export interface UseServiceReturn {
    userAccount: string;
    planExpireTime: number;
}

export function useService(): UseServiceReturn {
    const { userConfig } = userConfigModel.useModel();

    const userAccount = useMemo(() => {
        if (!userConfig) return '';
        return userConfig.account?.username || '';
    }, [userConfig]);

    const planExpireTime = useMemo(() => {
        return userConfig?.expireTime ?? 0;
    }, [userConfig]);

    return {
        userAccount,
        planExpireTime,
    };
}
