diff --git a/src/App.css b/src/App.css index bfaf462..c766dae 100644 --- a/src/App.css +++ b/src/App.css @@ -1,11 +1,45 @@ +/* Основные стили приложения */ .App { - display: flex; - flex-direction: column; - min-height: 100vh; + display: flex; + flex-direction: column; + min-height: 100vh; + background: #fff; /* Добавляем белый фон */ +} + +/* Стили для главного контента */ +main { + flex: 1; + padding: 20px 0 40px; + max-width: 1200px; /* Ограничиваем ширину контента */ + width: 100%; + margin: 0 auto; /* Центрируем контент */ +} + +/* Плавная прокрутка */ +html { + scroll-behavior: smooth; +} + +/* Стили для секций */ +section { + padding: 60px 0; + scroll-margin-top: 80px; /* Учитываем высоту шапки */ +} + +/* Отступы между секциями */ +section:not(:last-child) { + margin-bottom: 40px; + border-bottom: 1px solid #f0f0f0; +} + +/* Для адаптивности */ +@media (max-width: 768px) { + main { + padding: 15px 20px 30px; } - main { - flex: 1; - padding-bottom: 40px; + section { + padding: 40px 0; + scroll-margin-top: 70px; } - \ No newline at end of file +} diff --git a/src/App.js b/src/App.js index d2c4fe5..ec4f492 100644 --- a/src/App.js +++ b/src/App.js @@ -14,24 +14,34 @@ function App() {
+
-

+

Добро пожаловать в SkinCare Advisor!

-
+ +
- - + +
+ +
+ +
+ +
} /> + } /> } />
+
diff --git a/src/components/Footer/Footer.css b/src/components/Footer/Footer.css index 5e312d2..92cad88 100644 --- a/src/components/Footer/Footer.css +++ b/src/components/Footer/Footer.css @@ -75,7 +75,6 @@ width: 100%; } - /* Адаптивность */ @media (max-width: 768px) { .footer-content { flex-direction: column; @@ -92,17 +91,4 @@ justify-content: center; } } - - /* Фиксированный футер (опционально) */ - /* - .App { - display: flex; - flex-direction: column; - min-height: 100vh; - } - - .site-footer { - margin-top: auto; - } - */ \ No newline at end of file diff --git a/src/components/Footer/Footer.js b/src/components/Footer/Footer.js index 506aac9..6cbca77 100644 --- a/src/components/Footer/Footer.js +++ b/src/components/Footer/Footer.js @@ -22,8 +22,8 @@ function Footer() {
- © {new Date().getFullYear()} SkinCare Advisor. Все права защищены. -
+ © {new Date().getFullYear()} SkinCare Advisor. Все права защищены. + {/*JS выражение, которое подставляет текущий год*/} ); } diff --git a/src/components/Header/Header.css b/src/components/Header/Header.css index b6cfeb2..55b80e8 100644 --- a/src/components/Header/Header.css +++ b/src/components/Header/Header.css @@ -1,111 +1,141 @@ -/* Основные стили шапки */ -.site-header { - background: white; - padding: 15px 0; - position: sticky; - top: 0; - z-index: 1000; - box-shadow: 0 2px 15px rgba(0,0,0,0.1); - border-bottom: 1px solid #f0f0f0; -} +.site-header { /* Основной контейнер шапки сайта */ + background: white; + padding: 15px 0; /* Отступы сверху/снизу */ + position: sticky; + top: 0; /* Привязка к верху */ + z-index: 1000; /* Поверх других элементов */ + box-shadow: 0 2px 15px rgba(0,0,0,0.07); /* Тень снизу */ + border-bottom: 1px solid #f0f0f0; /* Граница снизу */ +} -.header-content { - max-width: 1200px; - margin: 0 auto; - display: flex; - align-items: center; - padding: 0 20px; - gap: 30px; -} +.header-content { /* Контейнер содержимого */ + max-width: 1200px; + margin: 0 auto; /* Центрирование */ + display: flex; + align-items: center; /* Вертикальное выравнивание */ + padding: 0 20px; /* Отступы по бокам */ + gap: 22px; /* Расстояние между элементами */ +} -/* Стили для логотипа */ -.logo-link { - text-decoration: none; - display: flex; - align-items: center; - transition: transform 0.3s ease; -} +.logo-link { /* Ссылка с логотипом */ + display: flex; + align-items: center; /* Выравнивание по центру */ + text-decoration: none; /* Без подчеркивания */ +} -.logo-link:hover { - transform: translateY(-2px); -} +.navigation ul { /* Навигационное меню */ + display: flex; + gap: 18px; /* Расстояние между пунктами */ + list-style: none; /* Убрать маркеры */ + margin: 0; + padding: 0; +} -/* Стили для поиска */ -.search-container { - display: flex; - flex-grow: 1; - max-width: 600px; - gap: 12px; -} - -.search-input { - flex: 1; - padding: 12px 25px; - border: 1px solid #e0e0e0; - border-radius: 30px; - background: white; +.navigation a { /* Ссылки меню */ color: #333; - font-size: 16px; - transition: all 0.3s; - box-shadow: 0 2px 5px rgba(0,0,0,0.05); -} + text-decoration: none; /* Без подчеркивания */ + font-size: 16px; + font-weight: 500; /* Насыщенность */ + padding: 8px 14px; + border-radius: 6px; + transition: background 0.2s, color 0.2s; /* Анимация */ +} -.search-input:focus { - border-color: #6C63FF; - box-shadow: 0 0 0 3px rgba(108, 99, 255, 0.1); - outline: none; -} +.navigation a:hover { /* При наведении */ + background: #f3f2ff; + color: #6C63FF; +} -.search-input::placeholder { - color: #aaa; -} - -.search-btn { - padding: 0 30px; - background: #ffffff; - color: rgb(0, 0, 0); - border: none; - border-radius: 30px; - cursor: pointer; - font-size: 16px; - font-weight: 600; - transition: all 0.3s; - box-shadow: 0 2px 10px rgba(108, 99, 255, 0.2); -} - -.search-btn:hover { - background: #e2e2e2; - transform: translateY(-1px); - box-shadow: 0 4px 12px rgba(108, 99, 255, 0.3); -} - -/* Стили для кнопок авторизации */ -.auth-buttons { +.search-container { /* Поисковая строка */ display: flex; - gap: 15px; -} + align-items: center; + max-width: 260px; + width: 100%; + margin-left: 30px; + background: #f6f6fa; + border-radius: 22px; + box-shadow: 0 1px 4px rgba(108,99,255,0.05); /* Тень */ + padding: 2px 4px; + gap: 6px; +} -.auth-link { - color: #555; - text-decoration: none; - padding: 10px 20px; - border-radius: 8px; - transition: all 0.3s; - font-weight: 500; -} +.search-input { /* Поле ввода */ + flex: 1; /* Заполнение пространства */ + padding: 8px 14px; + border: none; + border-radius: 18px; + background: transparent; /* Прозрачный фон */ + color: #333; + font-size: 15px; + outline: none; /* Без обводки */ +} -.auth-link:hover { - color: #6C63FF; - background: rgba(108, 99, 255, 0.05); -} +.search-input::placeholder { /* Плейсхолдер */ + color: #aaa; +} -.auth-link.register { - background: #6C63FF; - color: white; - box-shadow: 0 2px 10px rgba(108, 99, 255, 0.2); -} +.search-btn { /* Кнопка поиска */ + padding: 7px 18px; + background: #fff; + color: #6C63FF; + border: 1px solid #6C63FF; + border-radius: 18px; + font-size: 15px; + font-weight: 600; + cursor: pointer; /* Курсор-указатель */ + transition: background 0.2s, color 0.2s; /* Анимация */ +} -.auth-link.register:hover { - background: #5a52d4; - box-shadow: 0 4px 12px rgba(108, 99, 255, 0.3); +.search-btn:hover { /* При наведении */ + background: #6C63FF; + color: #fff; +} + +.auth-buttons { /* Кнопки авторизации */ + display: flex; + gap: 10px; + align-items: center; + margin-left: 30px; +} + +.auth-link { /* Ссылка авторизации */ + color: #555; + text-decoration: none; + padding: 8px 16px; + border-radius: 8px; + transition: background 0.2s, color 0.2s; /* Анимация */ + font-weight: 500; +} + +.auth-link:hover { /* При наведении */ + color: #6C63FF; + background: rgba(108, 99, 255, 0.07); +} + +.auth-link.register { /* Кнопка регистрации */ + background: #6C63FF; + color: white; + box-shadow: 0 2px 10px rgba(108, 99, 255, 0.08); /* Тень */ +} + +.auth-link.register:hover { /* При наведении */ + background: #5a52d4; + color: #fff; +} + +@media (max-width: 1000px) { /* Адаптивность */ + .header-content { + flex-wrap: wrap; /* Перенос строк */ + gap: 10px; + } + .navigation, .search-container, .auth-buttons { + margin-left: 0; + } + .navigation ul { /* Меню */ + flex-wrap: wrap; /* Перенос пунктов */ + gap: 10px; + } + .search-container { /* Поиск */ + max-width: 100%; /* Полная ширина */ + } } diff --git a/src/components/Header/Header.js b/src/components/Header/Header.js index 0f52593..6cb0f57 100644 --- a/src/components/Header/Header.js +++ b/src/components/Header/Header.js @@ -1,6 +1,7 @@ import React from 'react'; import { Link } from 'react-router-dom'; -import Logo from './Logo'; // Убедитесь в правильности пути +import Logo from './Logo'; +import Navigation from './Navigation'; import './Header.css'; function Header() { @@ -10,16 +11,18 @@ function Header() { - + + +
- +
Вход Регистрация diff --git a/src/components/Header/Logo.css b/src/components/Header/Logo.css index b9685ce..df7d047 100644 --- a/src/components/Header/Logo.css +++ b/src/components/Header/Logo.css @@ -1,53 +1,22 @@ .logo { display: flex; align-items: center; - gap: 15px; - transition: all 0.3s ease; -} - -.logo:hover { - transform: translateY(-2px); + gap: 12px; } .logo-image { height: 40px; width: auto; - transition: transform 0.3s ease; -} - -.logo-image:hover { - transform: scale(1.05) rotate(-5deg); } .logo-text { font-size: 22px; - color: #333; /* Изменили на тёмный цвет */ + color: #333; font-weight: 600; margin: 0; - letter-spacing: 0.5px; - position: relative; -} - -.logo-text::after { - content: ""; - position: absolute; - bottom: -5px; - left: 0; - width: 0; - height: 2px; - background: #6C63FF; - transition: width 0.3s ease; -} - -.logo:hover .logo-text::after { - width: 100%; + letter-spacing: 0.5px; /* Доб 0.5px между символами */ } .logo-text span { color: #6C63FF; - transition: color 0.3s ease; -} - -.logo:hover .logo-text span { - color: #5a52d4; } diff --git a/src/components/Header/Navigation.js b/src/components/Header/Navigation.js index 5ced418..c3836c4 100644 --- a/src/components/Header/Navigation.js +++ b/src/components/Header/Navigation.js @@ -4,14 +4,18 @@ function Navigation() { return ( ); } -export default Navigation; \ No newline at end of file +export default Navigation; diff --git a/src/components/PopularProducts/PopularProducts.css b/src/components/PopularProducts/PopularProducts.css index f4d889d..2ad55cb 100644 --- a/src/components/PopularProducts/PopularProducts.css +++ b/src/components/PopularProducts/PopularProducts.css @@ -1,77 +1,76 @@ -.popular-products { - max-width: 1200px; - margin: 40px auto; - padding: 0 20px; - } - - .popular-products h2 { - text-align: center; - margin-bottom: 40px; - font-size: 28px; - } - - .products-grid { - display: grid; - grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); - gap: 30px; - } - - .product-card { - border: 1px solid #eee; - border-radius: 12px; - overflow: hidden; - transition: transform 0.3s; - } - - .product-card:hover { - transform: translateY(-5px); - } - - .product-image { - width: 100%; - height: 200px; - object-fit: cover; - } - - .product-card h3 { - padding: 15px 15px 0; - margin: 0; - font-size: 18px; - } - - .product-card p { - padding: 10px 15px; - color: #666; - font-size: 14px; - margin: 0; - } - - .product-footer { - padding: 15px; - display: flex; - justify-content: space-between; - align-items: center; - } - - .price { - font-weight: bold; - color: #333; - } - - .details-btn { - background: #f8f9fa; - border: 1px solid #ddd; - padding: 8px 15px; - border-radius: 20px; - cursor: pointer; - transition: all 0.3s; - opacity: 0; /* Скрываем кнопку по умолчанию */ - } - - .product-card:hover .details-btn { - background: #6C63FF; - color: white; - border-color: #6C63FF; - opacity: 1; /* Показываем кнопку при наведении */ - } - \ No newline at end of file +.popular-products { /* Контейнер секции */ + max-width: 1200px; + margin: 40px auto; /* Центрирование */ + padding: 0 20px; +} + +.popular-products h2 { /* Заголовок */ + text-align: center; + margin-bottom: 40px; + font-size: 28px; +} + +.products-grid { /* Сетка товаров */ + display: grid; + grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); /* Автоподбор колонок */ + gap: 30px; /* Расстояние между карточками */ +} + +.product-card { /* Карточка товара */ + border: 1px solid #eee; + border-radius: 12px; + overflow: hidden; /* Скрытие выходящего контента */ + transition: transform 0.3s; /* Анимация */ +} + +.product-card:hover { /* Эффект при наведении */ + transform: translateY(-5px); /* Сдвиг вверх */ +} + +.product-image { /* Изображение товара */ + width: 100%; + height: 200px; + object-fit: cover; /* Обрезка изображения */ +} + +.product-card h3 { /* Название товара */ + padding: 15px 15px 0; + margin: 0; + font-size: 18px; +} + +.product-card p { /* Описание товара */ + padding: 10px 15px; + color: #666; + font-size: 14px; + margin: 0; +} + +.product-footer { /* Подвал карточки */ + padding: 15px; + display: flex; + justify-content: space-between; /* Распределение пространства */ + align-items: center; +} + +.price { + font-weight: bold; + color: #333; +} + +.details-btn { /* Кнопка "Подробнее" */ + background: #f8f9fa; + border: 1px solid #ddd; + padding: 8px 15px; + border-radius: 20px; + cursor: pointer; /* Курсор-указатель */ + transition: all 0.3s; + opacity: 0; +} + +.product-card:hover .details-btn { /* Кнопка при наведении */ + background: #6C63FF; + color: white; + border-color: #6C63FF; + opacity: 1; /* Показываем кнопку */ +} diff --git a/src/components/PopularProducts/PopularProducts.js b/src/components/PopularProducts/PopularProducts.js index d78f515..fbe9e1c 100644 --- a/src/components/PopularProducts/PopularProducts.js +++ b/src/components/PopularProducts/PopularProducts.js @@ -4,6 +4,8 @@ import product1 from './img/product1.jpg'; import product2 from './img/product2.jpg'; import product3 from './img/product3.jpg'; import product4 from './img/product4.jpg'; +import product5 from './img/product5.png'; +import product6 from './img/product6.png'; const products = [ { @@ -33,26 +35,42 @@ const products = [ image: product4, description: "Восстановление во время сна", price: "1 950 ₽" + }, + { + id: 5, + name: "Солнцезащитный крем SPF 50", + image: product5, + description: "Защита от UVA/UVB лучей", + price: "1 250 ₽" + }, + { + id: 6, + name: "Пилинг для лица", + image: product6, + description: "Мягкое отшелушивание кожи", + price: "1 780 ₽" } ]; -function PopularProducts() { +function PopularProducts() { /* берет массив products, преобразует каждый товар + в HTML-карточку и выводит их в адаптивную сетку.*/ return ( -
-

Популярные косметические средства

-
- {products.map(product => ( -
+
{/* Основная секция */} +

Популярные косметические средства

+ +
{/* Контейнер сетки */} + {products.map(product => ( /* Перебираем массив товаров */ +
{product.name} -

{product.name}

-

{product.description}

-
- {product.price} - +

{product.name}

+

{product.description}

+
+ {product.price} +
))} diff --git a/src/components/PopularProducts/img/product5.png b/src/components/PopularProducts/img/product5.png new file mode 100644 index 0000000..d184433 Binary files /dev/null and b/src/components/PopularProducts/img/product5.png differ diff --git a/src/components/PopularProducts/img/product6.png b/src/components/PopularProducts/img/product6.png new file mode 100644 index 0000000..f6d8b78 Binary files /dev/null and b/src/components/PopularProducts/img/product6.png differ diff --git a/src/components/Reviews/Reviews.css b/src/components/Reviews/Reviews.css index d76d031..7704d74 100644 --- a/src/components/Reviews/Reviews.css +++ b/src/components/Reviews/Reviews.css @@ -1,48 +1,47 @@ .reviews-section { - max-width: 800px; - margin: 40px auto; - padding: 0 20px; - } - - .reviews-section h2 { - text-align: center; - margin-bottom: 32px; - font-size: 26px; - } - - .reviews-list { - display: flex; - flex-direction: column; - gap: 24px; - } - - .review-card { - border: 1px solid #eee; - border-radius: 10px; - background: #fafbfc; - padding: 20px 24px; - box-shadow: 0 2px 8px rgba(0,0,0,0.03); - } - - .review-text { - font-size: 16px; - margin-bottom: 12px; - color: #222; - } - - .review-meta { - display: flex; - align-items: center; - gap: 16px; - } - - .review-author { - font-weight: bold; - color: #6C63FF; - } - - .star-rating { - color: #FFD700; - font-size: 18px; - } - \ No newline at end of file + max-width: 800px; + margin: 40px auto; + padding: 0 20px; +} + +.reviews-section h2 { + text-align: center; + margin-bottom: 32px; + font-size: 26px; +} + +.reviews-list { + display: flex; + flex-direction: column; + gap: 24px; +} + +.review-card { + border: 1px solid #eee; + border-radius: 10px; + background: #fafbfc; + padding: 20px 24px; + box-shadow: 0 2px 8px rgba(0,0,0,0.03); +} + +.review-text { + font-size: 16px; + margin-bottom: 12px; + color: #222; +} + +.review-info { + display: flex; + align-items: center; + gap: 16px; +} + +.review-author { + font-weight: bold; + color: #6C63FF; +} + +.star-rating { + color: #FFD700; + font-size: 18px; +} diff --git a/src/components/Reviews/Reviews.js b/src/components/Reviews/Reviews.js index 55095ac..97125fa 100644 --- a/src/components/Reviews/Reviews.js +++ b/src/components/Reviews/Reviews.js @@ -1,6 +1,7 @@ import React from 'react'; import './Reviews.css'; +// Массив с отзывами пользователей const reviews = [ { id: 1, @@ -22,6 +23,7 @@ const reviews = [ } ]; +// Компонент для отображения звездного рейтинга function StarRating({ rating }) { return ( @@ -31,17 +33,20 @@ function StarRating({ rating }) { ); } +// Основной компонент отзывов function Reviews() { return (
-

Отзывы пользователей

-
+

Отзывы пользователей

+ +
{/* Перебираем массив отзывов */} {reviews.map(review => ( + // Карточка отзыва с уникальным ключом
-

"{review.text}"

-
- {review.author} - +

"{review.text}"

+
+ {review.author} +
))} @@ -50,4 +55,5 @@ function Reviews() { ); } + export default Reviews; diff --git a/src/components/SkinTypeQuiz/Question.js b/src/components/SkinTypeQuiz/Question.js index d45ee23..caa32ba 100644 --- a/src/components/SkinTypeQuiz/Question.js +++ b/src/components/SkinTypeQuiz/Question.js @@ -1,15 +1,17 @@ import React, { useState, useEffect } from 'react'; function Question({ question, answer, onAnswer, isLast, onNext }) { + // Выбранные ответы const [selected, setSelected] = useState(() => { return question.type === 'multiple' ? Array.isArray(answer) ? [...answer] : [] : answer || ''; }); + // Текст для поля "Другое" const [otherText, setOtherText] = useState(''); - // Инициализация otherText + // Инициализация текста для "Другое" useEffect(() => { if (question.type === 'multiple' && Array.isArray(answer)) { const otherItem = answer.find(item => item?.other); @@ -17,7 +19,7 @@ function Question({ question, answer, onAnswer, isLast, onNext }) { } }, [answer, question.type]); - // Синхронизация с пропсом answer + // Синхронизация с внешними изменениями useEffect(() => { if (question.type === 'multiple') { setSelected(Array.isArray(answer) ? answer : []); @@ -26,6 +28,7 @@ function Question({ question, answer, onAnswer, isLast, onNext }) { } }, [answer, question.type]); + // Обработчик изменения выбора const handleChange = (option, isOther = false) => { if (question.type === 'single') { setSelected(option); @@ -35,6 +38,7 @@ function Question({ question, answer, onAnswer, isLast, onNext }) { let newSelected = Array.isArray(selected) ? [...selected] : []; + // Логика для чекбокса "Другое" if (isOther) { const existingOther = newSelected.findIndex(item => item?.other); if (existingOther >= 0) { @@ -56,6 +60,7 @@ function Question({ question, answer, onAnswer, isLast, onNext }) { onAnswer(question.id, newSelected); }; + // Обработчик изменения текста для "Другое" const handleOtherTextChange = (e) => { const text = e.target.value; setOtherText(text); @@ -66,11 +71,13 @@ function Question({ question, answer, onAnswer, isLast, onNext }) { onAnswer(question.id, newSelected); }; + // Отправка формы const handleSubmit = (e) => { e.preventDefault(); onNext(); }; + // Нормализация выбранных значений const safeSelected = question.type === 'multiple' ? (Array.isArray(selected) ? selected : []) : selected; diff --git a/src/components/SkinTypeQuiz/SkinTypeQuiz.js b/src/components/SkinTypeQuiz/SkinTypeQuiz.js index bf662b8..db9cd72 100644 --- a/src/components/SkinTypeQuiz/SkinTypeQuiz.js +++ b/src/components/SkinTypeQuiz/SkinTypeQuiz.js @@ -3,6 +3,7 @@ import Question from './Question'; import Result from './Result'; import './SkinTypeQuiz.css'; +// Список всех вопросов опросника const questionsMock = [ { id: 1, @@ -49,15 +50,25 @@ const questionsMock = [ ]; function SkinTypeQuiz() { + // Текущий индекс вопроса const [currentIndex, setCurrentIndex] = useState(0); + + // Все ответы пользователя const [answers, setAnswers] = useState({}); + + // Флаг показа результатов const [showResult, setShowResult] = useState(false); + + // Рекомендации по уходу const [recommendations, setRecommendations] = useState(''); const questions = questionsMock; + // Обработчик выбора ответа const handleAnswer = (questionId, answer) => { const currentQuestion = questions.find(q => q.id === questionId); + + // Для чекбоксов: преобразуем в массив если необходимо const safeAnswer = currentQuestion.type === 'multiple' ? Array.isArray(answer) ? answer : [] : answer; @@ -65,6 +76,7 @@ function SkinTypeQuiz() { setAnswers(prev => ({ ...prev, [questionId]: safeAnswer })); }; + // Переход к следующему вопросу или показ результатов const handleNext = () => { if (currentIndex + 1 < questions.length) { setCurrentIndex(currentIndex + 1); @@ -75,10 +87,12 @@ function SkinTypeQuiz() { } }; + // Показываем результаты если опрос завершен if (showResult) { return ; } + // Рендер текущего вопроса return ( { - const { name, value } = e.target; + const { name, value } = e.target; setFormData(prev => ({ - ...prev, - [name]: value + ...prev, // Сохранение предыдущих значений + [name]: value // Динамическое обновление поля })); }; + // Обработчик отправки формы const handleSubmit = (e) => { - e.preventDefault(); - console.log('Вход:', formData); - navigate('/'); + e.preventDefault(); // Отмена стандартного поведения + console.log('Вход:', formData); // Логирование данных (в реальном приложении - запрос к API) + navigate('/'); // Перенаправление на главную страницу }; return ( + // Основной контейнер страницы
-

Вход

+

Вход

+ + {/* Форма с обработчиком отправки */}
+ {/* Группа полей для email */}
+ {/* Группа полей для пароля */}
+ {/* Кнопка отправки формы */}
+ {/* Ссылка для перехода к регистрации */}
Нет аккаунта? Создать
diff --git a/src/pages/Register.js b/src/pages/Register.js index 9650cfb..944f3a1 100644 --- a/src/pages/Register.js +++ b/src/pages/Register.js @@ -1,46 +1,57 @@ -import React, { useState } from 'react'; -import { useNavigate } from 'react-router-dom'; -import './AuthForms.css'; +import React, { useState } from 'react'; //для управления состоянием формы +import { useNavigate } from 'react-router-dom'; +import './AuthForms.css'; function Register() { + // Состояние для хранения данных формы const [formData, setFormData] = useState({ name: '', email: '', password: '' }); + // Хук для навигации между страницами const navigate = useNavigate(); + // Обработчик изменений в полях ввода const handleChange = (e) => { - const { name, value } = e.target; + const { name, value } = e.target; // Извлекаем имя поля и значение setFormData(prev => ({ - ...prev, - [name]: value + ...prev, // Копируем предыдущее состояние + [name]: value // Обновляем конкретное поле })); }; + // Обработчик отправки формы const handleSubmit = (e) => { - e.preventDefault(); - console.log('Регистрация:', formData); + e.preventDefault(); // Отменяем стандартное поведение формы + + // В реальном приложении здесь будет запрос к API + console.log('Регистрация:', formData); + + // Перенаправляем на главную страницу navigate('/'); }; return ( -
-
-

Регистрация

-
+
+
+

Регистрация

+ + {/* Форма с обработчиком отправки */} + {/* Группа полей для имени */}
+ {/* Группа полей для email */}
+ {/* Группа полей для пароля */}
+ {/* Кнопка отправки формы */} + {/* Ссылка для перехода к авторизации */}
Уже есть аккаунт? Войти
@@ -76,4 +90,4 @@ function Register() { ); } -export default Register; +export default Register;