diff --git a/public/locales/en/translation.json b/public/locales/en/translation.json index 336a8237..62db14b5 100644 --- a/public/locales/en/translation.json +++ b/public/locales/en/translation.json @@ -405,6 +405,7 @@ "Upload userpic": "Upload userpic", "Upload video": "Upload video", "Uploading image": "Uploading image", + "User with this email already exists": "User with this email already exists", "Username": "Username", "Userpic": "Userpic", "Users": "Users", diff --git a/public/locales/ru/translation.json b/public/locales/ru/translation.json index a06c7c81..b90b3abb 100644 --- a/public/locales/ru/translation.json +++ b/public/locales/ru/translation.json @@ -427,6 +427,7 @@ "Upload userpic": "Загрузить аватар", "Upload video": "Загрузить видео", "Uploading image": "Загружаем изображение", + "User with this email already exists": "Пользователь с таким email уже существует", "Username": "Имя пользователя", "Userpic": "Аватар", "Users": "Пользователи", diff --git a/src/components/App.tsx b/src/components/App.tsx index d04fef14..cef8c3f9 100644 --- a/src/components/App.tsx +++ b/src/components/App.tsx @@ -93,11 +93,11 @@ export const App = (props: Props) => { let is404 = props.is404 createEffect(() => { - if (!searchParams().modal) { + if (!searchParams().m) { hideModal() } - const modal = MODALS[searchParams().modal] + const modal = MODALS[searchParams().m] if (modal) { showModal(modal) } diff --git a/src/components/Article/CommentsTree.tsx b/src/components/Article/CommentsTree.tsx index b0bb86f4..436b5988 100644 --- a/src/components/Article/CommentsTree.tsx +++ b/src/components/Article/CommentsTree.tsx @@ -172,11 +172,11 @@ export const CommentsTree = (props: Props) => { fallback={
{t('To write a comment, you must')}{' '} - + {t('sign up')} {' '} {t('or')}  - + {t('sign in')}
diff --git a/src/components/AuthGuard/AuthGuard.tsx b/src/components/AuthGuard/AuthGuard.tsx index a7ef1ff8..86b10f95 100644 --- a/src/components/AuthGuard/AuthGuard.tsx +++ b/src/components/AuthGuard/AuthGuard.tsx @@ -26,7 +26,7 @@ export const AuthGuard = (props: Props) => { changeSearchParams( { source: 'authguard', - modal: 'auth', + m: 'auth', }, true, ) diff --git a/src/components/Author/AuthorCard/AuthorCard.tsx b/src/components/Author/AuthorCard/AuthorCard.tsx index f8100e00..587dd564 100644 --- a/src/components/Author/AuthorCard/AuthorCard.tsx +++ b/src/components/Author/AuthorCard/AuthorCard.tsx @@ -142,7 +142,7 @@ export const AuthorCard = (props: Props) => { >
0}> - + {(f) => ( @@ -155,7 +155,7 @@ export const AuthorCard = (props: Props) => { 0}> - + {(f) => { if ('name' in f) { diff --git a/src/components/Nav/AuthModal/LoginForm.tsx b/src/components/Nav/AuthModal/LoginForm.tsx index 014f8bcf..7e2b1de7 100644 --- a/src/components/Nav/AuthModal/LoginForm.tsx +++ b/src/components/Nav/AuthModal/LoginForm.tsx @@ -66,7 +66,7 @@ export const LoginForm = () => { setIsEmailNotConfirmed(false) setSubmitError('') changeSearchParams({ mode: 'forgot-password' }) - // NOTE: temporary solition, needs logix in authorizer + // NOTE: temporary solution, needs logic in authorizer /* FIXME: const { actions: { authorizer } } = useSession() const result = await authorizer().verifyEmail({ token }) @@ -140,9 +140,9 @@ export const LoginForm = () => {
{submitError()}
-
+ {t('Send link again')} - +
@@ -169,7 +169,7 @@ export const LoginForm = () => {
- handlePasswordInput(value)} /> + handlePasswordInput(value)} />
- +
{error()}
diff --git a/src/components/Nav/AuthModal/RegisterForm.tsx b/src/components/Nav/AuthModal/RegisterForm.tsx index 7ce83e3e..24d1477d 100644 --- a/src/components/Nav/AuthModal/RegisterForm.tsx +++ b/src/components/Nav/AuthModal/RegisterForm.tsx @@ -118,13 +118,29 @@ export const RegisterForm = () => { setIsSuccess(true) } catch (error) { console.error(error) - - // TODO: move to context/session - if (error?.code === 'user_already_exists') { - return + if (error) { + if (error.message.includes('has already signed up')) { + setValidationErrors((errors) => ({ + ...errors, + email: ( + <> + {t('User with this email already exists')},{' '} + + changeSearchParams({ + mode: 'login', + }) + } + > + {t('sign in')} + + + ), + })) + } + console.error(error) } - - setSubmitError(error.message) } finally { setIsSubmitting(false) } @@ -138,9 +154,7 @@ export const RegisterForm = () => {
-
    -
  • {submitError()}
  • -
+
{submitError()}
{ when={isAuthenticatedControlsVisible()} fallback={
- + {t('Enter')} {/**/} diff --git a/src/components/Nav/ProfilePopup.tsx b/src/components/Nav/ProfilePopup.tsx index 56f1a5e3..736a763a 100644 --- a/src/components/Nav/ProfilePopup.tsx +++ b/src/components/Nav/ProfilePopup.tsx @@ -29,7 +29,7 @@ export const ProfilePopup = (props: ProfilePopupProps) => { {t('Drafts')}
  • - + {t('Subscriptions')}
  • diff --git a/src/components/_shared/InviteMembers/InviteMembers.tsx b/src/components/_shared/InviteMembers/InviteMembers.tsx index 62940bde..87979810 100644 --- a/src/components/_shared/InviteMembers/InviteMembers.tsx +++ b/src/components/_shared/InviteMembers/InviteMembers.tsx @@ -41,7 +41,9 @@ export const InviteMembers = (props: Props) => { ] const { sortedAuthors } = useAuthorsStore({ sortBy: 'name' }) - const { actions } = useInbox() + const { + actions: { loadChats, createChat }, + } = useInbox() const [authorsToInvite, setAuthorsToInvite] = createSignal() const [searchResultAuthors, setSearchResultAuthors] = createSignal() @@ -99,10 +101,10 @@ export const InviteMembers = (props: Props) => { const handleCreate = async () => { try { - const initChat = await actions.createChat(collectionToInvite(), 'chat Title') + const initChat = await createChat(collectionToInvite(), 'chat Title') console.debug('[components.Inbox] create chat result:', initChat) hideModal() - await actions.loadChats() + await loadChats() } catch (error) { console.error('handleCreate chat', error) } diff --git a/src/pages/types.ts b/src/pages/types.ts index 627b5bda..c54208c1 100644 --- a/src/pages/types.ts +++ b/src/pages/types.ts @@ -23,7 +23,7 @@ export type PageProps = { } export type RootSearchParams = { - modal: string + m: string // modal lang: string } diff --git a/src/stores/router.ts b/src/stores/router.ts index a9409c68..be197bd1 100644 --- a/src/stores/router.ts +++ b/src/stores/router.ts @@ -152,9 +152,14 @@ export const useRouter = = Record< searchParamsStore.open(newSearchParams, replace) } + const clearSearchParams = (replace = false) => { + searchParamsStore.open({}, replace) + } + return { page, searchParams, changeSearchParams, + clearSearchParams, } } diff --git a/src/stores/ui.ts b/src/stores/ui.ts index 4c8fadc1..039176d4 100644 --- a/src/stores/ui.ts +++ b/src/stores/ui.ts @@ -46,7 +46,7 @@ export const MODALS: Record = { const [modal, setModal] = createSignal(null) -const { changeSearchParams } = useRouter< +const { changeSearchParams, clearSearchParams } = useRouter< AuthModalSearchParams & ConfirmEmailSearchParams & RootSearchParams >() @@ -60,7 +60,10 @@ export const showModal = (modalType: ModalType, modalSource?: AuthModalSource) = setModal(modalType) } -export const hideModal = () => setModal(null) +export const hideModal = () => { + clearSearchParams() + setModal(null) +} export const useModalStore = () => { return {