diff --git a/src/components/Pages/profile/ProfileSettingsPage.tsx b/src/components/Pages/profile/ProfileSettingsPage.tsx index 556ab1a6..d9e8d200 100644 --- a/src/components/Pages/profile/ProfileSettingsPage.tsx +++ b/src/components/Pages/profile/ProfileSettingsPage.tsx @@ -3,34 +3,25 @@ import { t } from '../../../utils/intl' import type { PageProps } from '../../types' import { Icon } from '../../_shared/Icon' import ProfileSettingsNavigation from '../../Discours/ProfileSettingsNavigation' -import { useSession } from '../../../context/session' -import { createMemo, For, createSignal, Show, createEffect } from 'solid-js' -import { loadAuthor, useAuthorsStore } from '../../../stores/zine/authors' -import type { Author } from '../../../graphql/types.gen' +import { For, createSignal, Show } from 'solid-js' import { clsx } from 'clsx' import styles from './Settings.module.scss' +import { useProfileForm } from '../../../context/profile' export const ProfileSettingsPage = (props: PageProps) => { - const [author, setAuthor] = createSignal(null) - const { session } = useSession() - const currentSlug = createMemo(() => session()?.user?.slug) - const { authorEntities } = useAuthorsStore({ authors: [] }) - const currentAuthor = createMemo(() => authorEntities()[currentSlug()]) - - createEffect(async () => { - if (!currentSlug()) return - try { - await loadAuthor({ slug: currentSlug() }) - setAuthor(currentAuthor()) - console.log('!!! currentAuthor:', currentAuthor()) - } catch (error) { - console.error(error) - } - }) - + const [addLinkForm, setAddLinkForm] = createSignal(false) + const { form, updateFormField, submit } = useProfileForm() + const handleChangeSocial = (value) => { + updateFormField('links', value) + setAddLinkForm(false) + } + const handleSubmit = (event: Event): void => { + event.preventDefault() + submit(form) + } return ( - +
@@ -42,11 +33,11 @@ export const ProfileSettingsPage = (props: PageProps) => {

{t('Profile settings')}

{t('Here you can customize your profile the way you want.')}

-
+

{t('Userpic')}

- + {form.name} { />
-

{t('Name')}

{t( @@ -67,8 +57,9 @@ export const ProfileSettingsPage = (props: PageProps) => { type="text" name="username" id="username" - placeholder="Имя" - value={author().name} + placeholder={t('Name')} + onChange={(event) => updateFormField('name', event.currentTarget.value)} + value={form.name} />

@@ -82,7 +73,8 @@ export const ProfileSettingsPage = (props: PageProps) => { type="text" name="user-address" id="user-address" - value={currentSlug()} + onChange={(event) => updateFormField('slug', event.currentTarget.value)} + value={form.slug} class="nolabel" />

@@ -92,52 +84,70 @@ export const ProfileSettingsPage = (props: PageProps) => {

-

{t('Introduce')}

-
- +