'use client';

import { redirect } from 'next/navigation';

import pathsConfig from '@/config/paths.config';
import { useTranslation } from 'react-i18next';

import { usePersonalAccountData } from '@kit/accounts/hooks/use-personal-account-data';

import { SuccessNotification } from './success-notification';

export const UpdateAccountSuccessNotification = ({
  userId,
}: {
  userId?: string;
}) => {
  const { t } = useTranslation('account');

  if (!userId) {
    redirect(pathsConfig.app.home);
  }

  const { data: accountData } = usePersonalAccountData(userId);

  return (
    <SuccessNotification
      showLogo={false}
      title={t('account:updateAccount:successTitle', {
        firstName: accountData?.name,
        lastName: accountData?.last_name,
      })}
      descriptionKey="account:updateAccount:successDescription"
      buttonProps={{
        buttonTitleKey: 'account:updateAccount:successButton',
        href: pathsConfig.app.home,
      }}
    />
  );
};
