import { useCallback } from 'react';

import { useTranslation } from 'react-i18next';

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

export interface ComingSoonDialogOptions {
    /** 弹窗标题的 i18n key，默认 common.comingSoon.dialogTitle */
    titleKey?: string;
    /** 提示文案的 i18n key，默认 common.comingSoon.dialogPrompt */
    promptKey?: string;
}

export function useComingSoonDialog() {
    const { t } = useTranslation();
    const { openDialog, closeDialog } = dialogModel.useModel();

    return useCallback(
        (options?: ComingSoonDialogOptions) => {
            const titleKey = options?.titleKey ?? 'common.comingSoon.dialogTitle';
            const promptKey = options?.promptKey ?? 'common.comingSoon.dialogPrompt';

            const id = openDialog({
                title: t(titleKey),
                content: <p className="text-white/80 text-sm">{t(promptKey)}</p>,
                buttons: [
                    {
                        label: t('common.comingSoon.ok'),
                        variant: 'primary',
                        onClick: () => closeDialog(id),
                    },
                ],
                maskClosable: true,
                closeable: true,
            });
        },
        [t, openDialog, closeDialog]
    );
}
