diff --git a/backend/src/config/mailer.config.ts b/backend/src/config/mailer.config.ts index 3ede4801..e0b02655 100644 --- a/backend/src/config/mailer.config.ts +++ b/backend/src/config/mailer.config.ts @@ -5,10 +5,10 @@ const configFromName = (transportUrl) => { const parts = transportUrl.replace('smtp://', '').split(':'); const [emailName, otherInfo] = parts; const domain = otherInfo.split('.'); - const [,domName, dom] = domain; + const [, domName, dom] = domain; - return `${emailName}@${domName}.${dom}` -} + return `${emailName}@${domName}.${dom}`; +}; export class MailerConfig implements MailerOptionsFactory { /* eslint-disable-next-line class-methods-use-this */ @@ -17,7 +17,9 @@ export class MailerConfig implements MailerOptionsFactory { const options: MailerOptions = { transport: transportUrl, defaults: { - from: `"Run IT" <${transportUrl ? configFromName(transportUrl) : "test"}>`, + from: `"Run IT" <${ + transportUrl ? configFromName(transportUrl) : 'test' + }>`, }, template: { dir: `${process.cwd()}/src/users/templates`, @@ -32,9 +34,9 @@ export class MailerConfig implements MailerOptionsFactory { case 'production': return options; default: - options.transport = - process.env.TRANSPORT_MAILER_URL ?? - { jsonTransport: true } + options.transport = process.env.TRANSPORT_MAILER_URL ?? { + jsonTransport: true, + }; options.preview = true; return options; } diff --git a/backend/src/users/users.service.ts b/backend/src/users/users.service.ts index 6d2dd2c6..b2151ab2 100644 --- a/backend/src/users/users.service.ts +++ b/backend/src/users/users.service.ts @@ -2,6 +2,7 @@ /* eslint-disable no-param-reassign */ /* eslint-disable class-methods-use-this */ +import { mkdirSync, openSync, appendFileSync } from 'fs'; import { Injectable } from '@nestjs/common'; import { InjectRepository } from '@nestjs/typeorm'; import { ILike, Repository } from 'typeorm'; @@ -13,7 +14,6 @@ import { Snippets } from '../entities/snippet.entity'; import { User } from './interfaces/users.interface'; import { RecoverUserDto } from './dto/recover-user.dto'; import { cipher, decipher } from './secure/cipher'; -import { mkdirSync, openSync, appendFileSync } from 'fs'; @Injectable() export class UsersService { @@ -76,23 +76,27 @@ export class UsersService { const url = `${frontendUrl}/recovery/${recoverHash}`; try { - this.mailerService.sendMail({ - to: email, - // FIXME: use i18n - subject: 'Ссылка для изменения пароля на runit.hexlet.ru', - template: 'recover', - context: { - url, - }, - }) - .then((data) => { - if (process.env.NODE_ENV !== "production" && !process.env.TRANSPORT_MAILER_URL) { - const logsDirName = process.env.LOGS_PATH ?? 'logs'; - mkdirSync(logsDirName, { recursive: true }); - openSync(`${logsDirName}/mail.log`, 'a'); - appendFileSync(`${logsDirName}/mail.log`, `${data.message}\n`); - } - }); + this.mailerService + .sendMail({ + to: email, + // FIXME: use i18n + subject: 'Ссылка для изменения пароля на runit.hexlet.ru', + template: 'recover', + context: { + url, + }, + }) + .then((data) => { + if ( + process.env.NODE_ENV !== 'production' && + !process.env.TRANSPORT_MAILER_URL + ) { + const logsDirName = process.env.LOGS_PATH ?? 'logs'; + mkdirSync(logsDirName, { recursive: true }); + openSync(`${logsDirName}/mail.log`, 'a'); + appendFileSync(`${logsDirName}/mail.log`, `${data.message}\n`); + } + }); } catch (e) { throw new Error(e); } diff --git a/frontend/src/components/ActionsToolbar/index.jsx b/frontend/src/components/ActionsToolbar/index.jsx new file mode 100644 index 00000000..ad3a0910 --- /dev/null +++ b/frontend/src/components/ActionsToolbar/index.jsx @@ -0,0 +1,19 @@ +import { useSelector } from 'react-redux'; +import { + DistributeHorizontal, + DistributeVertical, +} from 'react-bootstrap-icons'; + +function DisplayIconView() { + const { direction } = useSelector((state) => state.editor); + switch (direction) { + case 'horizontal': + return ; + case 'vertical': + return ; + default: + return ; + } +} + +export default DisplayIconView; diff --git a/frontend/src/pages/snippet/ActionsToolbar.jsx b/frontend/src/pages/snippet/ActionsToolbar.jsx index a0c43b02..e158f4b3 100644 --- a/frontend/src/pages/snippet/ActionsToolbar.jsx +++ b/frontend/src/pages/snippet/ActionsToolbar.jsx @@ -1,11 +1,12 @@ import { useTranslation } from 'react-i18next'; -import { useDispatch } from 'react-redux'; +import { useDispatch, useSelector } from 'react-redux'; import Button from 'react-bootstrap/Button'; import Col from 'react-bootstrap/Col'; import { BoxArrowUp, Files, PlayFill } from 'react-bootstrap-icons'; import { toast } from 'react-toastify'; import { actions } from '../../slices'; +import DisplayIconView from '../../components/ActionsToolbar/index.jsx'; import { useAuth, useRunButton, useSaveButton } from '../../hooks'; import 'react-toastify/dist/ReactToastify.css'; @@ -17,7 +18,7 @@ function ActionsToolbar({ snippet }) { const { snippetData, code, isAllSaved } = snippet; const { name: snippetName, ownerUsername } = snippetData; const { isLoggedIn } = useAuth(); - + const { direction } = useSelector((state) => state.editor); const handleShare = () => { dispatch( actions.openModal({ @@ -61,8 +62,25 @@ function ActionsToolbar({ snippet }) { toast.error(t('toasts.saveCode.error')); }; + const handleView = () => { + if (direction === 'horizontal') { + dispatch(actions.updateDirection('vertical')); + return; + } + if (direction === 'vertical') { + dispatch(actions.updateDirection('horizontal')); + } + }; + return ( +