refactored
All checks were successful
deploy / test (push) Successful in 2m10s
deploy / Update templates on Mailgun (push) Has been skipped

This commit is contained in:
Untone 2024-02-06 18:02:57 +03:00
parent bafe35cb0e
commit a664c8f6cb
7 changed files with 17 additions and 25 deletions

View File

@ -143,7 +143,7 @@
"Enter your new password": "Enter your new password",
"Enter": "Enter",
"Error": "Error",
"Everything is ok, please give us your email address": "It's okay, just enter your email address to receive a password reset link.",
"Please give us your email address": "Please provide us your email address to get the password reset link",
"Experience": "Experience",
"FAQ": "Tips and suggestions",
"Favorite topics": "Favorite topics",
@ -157,7 +157,6 @@
"Follow": "Follow",
"Followers": "Followers",
"Following": "Following",
"Forgot password?": "Forgot your password?",
"Forward": "Forward",
"Full name": "First and last name",
"Gallery name": "Gallery name",
@ -308,7 +307,6 @@
"Reports": "Reports",
"Required": "Required",
"Resend code": "Send confirmation",
"Restore password": "Restore password",
"Rules of the journal Discours": "Rules of the journal Discours",
"Save draft": "Save draft",
"Save settings": "Save settings",

View File

@ -150,7 +150,7 @@
"Enter your new password": "Введите новый пароль",
"Enter": "Войти",
"Error": "Ошибка",
"Everything is ok, please give us your email address": "Ничего страшного, просто укажите свою почту, чтобы получить ссылку для сброса пароля.",
"Please give us your email address": "Пожалуйста, укажите свою почту, чтобы получить ссылку для сброса пароля",
"Experience": "Личный опыт",
"FAQ": "Советы и предложения",
"Favorite topics": "Избранные темы",
@ -164,7 +164,6 @@
"Follow": "Подписаться",
"Followers": "Подписчики",
"Following": "Вы подписаны",
"Forgot password?": "Забыли пароль?",
"Forward": "Переслать",
"Full name": "Имя и фамилия",
"Gallery name": "Название галереи",
@ -327,7 +326,7 @@
"Reports": "Репортажи",
"Required": "Поле обязательно для заполнения",
"Resend code": "Выслать подтверждение",
"Restore password": "Восстановить пароль",
"Set the new password": "Задать новый пароль",
"Rules of the journal Discours": "Правила журнала Дискурс",
"Save draft": "Сохранить черновик",
"Save settings": "Сохранить настройки",
@ -343,7 +342,6 @@
"Self-publishing exists thanks to the help of wonderful people from all over the world. Thank you!": "Самиздат существуют благодаря помощи замечательных людей со всего мира. Спасибо Вам!",
"Send link again": "Прислать ссылку ещё раз",
"Send": "Отправить",
"Set the new password": "Задать новый пароль",
"Settings": "Настройки",
"Share publication": "Поделиться публикацией",
"Share": "Поделиться",

View File

@ -55,7 +55,7 @@ export const LoginForm = () => {
setIsLinkSent(true)
setIsEmailNotConfirmed(false)
setSubmitError('')
changeSearchParams({ mode: 'forgot-password' })
changeSearchParams({ mode: 'send-reset-link' })
// NOTE: temporary solution, needs logic in authorizer
/* FIXME:
const { authorizer } = useSession()
@ -172,7 +172,7 @@ export const LoginForm = () => {
class="link"
onClick={() =>
changeSearchParams({
mode: 'forgot-password',
mode: 'send-reset-link',
})
}
>

View File

@ -187,17 +187,16 @@ export const RegisterForm = () => {
onBlur={handleEmailBlur}
/>
<label for="email">{t('Email')}</label>
<div class={styles.validationError}>{validationErrors().email}</div>
<Show when={Boolean(emailStatus())}>
{t('This email is')} {emailStatus() ? t(emailStatus()) : ''},{' '}
</Show>
<Show when={emailStatus() === 'verfied'}>
{t('This email is')} {t(emailStatus())},{' '}
<span class="link" onClick={() => changeSearchParams({ mode: 'login' })}>
{t('enter')}
</span>
</Show>
<Show when={emailStatus() === 'not verfied'}>
{t('This email is')} {t(emailStatus())},{' '}
<span
class="link"
onClick={() => resendVerifyEmail({ email: email(), identifier: 'basic_signup' })}
@ -206,12 +205,11 @@ export const RegisterForm = () => {
</span>
</Show>
<Show when={emailStatus() === 'registered'}>
{t('This email is')} {t(emailStatus())},{' '}
<span
class="link"
onClick={() =>
changeSearchParams({
mode: 'forgot-password',
mode: 'send-reset-link',
})
}
>

View File

@ -18,7 +18,7 @@ type FormFields = {
type ValidationErrors = Partial<Record<keyof FormFields, string | JSX.Element>>
export const ForgotPasswordForm = () => {
export const SendResetLinkForm = () => {
const { changeSearchParams } = useRouter<AuthModalSearchParams>()
const { t } = useLocalize()
const handleEmailInput = (newEmail: string) => {
@ -60,7 +60,7 @@ export const ForgotPasswordForm = () => {
email: email(),
redirect_uri: window.location.origin,
})
console.debug('[ForgotPasswordForm] authorizer response:', data)
console.debug('[SendResetLinkForm] authorizer response:', data)
if (errors?.some((error) => error.message.includes('bad user credentials'))) {
setIsUserNotFound(true)
}
@ -79,10 +79,8 @@ export const ForgotPasswordForm = () => {
ref={(el) => (authFormRef.current = el)}
>
<div>
<h4>{t('Restore password')}</h4>
<div class={styles.authSubtitle}>
{t(message()) || t('Everything is ok, please give us your email address')}
</div>
<h4>{t('Set the new password')}</h4>
<div class={styles.authSubtitle}>{t(message()) || t('Please give us your email address')}</div>
<div
class={clsx('pretty-form__item', {
'pretty-form__item--error': validationErrors().email,
@ -126,7 +124,7 @@ export const ForgotPasswordForm = () => {
disabled={isSubmitting() || Boolean(message())}
type="submit"
>
{isSubmitting() ? '...' : t('Restore password')}
{isSubmitting() ? '...' : t('Send')}
</button>
</div>
<div class={styles.authControl}>

View File

@ -11,16 +11,16 @@ import { isMobile } from '../../../utils/media-query'
import { ChangePasswordForm } from './ChangePasswordForm'
import { EmailConfirm } from './EmailConfirm'
import { ForgotPasswordForm } from './ForgotPasswordForm'
import { LoginForm } from './LoginForm'
import { RegisterForm } from './RegisterForm'
import { SendResetLinkForm } from './SendResetLinkForm'
import styles from './AuthModal.module.scss'
const AUTH_MODAL_MODES: Record<AuthModalMode, Component> = {
login: LoginForm,
register: RegisterForm,
'forgot-password': ForgotPasswordForm,
'send-reset-link': SendResetLinkForm,
'confirm-email': EmailConfirm,
'change-password': ChangePasswordForm,
}

View File

@ -1,4 +1,4 @@
export type AuthModalMode = 'login' | 'register' | 'confirm-email' | 'forgot-password' | 'change-password'
export type AuthModalMode = 'login' | 'register' | 'confirm-email' | 'send-reset-link' | 'change-password'
export type AuthModalSource =
| 'discussions'
| 'vote'