Skip to content

Commit

Permalink
formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
addfs committed Jul 18, 2024
1 parent 047aa62 commit c3b772e
Show file tree
Hide file tree
Showing 37 changed files with 609 additions and 625 deletions.
4 changes: 2 additions & 2 deletions frontend/microfrontend/auth_app/build/webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
const { merge } = require("webpack-merge");
const {merge} = require("webpack-merge");

const commonConfig = require("./webpack.common.js");

module.exports = ({ env }) => {
module.exports = ({env}) => {
const envConfig = require(`./webpack.${env}.js`);

return merge(commonConfig, envConfig);
Expand Down
2 changes: 1 addition & 1 deletion frontend/microfrontend/auth_app/build/webpack.dev.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { DefinePlugin } = require("webpack");
const {DefinePlugin} = require("webpack");

module.exports = {
mode: "development",
Expand Down
2 changes: 1 addition & 1 deletion frontend/microfrontend/auth_app/build/webpack.prod.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { DefinePlugin } = require("webpack");
const {DefinePlugin} = require("webpack");

module.exports = {
mode: "production",
Expand Down
2 changes: 1 addition & 1 deletion frontend/microfrontend/auth_app/src/bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ import './index.css';
import App from './components/App';

ReactDOM.createRoot(document.getElementById('root')).render(
<App />,
<App/>,
);
3 changes: 2 additions & 1 deletion frontend/microfrontend/auth_app/src/components/App.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import React from "react";

const Shell = React.lazy(() => import('mesto/App'));

function App() {
return (
<React.Suspense fallback={<div>Загрузка ... </div>}>
<Shell />
<Shell/>
</React.Suspense>
);
}
Expand Down
4 changes: 2 additions & 2 deletions frontend/microfrontend/auth_app/src/components/Auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ function Auth() {
.checkToken(token)
.then((res) => {
const customEvent = new CustomEvent(
'userLogged', {detail: { email: res.data.email, isLoggedIn: true } }
'userLogged', {detail: {email: res.data.email, isLoggedIn: true}}
);
window.dispatchEvent(customEvent)

Expand Down Expand Up @@ -51,7 +51,7 @@ function Auth() {
.login(email, password)
.then((res) => {
const customEvent = new CustomEvent(
'userLogged', {detail: { email: email, isLoggedIn: true } }
'userLogged', {detail: {email: email, isLoggedIn: true}}
);
window.dispatchEvent(customEvent)
history.push("/");
Expand Down
4 changes: 2 additions & 2 deletions frontend/microfrontend/auth_app/src/components/HeaderAuth.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import React from 'react';
import {Link, Route} from 'react-router-dom';

export default function HeaderAuth({email}) {
function handleSignOut(){
function handleSignOut() {
localStorage.removeItem("jwt");
const customEvent = new CustomEvent(
'userLogged', {detail: { email: '', isLoggedIn: false } }
'userLogged', {detail: {email: '', isLoggedIn: false}}
);
window.dispatchEvent(customEvent)
}
Expand Down
32 changes: 16 additions & 16 deletions frontend/microfrontend/auth_app/src/components/InfoTooltip.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,23 @@ import React from 'react';
import SuccessIcon from '../images/success-icon.svg';
import ErrorIcon from '../images/error-icon.svg';

function InfoTooltip({ isOpen, onClose, status }) {
const icon = status === 'success' ? SuccessIcon : ErrorIcon
const text = status === 'success' ? "Вы успешно зарегистрировались" :
"Что-то пошло не так! Попробуйте ещё раз."
return (
<div className={`popup ${isOpen && 'popup_is-opened'}`}>
<div className="popup__content">
<form className="popup__form" noValidate>
<button type="button" className="popup__close" onClick={onClose}></button>
<div>
<img className="popup__icon" src={icon} alt=""/>
<p className="popup__status-message">{text}</p>
function InfoTooltip({isOpen, onClose, status}) {
const icon = status === 'success' ? SuccessIcon : ErrorIcon
const text = status === 'success' ? "Вы успешно зарегистрировались" :
"Что-то пошло не так! Попробуйте ещё раз."
return (
<div className={`popup ${isOpen && 'popup_is-opened'}`}>
<div className="popup__content">
<form className="popup__form" noValidate>
<button type="button" className="popup__close" onClick={onClose}></button>
<div>
<img className="popup__icon" src={icon} alt=""/>
<p className="popup__status-message">{text}</p>
</div>
</form>
</div>
</form>
</div>
</div>
);
</div>
);
}

export default InfoTooltip;
Expand Down
19 changes: 0 additions & 19 deletions frontend/microfrontend/auth_app/src/components/Login.js
Original file line number Diff line number Diff line change
@@ -1,30 +1,11 @@
import React from 'react';

import {useHistory} from 'react-router-dom';
import * as auth from "../utils/auth.js";
import '../blocks/login/login.css';
import '../blocks/auth-form/auth-form.css';

function Login({onLogin}) {
const [email, setEmail] = React.useState('');
const [password, setPassword] = React.useState('');
const history = useHistory();

/* function onLogin({email, password}) {
auth
.login(email, password)
.then((res) => {
const customEvent = new CustomEvent(
'userLogged', {detail: { email: email, isLoggedIn: true } }
);
window.dispatchEvent(customEvent)
history.push("/");
})
.catch((err) => {
// setTooltipStatus("fail");
// setIsInfoToolTipOpen(true);
});
}*/

function handleSubmit(e) {
e.preventDefault();
Expand Down
67 changes: 34 additions & 33 deletions frontend/microfrontend/auth_app/src/components/Register.js
Original file line number Diff line number Diff line change
@@ -1,42 +1,43 @@
import React from 'react';
import { Link } from 'react-router-dom';
import {Link} from 'react-router-dom';

function Register ({onRegister}){
const [email, setEmail] = React.useState('');
const [password, setPassword] = React.useState('');
function Register({onRegister}) {
const [email, setEmail] = React.useState('');
const [password, setPassword] = React.useState('');

function handleSubmit(e){
e.preventDefault();
const userData = {
email,
password
function handleSubmit(e) {
e.preventDefault();
const userData = {
email,
password
}
onRegister(userData);
}
onRegister(userData);
}

return (
<div className="auth-form">
<form className="auth-form__form" onSubmit={handleSubmit}>
<div className="auth-form__wrapper">
<h3 className="auth-form__title">Регистрация</h3>
<label className="auth-form__input">
<input type="text" name="email" id="email"
className="auth-form__textfield" placeholder="Email"
onChange={e => setEmail(e.target.value)} required />
</label>
<label className="auth-form__input">
<input type="password" name="password" id="password"
className="auth-form__textfield" placeholder="Пароль"
onChange={e => setPassword(e.target.value)} required />
</label>
return (
<div className="auth-form">
<form className="auth-form__form" onSubmit={handleSubmit}>
<div className="auth-form__wrapper">
<h3 className="auth-form__title">Регистрация</h3>
<label className="auth-form__input">
<input type="text" name="email" id="email"
className="auth-form__textfield" placeholder="Email"
onChange={e => setEmail(e.target.value)} required/>
</label>
<label className="auth-form__input">
<input type="password" name="password" id="password"
className="auth-form__textfield" placeholder="Пароль"
onChange={e => setPassword(e.target.value)} required/>
</label>
</div>
<div className="auth-form__wrapper">
<button className="auth-form__button" type="submit">Зарегистрироваться</button>
<p className="auth-form__text">Уже зарегистрированы? <Link className="auth-form__link"
to="/signin">Войти</Link></p>
</div>
</form>
</div>
<div className="auth-form__wrapper">
<button className="auth-form__button" type="submit">Зарегистрироваться</button>
<p className="auth-form__text">Уже зарегистрированы? <Link className="auth-form__link" to="/signin">Войти</Link></p>
</div>
</form>
</div>
)
)
}

export default Register;
4 changes: 2 additions & 2 deletions frontend/microfrontend/mesto_app/build/webpack.common.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const path = require("path");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const { CleanWebpackPlugin } = require("clean-webpack-plugin");
const { ModuleFederationPlugin } = require("webpack").container;
const {CleanWebpackPlugin} = require("clean-webpack-plugin");
const {ModuleFederationPlugin} = require("webpack").container;
const HotModuleReplacementPlugin = require("webpack").HotModuleReplacementPlugin;
const deps = require("../package.json").dependencies;

Expand Down
4 changes: 2 additions & 2 deletions frontend/microfrontend/mesto_app/build/webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
const { merge } = require("webpack-merge");
const {merge} = require("webpack-merge");

const commonConfig = require("./webpack.common.js");

module.exports = ({ env }) => {
module.exports = ({env}) => {
const envConfig = require(`./webpack.${env}.js`);

return merge(commonConfig, envConfig);
Expand Down
2 changes: 1 addition & 1 deletion frontend/microfrontend/mesto_app/build/webpack.dev.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { DefinePlugin } = require("webpack");
const {DefinePlugin} = require("webpack");

module.exports = {
mode: "development",
Expand Down
2 changes: 1 addition & 1 deletion frontend/microfrontend/mesto_app/build/webpack.prod.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { DefinePlugin } = require("webpack");
const {DefinePlugin} = require("webpack");

module.exports = {
mode: "production",
Expand Down
4 changes: 2 additions & 2 deletions frontend/microfrontend/mesto_app/src/bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ import ReactDOM from 'react-dom/client';
import './index.css';
import App from './components/App';
import * as serviceWorker from './serviceWorker';
import { BrowserRouter } from "react-router-dom";
import {BrowserRouter} from "react-router-dom";

ReactDOM.createRoot(document.getElementById('root')).render(
<React.StrictMode>
<BrowserRouter>
<App />
<App/>
</BrowserRouter>
</React.StrictMode>,
);
Expand Down
68 changes: 34 additions & 34 deletions frontend/microfrontend/mesto_app/src/components/AddPlacePopup.js
Original file line number Diff line number Diff line change
@@ -1,45 +1,45 @@
import React from 'react';
import PopupWithForm from './PopupWithForm';

function AddPlacePopup({ isOpen, onAddPlace, onClose }) {
const [name, setName] = React.useState('');
const [link, setLink] = React.useState('');
function AddPlacePopup({isOpen, onAddPlace, onClose}) {
const [name, setName] = React.useState('');
const [link, setLink] = React.useState('');

function handleNameChange(e) {
setName(e.target.value);
}
function handleNameChange(e) {
setName(e.target.value);
}

function handleLinkChange(e) {
setLink(e.target.value);
}
function handleLinkChange(e) {
setLink(e.target.value);
}

function handleSubmit(e) {
e.preventDefault();
function handleSubmit(e) {
e.preventDefault();

onAddPlace({
name,
link
});
}
onAddPlace({
name,
link
});
}

return (
<PopupWithForm
isOpen={isOpen} onSubmit={handleSubmit} onClose={onClose} title="Новое место" name="new-card"
>
<label className="popup__label">
<input type="text" name="name" id="place-name"
className="popup__input popup__input_type_card-name" placeholder="Название"
required minLength="1" maxLength="30" value={name} onChange={handleNameChange} />
<span className="popup__error" id="place-name-error"></span>
</label>
<label className="popup__label">
<input type="url" name="link" id="place-link"
className="popup__input popup__input_type_url" placeholder="Ссылка на картинку"
required value={link} onChange={handleLinkChange} />
<span className="popup__error" id="place-link-error"></span>
</label>
</PopupWithForm>
);
return (
<PopupWithForm
isOpen={isOpen} onSubmit={handleSubmit} onClose={onClose} title="Новое место" name="new-card"
>
<label className="popup__label">
<input type="text" name="name" id="place-name"
className="popup__input popup__input_type_card-name" placeholder="Название"
required minLength="1" maxLength="30" value={name} onChange={handleNameChange}/>
<span className="popup__error" id="place-name-error"></span>
</label>
<label className="popup__label">
<input type="url" name="link" id="place-link"
className="popup__input popup__input_type_url" placeholder="Ссылка на картинку"
required value={link} onChange={handleLinkChange}/>
<span className="popup__error" id="place-link-error"></span>
</label>
</PopupWithForm>
);
}

export default AddPlacePopup;
Loading

0 comments on commit c3b772e

Please sign in to comment.