2023-04-28 21:23:06 +02:00
|
|
|
// Hooks
|
|
|
|
import { useContext } from 'react'
|
|
|
|
import { useTranslation } from 'next-i18next'
|
|
|
|
// Context
|
|
|
|
import { LoadingContext } from 'shared/context/loading-context.mjs'
|
|
|
|
// Components
|
2023-02-12 18:35:54 +01:00
|
|
|
import { Spinner } from 'shared/components/spinner.mjs'
|
|
|
|
import Link from 'next/link'
|
|
|
|
|
2023-05-17 13:50:56 +02:00
|
|
|
export const ContinueButton = ({ btnProps = {}, link = false }) => {
|
2023-04-28 21:23:06 +02:00
|
|
|
// Context
|
|
|
|
const { loading } = useContext(LoadingContext)
|
|
|
|
|
|
|
|
// Hooks
|
2023-02-12 18:35:54 +01:00
|
|
|
const { t } = useTranslation(['account'])
|
2023-04-28 21:23:06 +02:00
|
|
|
|
2023-02-12 18:35:54 +01:00
|
|
|
let classes = 'btn mt-8 capitalize w-full '
|
2023-04-28 21:23:06 +02:00
|
|
|
if (loading) classes += 'btn-accent '
|
2023-02-12 18:35:54 +01:00
|
|
|
else classes += 'btn-primary '
|
|
|
|
|
|
|
|
const children = (
|
|
|
|
<span className="flex flex-row items-center gap-2">
|
2023-04-28 21:23:06 +02:00
|
|
|
{loading ? (
|
2023-02-12 18:35:54 +01:00
|
|
|
<>
|
|
|
|
<Spinner />
|
|
|
|
<span>{t('processing')}</span>
|
|
|
|
</>
|
|
|
|
) : (
|
|
|
|
<span>{t('continue')}</span>
|
|
|
|
)}
|
|
|
|
</span>
|
|
|
|
)
|
|
|
|
|
|
|
|
return link ? (
|
|
|
|
<Link className={classes} tabIndex="-1" {...btnProps}>
|
|
|
|
{children}
|
|
|
|
</Link>
|
|
|
|
) : (
|
|
|
|
<button className={classes} tabIndex="-1" role="button" {...btnProps}>
|
|
|
|
{children}
|
|
|
|
</button>
|
|
|
|
)
|
|
|
|
}
|