import { PageWrap } from '../../_shared/PageWrap' import { t } from '../../../utils/intl' import type { PageProps } from '../../types' import { Icon } from '../../_shared/Icon' import ProfileSettingsNavigation from '../../Discours/ProfileSettingsNavigation' import { For, createSignal, Show, onMount } from 'solid-js' import { clsx } from 'clsx' import styles from './Settings.module.scss' import { useProfileForm } from '../../../context/profile' import { createFileUploader } from '@solid-primitives/upload' import validateUrl from '../../../utils/validateUrl' export const ProfileSettingsPage = (props: PageProps) => { const [addLinkForm, setAddLinkForm] = createSignal(false) const [incorrectUrl, setIncorrectUrl] = createSignal(false) const { form, updateFormField, submit, error } = useProfileForm() const handleChangeSocial = (value) => { if (validateUrl(value)) { updateFormField('links', value) setAddLinkForm(false) } else { setIncorrectUrl(true) } } const handleSubmit = (event: Event): void => { event.preventDefault() submit(form) } const { files, selectFiles: selectFilesAsync } = createFileUploader({ accept: 'image/*' }) const handleUpload = () => { selectFilesAsync(async ([{ source, name, size, file }]) => { const image = { source, name, size, file } try { const formData = new FormData() formData.append('type', file.type) formData.append('name', image.source.split('/').pop()) formData.append('ext', image.name.split('.').pop()) const resp = await fetch('/api/upload', { method: 'POST', body: formData }) const url = await resp.json() updateFormField('userpic', url) } catch (error) { console.error('[upload] error', error) } }) } const [hostname, setHostname] = createSignal('new.discours.io') onMount(() => setHostname(window?.location.host)) return (

{t('Profile settings')}

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

{t('Userpic')}

{form.name}

{t('Name')}

{t( 'Your name will appear on your profile page and as your signature in publications, comments and responses.' )}

updateFormField('name', event.currentTarget.value)} value={form.name} />

{t('Address on Discourse')}

updateFormField('slug', event.currentTarget.value)} value={form.slug} class="nolabel" />

{t(`error()`)}

{t('Introduce')}

{/*Нет реализации полей на бэке*/} {/*

{t('About myself')}

*/} {/*
*/} {/* updateFormField('about', event.currentTarget.value)}*/} {/* />*/} {/* */} {/*
*/} {/*

{t('How can I help/skills')}

*/} {/*
*/} {/* */} {/*
*/} {/*

{t('Where')}

*/} {/*
*/} {/* */} {/* */} {/*
*/} {/*

{t('Date of Birth')}

*/} {/*
*/} {/* */} {/*
*/}

{t('Social networks')}

handleChangeSocial(event.currentTarget.value)} />

{t('It does not look like url')}

{(link) => (
)}

) } // for lazy loading export default ProfileSettingsPage