import { createContext, useContext, useEffect, useState } from 'react';
import { Link, useNavigate } from 'react-router-dom';
import { useTranslation } from 'react-i18next';
import { Button } from 'antd';
import { isNotEmpty } from '@/utils/commons';

const BackBtn = ({to, ...props}) => {
  const { t } = useTranslation();
  const navigate = useNavigate();
  return (
    <>
      {isNotEmpty(to) ? <Link to={to} className='px-4'>{t('Back')}</Link> : <Button type='link' onClick={() => navigate(-1)}>{t('Back')}</Button>}
    </>
  );
};
export default BackBtn;
