Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@ module.exports = {
ecmaVersion: 'latest',
sourceType: 'module',
},
plugins: ['react', '@typescript-eslint', 'i18next', 'react-hooks'],
plugins: ['react', '@typescript-eslint', 'i18next', 'react-hooks', 'prettier'],
rules: {
'prettier/prettier': 'error',
'@typescript-eslint/consistent-type-imports': 'warn',
'react/jsx-indent': [1, 2],
'react/jsx-indent-props': [1, 2],
indent: [1, 2],
Expand All @@ -33,6 +35,13 @@ module.exports = {
'react/function-component-definition': 'off',
'no-shadow': 'off',
'import/extensions': 'off',
'import/order': [
'warn',
{
groups: ['builtin', 'external', 'internal'],
'newlines-between': 'always',
},
],
'import/no-extraneous-dependencies': 'off',
'no-underscore-dangle': 'off',
'i18next/no-literal-string': [
Expand Down
2 changes: 2 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npm run format || exit 1

if [ "$GIT_BRANCH" = "master" ]; then
npm run lint:ts
npm run lint:scss
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified .loki/reference/chrome_iphone7_features_LoginForm_Primary.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified .loki/reference/chrome_iphone7_pages_MainPage_Dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified .loki/reference/chrome_iphone7_pages_MainPage_Normal.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified .loki/reference/chrome_iphone7_pages_NotFoundPage_Dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified .loki/reference/chrome_iphone7_pages_NotFoundPage_Normal.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified .loki/reference/chrome_iphone7_shared_Input_Primary.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified .loki/reference/chrome_iphone7_shared_ThemeSwitcher_Dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified .loki/reference/chrome_iphone7_shared_ThemeSwitcher_Normal.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified .loki/reference/chrome_iphone7_widget_ErrorPage_Dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified .loki/reference/chrome_iphone7_widget_Navbar_Dark.png
Binary file modified .loki/reference/chrome_iphone7_widget_Navbar_Light.png
Binary file modified .loki/reference/chrome_iphone7_widget_Sidebar_Dark.png
Binary file modified .loki/reference/chrome_iphone7_widget_Sidebar_Light.png
Binary file modified .loki/reference/chrome_laptop_features_LoginForm_Primary.png
Binary file modified .loki/reference/chrome_laptop_pages_MainPage_Dark.png
Binary file modified .loki/reference/chrome_laptop_pages_MainPage_Normal.png
Binary file modified .loki/reference/chrome_laptop_pages_NotFoundPage_Dark.png
Binary file modified .loki/reference/chrome_laptop_pages_NotFoundPage_Normal.png
Binary file modified .loki/reference/chrome_laptop_shared_Input_Primary.png
Binary file modified .loki/reference/chrome_laptop_shared_ThemeSwitcher_Dark.png
Binary file modified .loki/reference/chrome_laptop_shared_ThemeSwitcher_Normal.png
Binary file modified .loki/reference/chrome_laptop_widget_ErrorPage_Dark.png
Diff not rendered.
Binary file modified .loki/reference/chrome_laptop_widget_Navbar_Dark.png
Binary file modified .loki/reference/chrome_laptop_widget_Navbar_Light.png
Binary file modified .loki/reference/chrome_laptop_widget_Sidebar_Dark.png
Binary file modified .loki/reference/chrome_laptop_widget_Sidebar_Light.png
1 change: 1 addition & 0 deletions .prettierrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ module.exports = {
trailingComma: 'all',
bracketSpacing: true,
arrowParens: 'always',
endOfLine: 'auto',
};
3 changes: 2 additions & 1 deletion config/build/buildDevServer.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { Configuration as DevServerConfiguration } from 'webpack-dev-server';
import { BuildOptions } from './types/config';

import type { BuildOptions } from './types/config';

export function buildDevServer(options: BuildOptions): DevServerConfiguration {
return {
Expand Down
5 changes: 3 additions & 2 deletions config/build/buildLoaders.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import webpack from 'webpack';
import type webpack from 'webpack';

import { buildCssLoader } from './loaders/buildCssLoader';
import { BuildOptions } from './types/config';
import type { BuildOptions } from './types/config';

export function buildLoaders({ isDev }: BuildOptions): webpack.RuleSetRule[] {
const svgLoader = {
Expand Down
3 changes: 2 additions & 1 deletion config/build/buildPlugins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import HtmlWebpackPlugin from 'html-webpack-plugin';
import MiniCssExtractPlugin from 'mini-css-extract-plugin';
import webpack from 'webpack';
import { BundleAnalyzerPlugin } from 'webpack-bundle-analyzer';
import { BuildOptions } from './types/config';

import type { BuildOptions } from './types/config';

export function buildPlugins({ paths, isDev }: BuildOptions): webpack.WebpackPluginInstance[] {
const plugins = [
Expand Down
5 changes: 3 additions & 2 deletions config/build/buildResolvers.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { ResolveOptions } from 'webpack';
import { BuildOptions } from './types/config';
import type { ResolveOptions } from 'webpack';

import type { BuildOptions } from './types/config';

export function buildResolvers(options: BuildOptions): ResolveOptions {
return {
Expand Down
5 changes: 3 additions & 2 deletions config/build/buildWebpackConfig.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import webpack from 'webpack';
import type webpack from 'webpack';

import { buildDevServer } from './buildDevServer';
import { buildLoaders } from './buildLoaders';
import { buildPlugins } from './buildPlugins';
import { buildResolvers } from './buildResolvers';
import { BuildOptions } from './types/config';
import type { BuildOptions } from './types/config';

export function buildWebpackConfig(options: BuildOptions): webpack.Configuration {
const { paths, mode, isDev } = options;
Expand Down
25 changes: 15 additions & 10 deletions config/storybook/main.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
module.exports = {
stories: ['../../src/**/*.stories.@(js|jsx|ts|tsx)'],
addons: [
'@storybook/addon-links',
'@storybook/addon-essentials',
'@storybook/addon-interactions',
],
framework: '@storybook/react',
core: {
builder: 'webpack5',
},
stories: ['../../src/**/*.stories.@(js|jsx|ts|tsx)'],
addons: [
'@storybook/addon-links',
'@storybook/addon-essentials',
'@storybook/addon-interactions',
],
framework: '@storybook/react',
core: {
builder: 'webpack5',
},
staticDirs: ['../../public'],
previewHead: (head) => `
${head}
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@20..48,100..700,0..1,-50..200&amp;display=swap" />
`,
};
21 changes: 12 additions & 9 deletions config/storybook/preview.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
import { addDecorator } from '@storybook/react';
import { StyleDecorator } from '../../src/shared/config/storybook/StyleDecorator/StyleDecorator';
import { ThemeDecorator } from '../../src/shared/config/storybook/ThemeDecorator/ThemeDecorator';

import { Theme } from '../../src/app/providers/ThemeProvider';
import { RouterDecorator } from '../../src/shared/config/storybook/RouterDecorator/RouterDecorator';
import { StyleDecorator } from '../../src/shared/config/storybook/StyleDecorator/StyleDecorator';
import { SuspenseDecorator } from '../../src/shared/config/storybook/SuspenseDecorator/SuspenseDecorator';
import { ThemeDecorator } from '../../src/shared/config/storybook/ThemeDecorator/ThemeDecorator';

export const parameters = {
actions: { argTypesRegex: '^on[A-Z].*' },
controls: {
matchers: {
color: /(background|color)$/i,
date: /Date$/,
},
},
actions: { argTypesRegex: '^on[A-Z].*' },
controls: {
matchers: {
color: /(background|color)$/i,
date: /Date$/,
},
},
};

addDecorator(SuspenseDecorator);
addDecorator(StyleDecorator);
addDecorator(ThemeDecorator(Theme.LIGHT));
addDecorator(RouterDecorator);
28 changes: 18 additions & 10 deletions config/storybook/webpack.config.ts
Original file line number Diff line number Diff line change
@@ -1,32 +1,40 @@
import webpack, { RuleSetRule } from 'webpack';
import path from 'path';

import type { Configuration } from 'webpack';
import { DefinePlugin } from 'webpack';

import { buildCssLoader } from '../build/loaders/buildCssLoader';
import { BuildPaths } from '../build/types/config';
import type { BuildPaths } from '../build/types/config';

export default ({ config }: { config: webpack.Configuration }) => {
export default ({ config }: { config: Configuration }) => {
const paths: BuildPaths = {
build: '',
html: '',
entry: '',
src: path.resolve(__dirname, '..', '..', 'src'),
};
config.resolve.modules.push(paths.src);
config.resolve.extensions.push('.ts', '.tsx');
config.resolve!.modules!.push(paths.src);
config.resolve!.extensions!.push('.ts', '.tsx');

// eslint-disable-next-line no-param-reassign
config.module.rules = config.module.rules.map((rule: RuleSetRule) => {
if (/svg/.test(rule.test as string)) {
config.module!.rules = config.module!.rules!.map((rule) => {
if (rule && typeof rule === 'object' && rule.test && /svg/.test(rule.test as string)) {
return { ...rule, exclude: /\.svg$/i };
}

return rule;
});

config.module.rules.push({
config.module!.rules.push({
test: /\.svg$/,
use: ['@svgr/webpack'],
});
config.module.rules.push(buildCssLoader(true));
config.module!.rules.push(buildCssLoader(true));

config.plugins!.push(
new DefinePlugin({
__IS_DEV__: true,
}),
);

return config;
};
12 changes: 11 additions & 1 deletion extractedTranslations/en/translation.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,19 @@
{
"Loading": {
"": {
"": {
"": ""
}
}
},
"throw error": "throw error",
"Авторизация": "",
"Введите username": "Введите username",
"Введите пароль": "Введите пароль",
"Войти": "",
"Войти": "Войти",
"Войти": "Login",
"Вы ввели неверный логин или пароль": "",
"Выйти": "Выйти",
"Главная": "Главная",
"Главная страница": "Главная страница",
"Короткий язык": "Короткий язык",
Expand Down
3 changes: 3 additions & 0 deletions extractedTranslations/ru/translation.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
{
"throw error": "throw error",
"Авторизация": "Авторизация",
"Введите username": "Введите username",
"Введите пароль": "Введите пароль",
"Войти": "Войти",
"Войти": "Войти",
"Вы ввели неверный логин или пароль": "Вы ввели неверный логин или пароль",
"Выйти": "Выйти",
"Главная": "Главная",
"Главная страница": "Главная страница",
"Короткий язык": "Короткий язык",
Expand Down
54 changes: 27 additions & 27 deletions json-server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,47 +12,47 @@ server.use(jsonServer.bodyParser);

// Нужно для небольшой задержки, чтобы запрос проходил не мгновенно, имитация реального апи
server.use(async (req, res, next) => {
await new Promise((res) => {
setTimeout(res, 800);
});
next();
await new Promise((resolve) => {
setTimeout(resolve, 800);
});
next();
});

// Эндпоинт для логина
server.post('/login', (req, res) => {
try {
const { username, password } = req.body;
const db = JSON.parse(fs.readFileSync(path.resolve(__dirname, 'db.json'), 'UTF-8'));
const { users = [] } = db;

const userFromBd = users.find(
(user) => user.username === username && user.password === password,
);

if (userFromBd) {
return res.json(userFromBd);
}

return res.status(403).json({ message: 'User not found' });
} catch (e) {
console.log(e);
return res.status(500).json({ message: e.message });
}
try {
const { username, password } = req.body;
const db = JSON.parse(fs.readFileSync(path.resolve(__dirname, 'db.json'), 'UTF-8'));
const { users = [] } = db;

const userFromBd = users.find(
(user) => user.username === username && user.password === password,
);

if (userFromBd) {
return res.json(userFromBd);
}

return res.status(403).json({ message: 'User not found' });
} catch (e) {
console.log(e);
return res.status(500).json({ message: e.message });
}
});

// проверяем, авторизован ли пользователь
// eslint-disable-next-line
server.use((req, res, next) => {
if (!req.headers.authorization) {
return res.status(403).json({ message: 'AUTH ERROR' });
}
if (!req.headers.authorization) {
return res.status(403).json({ message: 'AUTH ERROR' });
}

next();
next();
});

server.use(router);

// запуск сервера
server.listen(8000, () => {
console.log('server is running on 8000 port');
console.log('server is running on 8000 port');
});
Loading
Loading