feat(): Added ci restruct project and add dockerfile
No files matched your search
@@ -0,0 +1,42 @@
|
||||
#root {
|
||||
max-width: 1280px;
|
||||
margin: 0 auto;
|
||||
padding: 2rem;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.logo {
|
||||
height: 6em;
|
||||
padding: 1.5em;
|
||||
will-change: filter;
|
||||
transition: filter 300ms;
|
||||
}
|
||||
.logo:hover {
|
||||
filter: drop-shadow(0 0 2em #646cffaa);
|
||||
}
|
||||
.logo.react:hover {
|
||||
filter: drop-shadow(0 0 2em #61dafbaa);
|
||||
}
|
||||
|
||||
@keyframes logo-spin {
|
||||
from {
|
||||
transform: rotate(0deg);
|
||||
}
|
||||
to {
|
||||
transform: rotate(360deg);
|
||||
}
|
||||
}
|
||||
|
||||
@media (prefers-reduced-motion: no-preference) {
|
||||
a:nth-of-type(2) .logo {
|
||||
animation: logo-spin infinite 20s linear;
|
||||
}
|
||||
}
|
||||
|
||||
.card {
|
||||
padding: 2em;
|
||||
}
|
||||
|
||||
.read-the-docs {
|
||||
color: #888;
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
import axios from "axios";
|
||||
import type { Product } from "../types/product";
|
||||
import type { Category } from "../types/categories";
|
||||
|
||||
export const fetchCategoryProducts = async (category: string): Promise<Product[]> => {
|
||||
const response = await axios.get(`https://your-api.com/api/products?category=${category}`);
|
||||
return response.data;
|
||||
};
|
||||
|
||||
export const fetchCategories = async (categoryid: string): Promise<Category[]> => {
|
||||
const response = await axios.get(`https://your-api.com/api/category=${categoryid}`);
|
||||
return response.data;
|
||||
};
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
import axios from "axios";
|
||||
|
||||
export const API_BASE = "";
|
||||
const client = axios.create({
|
||||
baseURL: API_BASE,
|
||||
headers: { "Content-Type": "application/json" },
|
||||
});
|
||||
|
||||
export default client;
|
||||
@@ -0,0 +1,7 @@
|
||||
import { useDispatch, useSelector } from "react-redux";
|
||||
import type {TypedUseSelectorHook} from "react-redux";
|
||||
import type { RootState, AppDispatch } from "./store";
|
||||
|
||||
// Используем вместо обычных useDispatch и useSelector
|
||||
export const useAppDispatch: () => AppDispatch = useDispatch;
|
||||
export const useAppSelector: TypedUseSelectorHook<RootState> = useSelector;
|
||||
@@ -0,0 +1,22 @@
|
||||
import Layout from "../pages/Layout/Layout";
|
||||
import { Routes } from "react-router";
|
||||
import { Route } from "react-router";
|
||||
import Main from "../pages/Main/Main";
|
||||
import About from "../pages/About/About";
|
||||
import Products from "../pages/Products/Products";
|
||||
import ItemPage from "../pages/ItemPage/ItemPage";
|
||||
|
||||
function AppRoutes() {
|
||||
return (
|
||||
<Routes>
|
||||
<Route path="/" element={<Layout />}>
|
||||
<Route index element={<Main />} />
|
||||
<Route path="about" element={<About />} />
|
||||
<Route path="products" element={<Products />} />
|
||||
<Route path="/product/:id" element={<ItemPage />} />
|
||||
</Route>
|
||||
</Routes>
|
||||
)
|
||||
}
|
||||
|
||||
export default AppRoutes;
|
||||
@@ -0,0 +1,18 @@
|
||||
import { configureStore } from "@reduxjs/toolkit";
|
||||
import catalogReducer from "../features/catalog/productsSlice";
|
||||
import categoriesReducer from "../features/catalog/categoriesSlice"
|
||||
import productsReducer from "../features/catalog/productsSlice"
|
||||
|
||||
export const store = configureStore({
|
||||
reducer: {
|
||||
categories: categoriesReducer,
|
||||
products: productsReducer,
|
||||
},
|
||||
/*middleware: (getDefaultMiddleware) =>
|
||||
getDefaultMiddleware({
|
||||
serializableCheck: false, // отключаем для async thunk
|
||||
}),*/
|
||||
});
|
||||
|
||||
export type RootState = ReturnType<typeof store.getState>;
|
||||
export type AppDispatch = typeof store.dispatch;
|
||||
|
After Width: | Height: | Size: 33 KiB |
|
After Width: | Height: | Size: 1.4 MiB |
|
After Width: | Height: | Size: 955 KiB |
|
After Width: | Height: | Size: 90 KiB |
|
After Width: | Height: | Size: 215 KiB |
|
After Width: | Height: | Size: 130 KiB |
|
After Width: | Height: | Size: 19 KiB |
@@ -0,0 +1,96 @@
|
||||
.wrapper {
|
||||
width: 100%;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
|
||||
.carousel {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
|
||||
.slide {
|
||||
position: relative;
|
||||
width: 100%;
|
||||
height: 700px;
|
||||
overflow: hidden;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
background: var(--darkblue);
|
||||
}
|
||||
|
||||
|
||||
.textBlock {
|
||||
position: absolute;
|
||||
left: 80px;
|
||||
top: 180px;
|
||||
color: white;
|
||||
max-width: 500px;
|
||||
z-index: 2;
|
||||
}
|
||||
|
||||
|
||||
.textBlock h1 {
|
||||
font-size: 36px;
|
||||
font-weight: 700;
|
||||
line-height: 1.3;
|
||||
}
|
||||
|
||||
|
||||
.textBlock h2 {
|
||||
font-size: 20px;
|
||||
font-weight: 400;
|
||||
opacity: 0.8;
|
||||
}
|
||||
|
||||
|
||||
.button {
|
||||
margin-top: 30px;
|
||||
background: #ffd400 !important;
|
||||
border: none !important;
|
||||
color: black !important;
|
||||
font-weight: 600;
|
||||
padding: 0 26px;
|
||||
height: 48px;
|
||||
}
|
||||
|
||||
|
||||
.image {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
object-position: center;
|
||||
filter: brightness(0.5)
|
||||
}
|
||||
|
||||
/* --- Mobile Adaptive --- */
|
||||
@media (max-width: 768px) {
|
||||
.slide {
|
||||
height: 500px;
|
||||
}
|
||||
|
||||
|
||||
.textBlock {
|
||||
left: 20px;
|
||||
top: 120px;
|
||||
max-width: 300px;
|
||||
}
|
||||
|
||||
|
||||
.textBlock h1 {
|
||||
font-size: 22px;
|
||||
}
|
||||
|
||||
|
||||
.textBlock h2 {
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
|
||||
.button {
|
||||
height: 42px;
|
||||
padding: 0 20px;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
import styles from './Banner.module.css'
|
||||
import React from "react";
|
||||
import { Carousel } from "antd";
|
||||
import Button from '../Button/Button.tsx';
|
||||
import banner_img1 from '../../assets/images/mainPage/ChatGPT-Image-Oct-1_-2025_-05_29_18-PM.png'
|
||||
import banner_img2 from '../../assets/images/mainPage/296170994030930.jpg'
|
||||
|
||||
export interface SlideItem {
|
||||
id: number;
|
||||
image: string;
|
||||
title: string;
|
||||
subtitle: string;
|
||||
description: string;
|
||||
}
|
||||
|
||||
|
||||
const slides: SlideItem[] = [
|
||||
{
|
||||
id: 1,
|
||||
image: banner_img1,
|
||||
title: "ПРОИЗВОДСТВО",
|
||||
subtitle: "ТРУБ, ФИТИНГОВ, КОЛЕН И ОТВОДОВ",
|
||||
description: "ДЛЯ ВНЕШНЕЙ И ВНУТРЕННЕЙ КАНАЛИЗАЦИИ",
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
image: banner_img2,
|
||||
title: "ПРОИЗВОДСТВО",
|
||||
subtitle: "ТРУБ, ФИТИНГОВ, КОЛЕН И ОТВОДОВ",
|
||||
description: "ДЛЯ ВНЕШНЕЙ И ВНУТРЕННЕЙ КАНАЛИЗАЦИИ",
|
||||
}
|
||||
];
|
||||
|
||||
|
||||
const BannerSlider: React.FC = () => {
|
||||
|
||||
const handleClick = () => {
|
||||
console.log('Кнопка нажата!');
|
||||
};
|
||||
|
||||
return (
|
||||
<div className={styles.wrapper}>
|
||||
<Carousel autoplay dots className={styles.carousel}>
|
||||
{slides.map((slide) => (
|
||||
<div key={slide.id}>
|
||||
<div className={styles.slide}>
|
||||
<div className={styles.textBlock}>
|
||||
<h2>{slide.title}</h2>
|
||||
<h1>
|
||||
{slide.subtitle}
|
||||
<br /> {slide.description}
|
||||
</h1>
|
||||
<Button
|
||||
label="СМОТРЕТЬ КАТАЛОГ"
|
||||
onClick={handleClick}
|
||||
/>
|
||||
</div>
|
||||
<img src={slide.image} alt="banner" className={styles.image} />
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</Carousel>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
export default BannerSlider;
|
||||
@@ -0,0 +1,22 @@
|
||||
.button {
|
||||
background: #ffd400;
|
||||
border: none;
|
||||
color: #000;
|
||||
font-weight: 600;
|
||||
padding: 0 50px;
|
||||
height: 50px;
|
||||
border-radius: 50px;
|
||||
cursor: pointer;
|
||||
transition: 0.25s ease;
|
||||
font-size: 15px;
|
||||
}
|
||||
|
||||
|
||||
.button:hover {
|
||||
background: #ffdf3e;
|
||||
}
|
||||
|
||||
|
||||
.button:active {
|
||||
transform: scale(0.97);
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
import React from "react";
|
||||
import styles from "./Button.module.css";
|
||||
|
||||
|
||||
interface ButtonProps {
|
||||
label: string;
|
||||
onClick?: () => void;
|
||||
className?: string;
|
||||
}
|
||||
|
||||
|
||||
const Button: React.FC<ButtonProps> = ({ label, onClick, className }) => {
|
||||
return (
|
||||
<button className={`${styles.button} ${className || ""}`} onClick={onClick}>
|
||||
{label}
|
||||
</button>
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
export default Button;
|
||||
@@ -0,0 +1,127 @@
|
||||
.wrapper {
|
||||
width: 100%;
|
||||
margin-top: 40px;
|
||||
}
|
||||
|
||||
.header {
|
||||
font-size: 24px;
|
||||
font-weight: 700;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
|
||||
.grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(4, 1fr);
|
||||
grid-auto-rows: 230px;
|
||||
gap: 0;
|
||||
}
|
||||
|
||||
.card {
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
border: 1px solid #ececec;
|
||||
}
|
||||
|
||||
|
||||
.image {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
}
|
||||
|
||||
|
||||
.highlight {
|
||||
grid-column: span 2;
|
||||
grid-row: span 2;
|
||||
}
|
||||
|
||||
|
||||
.overlay {
|
||||
position: absolute;
|
||||
left: 40px;
|
||||
bottom: 40px;
|
||||
color: white;
|
||||
max-width: 320px;
|
||||
}
|
||||
|
||||
|
||||
.overlay h3 {
|
||||
font-size: 22px;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
|
||||
.overlay h4 {
|
||||
margin-top: 4px;
|
||||
font-size: 16px;
|
||||
opacity: 0.9;
|
||||
}
|
||||
|
||||
|
||||
.button {
|
||||
margin-top: 20px;
|
||||
background: #ffd400 !important;
|
||||
color: black !important;
|
||||
border: none !important;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
|
||||
.titleSmall {
|
||||
position: absolute;
|
||||
bottom: 15px;
|
||||
left: 15px;
|
||||
font-size: 15px;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.card:hover .image {
|
||||
transform: scale(1.05);
|
||||
transition: transform 0.4s ease;
|
||||
}
|
||||
|
||||
|
||||
.card:hover {
|
||||
cursor: pointer;
|
||||
background-color: #ffd400;
|
||||
}
|
||||
|
||||
|
||||
.highlight:hover .overlay h3,
|
||||
.highlight:hover .overlay h4 {
|
||||
transform: translateX(4px);
|
||||
transition: all 0.3s ease;
|
||||
}
|
||||
|
||||
|
||||
.titleSmall {
|
||||
transition: transform 0.3s ease, opacity 0.3s ease;
|
||||
}
|
||||
|
||||
|
||||
.card:hover .titleSmall {
|
||||
transform: translateY(-4px);
|
||||
opacity: 0.9;
|
||||
}
|
||||
|
||||
/* Mobile */
|
||||
@media (max-width: 900px) {
|
||||
.grid {
|
||||
grid-template-columns: repeat(2, 1fr);
|
||||
}
|
||||
.highlight {
|
||||
grid-column: span 2;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@media (max-width: 600px) {
|
||||
.grid {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
.highlight {
|
||||
grid-column: span 1;
|
||||
grid-row: span 1;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
import React from "react";
|
||||
import styles from "./Categories.module.css";
|
||||
import Button from "../Button/Button";
|
||||
import category_internal1 from "../../assets/images/mainPage/category_internal1.jpg"
|
||||
import category_interna2 from "../../assets/images/mainPage/category_internal2.jpg"
|
||||
import { useAppSelector, useAppDispatch } from "../../app/hooks";
|
||||
|
||||
interface CategoryItem {
|
||||
id: number;
|
||||
title: string;
|
||||
subtitle?: string;
|
||||
image: string;
|
||||
highlight?: boolean;
|
||||
}
|
||||
|
||||
const categories: CategoryItem[] = [
|
||||
{
|
||||
id: 1,
|
||||
title: "Труба ПВХ",
|
||||
subtitle: "для ВНУТРЕННЕЙ канализации",
|
||||
image: category_interna2,
|
||||
highlight: true,
|
||||
},
|
||||
/*{ id: 2, title: "СМАЗКИ СКОЛЬЖЕНИЯ", subtitle: "(ПАРАФИНЫ)", image: "/images/cat-paraffin.jpg" },
|
||||
{ id: 3, title: "МАЗИ ДЕРЖАНИЯ", image: "/images/cat-hold.jpg" },
|
||||
{ id: 4, title: "СМЫВКА", image: "/images/cat-wash.jpg" },
|
||||
{ id: 5, title: "СМОЛА", image: "/images/cat-resin.jpg" },
|
||||
{ id: 6, title: "СКРЕБКИ", image: "/images/cat-scraper.jpg" },
|
||||
{ id: 7, title: "ПРОБКИ / РАСТИРКИ", image: "/images/cat-cork.jpg" },*/
|
||||
{
|
||||
id: 2,
|
||||
title: "Труба ПВХ",
|
||||
subtitle: "для НАРУЖНОЙ канализации",
|
||||
highlight: true,
|
||||
image: category_internal1,
|
||||
},
|
||||
/*{ id: 9, title: "СВЯЗКИ И СКРЕПКИ ДЛЯ ЛЫЖ", image: "/images/cat-straps.jpg" },
|
||||
{ id: 10, title: "ЧЕХЛЫ, СУМКИ", image: "/images/cat-bags.jpg" },*/
|
||||
];
|
||||
|
||||
|
||||
const CategoriesGrid: React.FC = () => {
|
||||
|
||||
const handleClick = () => {
|
||||
console.log('Кнопка нажата!');
|
||||
};
|
||||
|
||||
return (
|
||||
<div className={styles.wrapper}>
|
||||
<h2 className={styles.header}>КАТЕГОРИИ ТОВАРОВ</h2>
|
||||
|
||||
|
||||
<div className={styles.grid}>
|
||||
{categories.map((cat) => (
|
||||
<div
|
||||
key={cat.id}
|
||||
className={`${styles.card} ${cat.highlight ? styles.highlight : ""}`}
|
||||
>
|
||||
<img src={cat.image} className={styles.image} alt={cat.title} />
|
||||
{cat.highlight && (
|
||||
<div className={styles.overlay}>
|
||||
<h3>{cat.title}</h3>
|
||||
{cat.subtitle && <h4>{cat.subtitle}</h4>}
|
||||
<Button
|
||||
label="СМОТРЕТЬ КАТАЛОГ"
|
||||
onClick={handleClick}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
|
||||
|
||||
{!cat.highlight && (
|
||||
<div className={styles.titleSmall}>
|
||||
<span>{cat.title}</span>
|
||||
{cat.subtitle && <span>{cat.subtitle}</span>}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
export default CategoriesGrid;
|
||||
@@ -0,0 +1,81 @@
|
||||
.wrapper {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 0px 0;
|
||||
}
|
||||
|
||||
.left {
|
||||
flex: 1;
|
||||
padding-left: 0px;
|
||||
}
|
||||
|
||||
.right {
|
||||
flex: 1;
|
||||
position: relative;
|
||||
|
||||
width: 60%;
|
||||
height: 100%;
|
||||
max-height: 600px;
|
||||
}
|
||||
|
||||
.carousel {
|
||||
width: 100%;
|
||||
height: 100%; /* Добавьте высоту 100% */
|
||||
}
|
||||
|
||||
.slide {
|
||||
position: relative;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.image {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
object-position: center bottom;
|
||||
display: block;
|
||||
}
|
||||
|
||||
.label {
|
||||
position: absolute;
|
||||
bottom: 20px;
|
||||
left: 40px;
|
||||
color: white;
|
||||
font-size: 22px;
|
||||
}
|
||||
|
||||
.arrows {
|
||||
position: absolute;
|
||||
right: 30px;
|
||||
bottom: 30px;
|
||||
display: flex;
|
||||
gap: 16px;
|
||||
}
|
||||
|
||||
.arrow {
|
||||
width: 48px;
|
||||
height: 48px;
|
||||
background: white;
|
||||
border: 1px solid #ccc;
|
||||
font-size: 22px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
@media (max-width: 900px) {
|
||||
.wrapper {
|
||||
flex-direction: column;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.left {
|
||||
padding-left: 0;
|
||||
}
|
||||
|
||||
.right {
|
||||
margin-top: 30px;
|
||||
height: 300px; /* Меньшая высота для мобильных */
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
import React, { useRef, useState } from "react";
|
||||
import styles from "./ContactProduct.module.css";
|
||||
import Button from "../Button/Button";
|
||||
import { Carousel } from "antd";
|
||||
import ModalRequestForm from "../ModalRequestForm/ModalRequestForm";
|
||||
const imageUrl = "http://sprint-pro.com/images/banners/slide1/t1.png";
|
||||
import image1 from "../../assets/images/mainPage/_.jpg"
|
||||
import image2 from "../../assets/images/mainPage/orig.jpg"
|
||||
|
||||
interface ProductionSlide {
|
||||
id: number;
|
||||
image: string;
|
||||
label: string;
|
||||
}
|
||||
|
||||
const slides: ProductionSlide[] = [
|
||||
{
|
||||
id: 1,
|
||||
image: image1,
|
||||
label: ".",
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
image: image2,
|
||||
label: ".",
|
||||
},
|
||||
];
|
||||
|
||||
|
||||
const ProductionBanner: React.FC = () => {
|
||||
|
||||
const [open, setOpen] = useState(false);
|
||||
|
||||
const handleClick = () => {
|
||||
console.log('Кнопка нажата!');
|
||||
};
|
||||
|
||||
const carouselRef = useRef<any>(null);
|
||||
|
||||
console.log('ProductionBanner render, open:', open);
|
||||
|
||||
return (
|
||||
<div className={styles.wrapper}>
|
||||
<ModalRequestForm open={open} onClose={() => setOpen(false)} />
|
||||
<div className={styles.left}>
|
||||
<h2 className={styles.title}>КОНТРАКТНОЕ</h2>
|
||||
<h1 className={styles.subtitle}>ПРОИЗВОДСТВО</h1>
|
||||
|
||||
<Button
|
||||
label="СДЕЛАТЬ ЗАПРОС"
|
||||
onClick={() => setOpen(true)}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className={styles.right}>
|
||||
<Carousel
|
||||
ref={carouselRef}
|
||||
dots={false}
|
||||
effect="scrollx"
|
||||
className={styles.carousel}
|
||||
>
|
||||
{slides.map((s) => (
|
||||
<div key={s.id} className={styles.slide}>
|
||||
<img src={s.image} className={styles.image} alt="prod" />
|
||||
<div className={styles.label}>{s.label}</div>
|
||||
</div>
|
||||
))}
|
||||
</Carousel>
|
||||
|
||||
<div className={styles.arrows}>
|
||||
<button
|
||||
className={styles.arrow}
|
||||
onClick={() => carouselRef.current?.prev()}
|
||||
>
|
||||
←
|
||||
</button>
|
||||
<button
|
||||
className={styles.arrow}
|
||||
onClick={() => carouselRef.current?.next()}
|
||||
>
|
||||
→
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
export default ProductionBanner;
|
||||
@@ -0,0 +1,94 @@
|
||||
.footer {
|
||||
color: #bfbfbf;
|
||||
background: #000;
|
||||
padding: 60px 0;
|
||||
}
|
||||
|
||||
|
||||
.container {
|
||||
width: 90%;
|
||||
margin: 0 auto;
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
|
||||
.left {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 25px;
|
||||
}
|
||||
|
||||
|
||||
.logo {
|
||||
width: 160px;
|
||||
opacity: 0.9;
|
||||
}
|
||||
|
||||
|
||||
.copy {
|
||||
font-size: 14px;
|
||||
opacity: 0.7;
|
||||
}
|
||||
|
||||
|
||||
.center {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 14px;
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
|
||||
.center a {
|
||||
color: #bfbfbf;
|
||||
text-decoration: none;
|
||||
cursor: pointer;
|
||||
transition: 0.3s ease;
|
||||
}
|
||||
|
||||
|
||||
.center a:hover {
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
|
||||
.right {
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
|
||||
.phone {
|
||||
color: #fff;
|
||||
font-size: 20px;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
|
||||
.mail {
|
||||
margin-top: 6px;
|
||||
display: inline-block;
|
||||
font-size: 16px;
|
||||
color: #bfbfbf;
|
||||
}
|
||||
|
||||
|
||||
.mail:hover {
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
|
||||
/* Mobile */
|
||||
@media (max-width: 900px) {
|
||||
.container {
|
||||
flex-direction: column;
|
||||
gap: 40px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
|
||||
.right {
|
||||
text-align: center;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
import React from "react";
|
||||
import styles from "./Footer.module.css";
|
||||
import { NavLink } from "react-router-dom";
|
||||
|
||||
const Footer: React.FC = () => {
|
||||
return (
|
||||
<footer className={styles.footer}>
|
||||
<div className={styles.container}>
|
||||
<div className={styles.left}>
|
||||
<img src="/images/logo-footer.png" alt="logo" className={styles.logo} />
|
||||
<span className={styles.copy}>ТРК Спринт. 2017-2025 ©</span>
|
||||
</div>
|
||||
|
||||
|
||||
<div className={styles.center}>
|
||||
<NavLink to="about">O КОМПАНИИ</NavLink>
|
||||
<NavLink to="products">ПРОДУКЦИЯ</NavLink>
|
||||
<NavLink to="products">ПРАЙС-ЛИСТ</NavLink>
|
||||
</div>
|
||||
|
||||
|
||||
<div className={styles.right}>
|
||||
<div className={styles.phone}>+7 910 121 09 62</div>
|
||||
<a className={styles.mail}>rkplastic@mail.ru</a>
|
||||
</div>
|
||||
</div>
|
||||
</footer>
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
export default Footer;
|
||||
@@ -0,0 +1,146 @@
|
||||
.header {
|
||||
/*background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);*/
|
||||
background-color: white;
|
||||
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
|
||||
padding: 0;
|
||||
position: fixed;
|
||||
top: 0;
|
||||
z-index: 1000;
|
||||
backdrop-filter: blur(10px);
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.phoneBlock a{
|
||||
font-size: 10px;
|
||||
}
|
||||
|
||||
.headerMenu {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin: 0 auto;
|
||||
padding: 0 20px;
|
||||
}
|
||||
|
||||
.headerMenu a {
|
||||
position: relative;
|
||||
color: black;
|
||||
text-decoration: none;
|
||||
padding: 1.8rem 2rem;
|
||||
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
||||
font-weight: 500;
|
||||
font-size: 1.1rem;
|
||||
transition: all 0.3s ease;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.headerMenu a::before {
|
||||
content: '';
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
left: 50%;
|
||||
width: 0;
|
||||
height: 3px;
|
||||
background: linear-gradient(90deg, var(--lavander), var(--light-blue));
|
||||
transition: all 0.3s ease;
|
||||
transform: translateX(-50%);
|
||||
}
|
||||
|
||||
.headerMenu a::after {
|
||||
content: '';
|
||||
top: 0;
|
||||
left: -100%;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1), transparent);
|
||||
transition: left 0.5s ease;
|
||||
}
|
||||
|
||||
.headeLogo {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
color: white;
|
||||
text-decoration: none;
|
||||
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
||||
font-weight: 700;
|
||||
font-size: 1.4rem;
|
||||
transition: all 0.3s ease;
|
||||
}
|
||||
|
||||
.logoImage {
|
||||
height: 80px;
|
||||
border-radius: 8px;
|
||||
object-fit: contain;
|
||||
transition: all 0.3s ease;
|
||||
/*filter: brightness(0) invert(1);*/
|
||||
}
|
||||
|
||||
.headerMenu a:hover {
|
||||
background: rgba(255, 255, 255, 0.1);
|
||||
transform: translateY(-2px);
|
||||
}
|
||||
|
||||
.headerMenu a:hover::before {
|
||||
width: 80%;
|
||||
}
|
||||
|
||||
.headerMenu a:hover::after {
|
||||
left: 100%;
|
||||
}
|
||||
|
||||
.headerMenu a.active {
|
||||
background: rgba(255, 255, 255, 0.15);
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.headerMenu a.active::before {
|
||||
width: 100%;
|
||||
background: linear-gradient(90deg, var(--lavander), var(--light-blue));
|
||||
}
|
||||
|
||||
/* Анимация при загрузке */
|
||||
.headerMenu a {
|
||||
animation: slideIn 0.6s ease forwards;
|
||||
opacity: 0;
|
||||
transform: translateY(-20px);
|
||||
}
|
||||
|
||||
.headerMenu a:nth-child(1) { animation-delay: 0.1s; }
|
||||
.headerMenu a:nth-child(2) { animation-delay: 0.2s; }
|
||||
.headerMenu a:nth-child(3) { animation-delay: 0.3s; }
|
||||
|
||||
@keyframes slideIn {
|
||||
to {
|
||||
opacity: 1;
|
||||
transform: translateY(0);
|
||||
}
|
||||
}
|
||||
|
||||
/* Адаптивность */
|
||||
@media (max-width: 768px) {
|
||||
.headerMenu {
|
||||
flex-direction: column;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.headerMenu a {
|
||||
width: 100%;
|
||||
text-align: center;
|
||||
padding: 1rem;
|
||||
border-bottom: 1px solid rgba(255, 255, 255, 0.1);
|
||||
}
|
||||
|
||||
.headerMenu a:last-child {
|
||||
border-bottom: none;
|
||||
}
|
||||
}
|
||||
|
||||
/* Эффект пульсации при наведении на кнопку выхода */
|
||||
.headerMenu a[onclick]:hover {
|
||||
background: linear-gradient(135deg, #ff6b6b, #ee5a52);
|
||||
}
|
||||
|
||||
.headerMenu a[onclick]:hover::before {
|
||||
background: linear-gradient(90deg, #ffd89b, #ff6b6b);
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
import { NavLink } from "react-router-dom";
|
||||
import styles from './Header.module.css'
|
||||
import logo from '../../assets/images/Logo.jpg'
|
||||
|
||||
const Header = () =>{
|
||||
|
||||
return(
|
||||
<nav className={styles.header}>
|
||||
<div className={styles.headerMenu}>
|
||||
<div className={styles.headeLogo}>
|
||||
<img src={logo} alt="logo" className={styles.logoImage}/>
|
||||
<div className={styles.phoneBlock}>
|
||||
<a href="" className={styles.phoneBlock}>+7 905 010 58 40</a>
|
||||
</div>
|
||||
</div>
|
||||
<div className={styles.headerNav}>
|
||||
<NavLink to="/" end >ГЛАВНАЯ</NavLink>
|
||||
<NavLink to="about" >O КОМПАНИИ</NavLink>
|
||||
<NavLink to="products" >ПРОДУКЦИЯ</NavLink>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
)
|
||||
}
|
||||
|
||||
export default Header;
|
||||
@@ -0,0 +1,68 @@
|
||||
.modalBox {
|
||||
padding: 10px 20px 30px;
|
||||
}
|
||||
|
||||
.title {
|
||||
text-align: center;
|
||||
font-size: 28px;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.subtitle {
|
||||
text-align: center;
|
||||
margin-top: 6px;
|
||||
margin-bottom: 26px;
|
||||
color: #666;
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
.form {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 16px;
|
||||
}
|
||||
|
||||
.field {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.input {
|
||||
width: 93%;
|
||||
padding: 18px;
|
||||
font-size: 18px;
|
||||
border-radius: 12px;
|
||||
border: 1px solid #ddd;
|
||||
background: #f9f9f9;
|
||||
outline: none;
|
||||
transition: 0.2s;
|
||||
}
|
||||
|
||||
.input:focus {
|
||||
border-color: #ffd400;
|
||||
background: white;
|
||||
}
|
||||
|
||||
.textarea {
|
||||
height: 120px;
|
||||
resize: none;
|
||||
padding: 18px;
|
||||
border-radius: 12px;
|
||||
border: 1px solid #ddd;
|
||||
background: #f9f9f9;
|
||||
font-size: 18px;
|
||||
}
|
||||
|
||||
.error {
|
||||
font-size: 13px;
|
||||
color: #d33;
|
||||
position: absolute;
|
||||
bottom: -18px;
|
||||
left: 5px;
|
||||
}
|
||||
|
||||
.button {
|
||||
margin-top: 10px;
|
||||
width: 100%;
|
||||
height: 58px;
|
||||
font-size: 18px;
|
||||
}
|
||||
@@ -0,0 +1,202 @@
|
||||
import React from "react";
|
||||
import { Modal } from "antd";
|
||||
import { motion } from "framer-motion";
|
||||
import InputMask from "react-input-mask";
|
||||
import { useForm } from "react-hook-form";
|
||||
import * as yup from "yup";
|
||||
import { yupResolver } from "@hookform/resolvers/yup";
|
||||
import styles from "./ModalRequestForm.module.css";
|
||||
import Button from "../Button/Button";
|
||||
|
||||
// ✅ Схема валидации
|
||||
const schema = yup.object().shape({
|
||||
name: yup.string().required("Введите имя"),
|
||||
email: yup.string().email("Некорректный Email").required("Введите Email"),
|
||||
phone: yup.string().min(18, "Введите корректный номер").required("Введите номер"),
|
||||
message: yup.string().nullable(),
|
||||
});
|
||||
|
||||
interface Props {
|
||||
open: boolean;
|
||||
onClose: () => void;
|
||||
}
|
||||
|
||||
interface FormData {
|
||||
name: string;
|
||||
email: string;
|
||||
phone: string;
|
||||
message?: string | null;
|
||||
}
|
||||
|
||||
const ModalRequestForm: React.FC<Props> = ({ open, onClose }) => {
|
||||
console.log('ModalRequestForm render, open:', open);
|
||||
const {
|
||||
register,
|
||||
handleSubmit,
|
||||
formState: { errors, isSubmitting },
|
||||
reset,
|
||||
} = useForm({ resolver: yupResolver(schema) });
|
||||
|
||||
const handlePhoneInput = (e: React.ChangeEvent<HTMLInputElement>) => {
|
||||
let value = e.target.value.replace(/\D/g, '');
|
||||
|
||||
if (value.startsWith('7') || value.startsWith('8')) {
|
||||
value = value.substring(1);
|
||||
}
|
||||
|
||||
let formattedValue = '+7 ';
|
||||
|
||||
if (value.length > 0) {
|
||||
formattedValue += '(' + value.substring(0, 3);
|
||||
}
|
||||
if (value.length > 3) {
|
||||
formattedValue += ') ' + value.substring(3, 6);
|
||||
}
|
||||
if (value.length > 6) {
|
||||
formattedValue += '-' + value.substring(6, 8);
|
||||
}
|
||||
if (value.length > 8) {
|
||||
formattedValue += '-' + value.substring(8, 10);
|
||||
}
|
||||
|
||||
e.target.value = formattedValue;
|
||||
};
|
||||
|
||||
// ✅ Отправка данных на бэкенд
|
||||
const sendToBackend = async (data: FormData): Promise<boolean> => {
|
||||
try {
|
||||
const response = await fetch(`/api/requests`, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({
|
||||
...data,
|
||||
source: "website-form",
|
||||
timestamp: new Date().toISOString(),
|
||||
}),
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(`HTTP error! status: ${response.status}`);
|
||||
}
|
||||
|
||||
const result = await response.json();
|
||||
return result.success;
|
||||
} catch (error) {
|
||||
console.error("Error sending request:", error);
|
||||
throw new Error("Не удалось отправить заявку. Попробуйте позже.");
|
||||
}
|
||||
};
|
||||
|
||||
// ✅ Submit
|
||||
const onSubmit = async (data: FormData) => {
|
||||
try {
|
||||
await sendToBackend(data);
|
||||
|
||||
// Показываем уведомление об успехе
|
||||
Modal.success({
|
||||
title: "Заявка отправлена!",
|
||||
content: "Наш менеджер свяжется с вами в ближайшее время.",
|
||||
okText: "Хорошо",
|
||||
});
|
||||
|
||||
reset();
|
||||
onClose();
|
||||
} catch (error) {
|
||||
// Показываем ошибку
|
||||
Modal.error({
|
||||
title: "Ошибка",
|
||||
content: error instanceof Error ? error.message : "Произошла неизвестная ошибка",
|
||||
okText: "Понятно",
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<Modal
|
||||
open={open}
|
||||
footer={null}
|
||||
onCancel={onClose}
|
||||
centered
|
||||
width={620}
|
||||
closable={!isSubmitting}
|
||||
maskClosable={!isSubmitting}
|
||||
>
|
||||
<motion.div
|
||||
initial={{ opacity: 0, y: 40 }}
|
||||
animate={{ opacity: 1, y: 0 }}
|
||||
transition={{ duration: 0.35 }}
|
||||
className={styles.modalBox}
|
||||
>
|
||||
<h2 className={styles.title}>Контрактное производство</h2>
|
||||
<p className={styles.subtitle}>
|
||||
Заполните форму ниже, и наш менеджер свяжется с Вами
|
||||
</p>
|
||||
|
||||
<form onSubmit={handleSubmit(onSubmit)} className={styles.form}>
|
||||
<div className={styles.field}>
|
||||
<input
|
||||
className={styles.input}
|
||||
placeholder="Введите имя *"
|
||||
{...register("name")}
|
||||
disabled={isSubmitting}
|
||||
/>
|
||||
{errors.name && <span className={styles.error}>{errors.name.message}</span>}
|
||||
</div>
|
||||
|
||||
<div className={styles.field}>
|
||||
<input
|
||||
className={styles.input}
|
||||
placeholder="Введите email *"
|
||||
{...register("email")}
|
||||
disabled={isSubmitting}
|
||||
/>
|
||||
{errors.email && <span className={styles.error}>{errors.email.message}</span>}
|
||||
</div>
|
||||
|
||||
{/*<div className={styles.field}>
|
||||
<InputMask
|
||||
mask="+7 (999) 999-99-99"
|
||||
{...register("phone")}
|
||||
disabled={isSubmitting}
|
||||
>
|
||||
{(inputProps: any) => (
|
||||
<input
|
||||
className={styles.input}
|
||||
placeholder="Введите № телефона *"
|
||||
{...inputProps}
|
||||
/>
|
||||
)}
|
||||
</InputMask>
|
||||
{errors.phone && <span className={styles.error}>{errors.phone.message}</span>}
|
||||
</div>*/}
|
||||
<div className={styles.field}>
|
||||
<input
|
||||
className={styles.input}
|
||||
placeholder="+7 (___) ___-__-__ *"
|
||||
{...register("phone")}
|
||||
onInput={handlePhoneInput}
|
||||
disabled={isSubmitting}
|
||||
/>
|
||||
{errors.phone && <span className={styles.error}>{errors.phone.message}</span>}
|
||||
</div>
|
||||
|
||||
<textarea
|
||||
className={styles.textarea}
|
||||
placeholder="Задайте свой вопрос"
|
||||
{...register("message")}
|
||||
disabled={isSubmitting}
|
||||
/>
|
||||
|
||||
<Button
|
||||
label={isSubmitting ? "ОТПРАВКА..." : "СДЕЛАТЬ ЗАПРОС"}
|
||||
className={styles.button}
|
||||
/>
|
||||
</form>
|
||||
</motion.div>
|
||||
</Modal>
|
||||
);
|
||||
};
|
||||
|
||||
export default ModalRequestForm;
|
||||
@@ -0,0 +1,162 @@
|
||||
import React from "react";
|
||||
import { Modal } from "antd";
|
||||
import { motion } from "framer-motion";
|
||||
import { useForm } from "react-hook-form";
|
||||
import * as yup from "yup";
|
||||
import { yupResolver } from "@hookform/resolvers/yup";
|
||||
import styles from "./ModalRequestForm.module.css";
|
||||
import Button from "../Button/Button";
|
||||
import axios from "axios";
|
||||
|
||||
// ✅ Схема валидации
|
||||
const schema = yup.object().shape({
|
||||
name: yup.string().required("Введите имя"),
|
||||
email: yup.string().email("Некорректный Email").required("Введите Email"),
|
||||
phone: yup.string().min(18, "Введите корректный номер").required("Введите номер"),
|
||||
});
|
||||
|
||||
interface Props {
|
||||
open: boolean;
|
||||
onClose: () => void;
|
||||
}
|
||||
|
||||
interface FormData {
|
||||
name: string;
|
||||
email: string;
|
||||
phone: string;
|
||||
}
|
||||
|
||||
const PriceLisForm: React.FC<Props> = ({ open, onClose }) => {
|
||||
console.log('ModalRequestForm render, open:', open);
|
||||
const {
|
||||
register,
|
||||
handleSubmit,
|
||||
formState: { errors, isSubmitting },
|
||||
reset,
|
||||
} = useForm({ resolver: yupResolver(schema) });
|
||||
|
||||
const handlePhoneInput = (e: React.ChangeEvent<HTMLInputElement>) => {
|
||||
let value = e.target.value.replace(/\D/g, '');
|
||||
|
||||
if (value.startsWith('7') || value.startsWith('8')) {
|
||||
value = value.substring(1);
|
||||
}
|
||||
|
||||
let formattedValue = '+7 ';
|
||||
|
||||
if (value.length > 0) {
|
||||
formattedValue += '(' + value.substring(0, 3);
|
||||
}
|
||||
if (value.length > 3) {
|
||||
formattedValue += ') ' + value.substring(3, 6);
|
||||
}
|
||||
if (value.length > 6) {
|
||||
formattedValue += '-' + value.substring(6, 8);
|
||||
}
|
||||
if (value.length > 8) {
|
||||
formattedValue += '-' + value.substring(8, 10);
|
||||
}
|
||||
|
||||
e.target.value = formattedValue;
|
||||
};
|
||||
|
||||
const sendToBackend = async (data: FormData): Promise<boolean> => {
|
||||
try{
|
||||
const response = await axios.post("/api/requests", {
|
||||
...data,
|
||||
source: "website-form",
|
||||
timestamp: new Date().toISOString(),
|
||||
})
|
||||
|
||||
return response.data.success;
|
||||
}catch (error: any){
|
||||
console.error("Error sending request:", error);
|
||||
|
||||
throw new Error("Не удалось отправить заявку. Попробуйте позже.");
|
||||
}
|
||||
};
|
||||
|
||||
const onSubmit = async (data: FormData) => {
|
||||
try {
|
||||
await sendToBackend(data);
|
||||
|
||||
Modal.success({
|
||||
title: "Прайс-лист отправлен!",
|
||||
okText: "Хорошо",
|
||||
});
|
||||
|
||||
reset();
|
||||
onClose();
|
||||
} catch (error) {
|
||||
Modal.error({
|
||||
title: "Ошибка",
|
||||
content: error instanceof Error ? error.message : "Произошла неизвестная ошибка",
|
||||
okText: "Понятно",
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<Modal
|
||||
open={open}
|
||||
footer={null}
|
||||
onCancel={onClose}
|
||||
centered
|
||||
width={620}
|
||||
closable={!isSubmitting}
|
||||
maskClosable={!isSubmitting}
|
||||
>
|
||||
<motion.div
|
||||
initial={{ opacity: 0, y: 40 }}
|
||||
animate={{ opacity: 1, y: 0 }}
|
||||
transition={{ duration: 0.35 }}
|
||||
className={styles.modalBox}
|
||||
>
|
||||
<h2 className={styles.title}>СКАЧАЙТЕ ПРАЙС_ЛИСТ</h2>
|
||||
<p className={styles.subtitle}>
|
||||
Заполните форму ниже, и прайс-лист будт выслан вам на почту
|
||||
</p>
|
||||
|
||||
<form onSubmit={handleSubmit(onSubmit)} className={styles.form}>
|
||||
<div className={styles.field}>
|
||||
<input
|
||||
className={styles.input}
|
||||
placeholder="Введите имя *"
|
||||
{...register("name")}
|
||||
disabled={isSubmitting}
|
||||
/>
|
||||
{errors.name && <span className={styles.error}>{errors.name.message}</span>}
|
||||
</div>
|
||||
|
||||
<div className={styles.field}>
|
||||
<input
|
||||
className={styles.input}
|
||||
placeholder="Введите email *"
|
||||
{...register("email")}
|
||||
disabled={isSubmitting}
|
||||
/>
|
||||
{errors.email && <span className={styles.error}>{errors.email.message}</span>}
|
||||
</div>
|
||||
|
||||
<div className={styles.field}>
|
||||
<input
|
||||
className={styles.input}
|
||||
placeholder="+7 (___) ___-__-__ *"
|
||||
{...register("phone")}
|
||||
onInput={handlePhoneInput}
|
||||
disabled={isSubmitting}
|
||||
/>
|
||||
{errors.phone && <span className={styles.error}>{errors.phone.message}</span>}
|
||||
</div>
|
||||
|
||||
<Button
|
||||
label={isSubmitting ? "ОТПРАВКА..." : "СКАЧАТЬ ПРАЙС-ЛИСТ"}
|
||||
className={styles.button}
|
||||
/>
|
||||
</form>
|
||||
</motion.div>
|
||||
</Modal>
|
||||
);
|
||||
};
|
||||
|
||||
export default PriceLisForm;
|
||||
@@ -0,0 +1,125 @@
|
||||
.phoneIcon {
|
||||
font-size: 28px;
|
||||
color: #ffd400;
|
||||
}
|
||||
|
||||
.wrapper {
|
||||
width: 100%;
|
||||
background-image: url("");
|
||||
background-size: cover;
|
||||
background-position: center;
|
||||
padding: 120px 0;
|
||||
}
|
||||
|
||||
.inner {
|
||||
width: 90%;
|
||||
max-width: 1400px;
|
||||
margin: 0 auto;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.left {
|
||||
max-width: 45%;
|
||||
}
|
||||
|
||||
.title {
|
||||
font-size: 42px;
|
||||
font-weight: 700;
|
||||
color: #1a1a1a;
|
||||
margin-bottom: 25px;
|
||||
}
|
||||
|
||||
.text {
|
||||
font-size: 18px;
|
||||
line-height: 1.6;
|
||||
color: #2a2a2a;
|
||||
}
|
||||
|
||||
.right {
|
||||
max-width: 50%;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.phoneBlock {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.phoneNumber {
|
||||
font-size: 25px;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.phoneInfo {
|
||||
margin-left: 44px;
|
||||
margin-top: -5px;
|
||||
font-size: 14px;
|
||||
color: #555;
|
||||
}
|
||||
|
||||
.formLabel {
|
||||
margin-top: 40px;
|
||||
font-size: 18px;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.form {
|
||||
margin-top: 20px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 20px;
|
||||
}
|
||||
|
||||
.input {
|
||||
flex: 1;
|
||||
padding: 18px 24px;
|
||||
border-radius: 50px;
|
||||
border: none;
|
||||
font-size: 18px;
|
||||
outline: none;
|
||||
}
|
||||
|
||||
.button {
|
||||
height: 56px !important;
|
||||
padding: 0 36px !important;
|
||||
border-radius: 50px !important;
|
||||
}
|
||||
|
||||
/* --- MOBILE --- */
|
||||
|
||||
@media (max-width: 992px) {
|
||||
.inner {
|
||||
flex-direction: column;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.left,
|
||||
.right {
|
||||
max-width: 100%;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.phoneBlock {
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.phoneInfo {
|
||||
margin-left: 0;
|
||||
}
|
||||
|
||||
.form {
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.input {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.button {
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
import React from "react";
|
||||
import styles from "./QuestionsBlock.module.css";
|
||||
import Button from "../Button/Button";
|
||||
import { PhoneOutlined } from "@ant-design/icons";
|
||||
import PhoneRequest from "../../features/MainPage/PhoneRequest";
|
||||
|
||||
const QuestionsBlock: React.FC = () => {
|
||||
|
||||
const handleClick = () => {
|
||||
console.log('Кнопка нажата!');
|
||||
};
|
||||
|
||||
return (
|
||||
<section className={styles.wrapper}>
|
||||
<div className={styles.inner}>
|
||||
{/* LEFT TEXT */}
|
||||
<div className={styles.left}>
|
||||
<h2 className={styles.title}>ЕСТЬ ВОПРОСЫ?</h2>
|
||||
|
||||
<p className={styles.text}>
|
||||
Мы готовы ответить на ваши вопросы <br />
|
||||
и предоставить всю необходимую информацию <br />
|
||||
о сотрудничестве и товаре.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
{/* RIGHT CONTENT */}
|
||||
<div className={styles.right}>
|
||||
<div className={styles.phoneBlock}>
|
||||
<PhoneOutlined className={styles.phoneIcon} />
|
||||
<span className={styles.phoneNumber}>8 800 707 25 58</span>
|
||||
|
||||
<div className={styles.phoneInfo}>
|
||||
Звоните с понедельника по пятницу <br /> c 09:00 до 18:00 (по Москве)
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p className={styles.formLabel}>
|
||||
Или оставьте заявку и мы вам перезвоним
|
||||
</p>
|
||||
|
||||
{/* FORM */}
|
||||
{/*<div className={styles.form}>
|
||||
<input
|
||||
type="text"
|
||||
placeholder="+7 (___) ___-__-__"
|
||||
className={styles.input}
|
||||
/>
|
||||
<Button
|
||||
label="ОТПРАВИТЬ"
|
||||
onClick={handleClick}
|
||||
/>
|
||||
</div>*/}
|
||||
<PhoneRequest/>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
);
|
||||
};
|
||||
|
||||
export default QuestionsBlock;
|
||||
@@ -0,0 +1,26 @@
|
||||
.form {
|
||||
margin-top: 20px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 20px;
|
||||
}
|
||||
|
||||
.input {
|
||||
flex: 1;
|
||||
padding: 18px 24px;
|
||||
border-radius: 50px;
|
||||
border: none;
|
||||
font-size: 18px;
|
||||
outline: none;
|
||||
}
|
||||
|
||||
.error {
|
||||
color: red;
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
.success {
|
||||
color: green;
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,105 @@
|
||||
import React, { useState } from "react";
|
||||
import axios from "axios";
|
||||
import styles from "./MainPage.module.css";
|
||||
import Button from "../../components/Button/Button";
|
||||
|
||||
interface Props {
|
||||
onSend?: (phone: string) => Promise<void>;
|
||||
}
|
||||
|
||||
const PhoneRequest: React.FC<Props> = ({ onSend }) => {
|
||||
const [phone, setPhone] = useState("");
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [success, setSuccess] = useState(false);
|
||||
const [error, setError] = useState("");
|
||||
|
||||
// Автоформатирование "+7 (999) 999-99-99"
|
||||
const formatPhone = (value: string) => {
|
||||
const digits = value.replace(/\D/g, "");
|
||||
|
||||
let result = "+7 ";
|
||||
if (digits.length > 1) result += "(" + digits.substring(1, 4);
|
||||
if (digits.length >= 4) result += ") " + digits.substring(4, 7);
|
||||
if (digits.length >= 7) result += "-" + digits.substring(7, 9);
|
||||
if (digits.length >= 9) result += "-" + digits.substring(9, 11);
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
const handlePhoneChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
||||
let v = e.target.value;
|
||||
|
||||
if (v.replace(/\D/g, "").length === 0) {
|
||||
setPhone("");
|
||||
return;
|
||||
}
|
||||
|
||||
if (v[0] !== "+") {
|
||||
v = "+7" + v;
|
||||
}
|
||||
|
||||
setPhone(formatPhone(v));
|
||||
};
|
||||
|
||||
const validatePhone = (p: string) => {
|
||||
return p.replace(/\D/g, "").length === 11;
|
||||
};
|
||||
|
||||
const handleSubmit = async () => {
|
||||
setError("");
|
||||
|
||||
if (!validatePhone(phone)) {
|
||||
setError("Введите корректный номер телефона");
|
||||
return;
|
||||
}
|
||||
|
||||
setLoading(true);
|
||||
|
||||
try {
|
||||
if (onSend) {
|
||||
await onSend(phone);
|
||||
} else {
|
||||
|
||||
await axios.post("/api/contact/send-phone", { phone });
|
||||
}
|
||||
|
||||
setSuccess(true);
|
||||
setPhone("");
|
||||
|
||||
setTimeout(() => setSuccess(false), 3000);
|
||||
} catch (e) {
|
||||
setError("Ошибка отправки. Попробуйте позже.");
|
||||
}
|
||||
|
||||
setLoading(false);
|
||||
};
|
||||
|
||||
return (
|
||||
<div className={styles.form}>
|
||||
<input
|
||||
className={styles.input}
|
||||
placeholder="+7 (___) ___-__-__"
|
||||
type="tel"
|
||||
value={phone}
|
||||
onChange={handlePhoneChange}
|
||||
maxLength={18}
|
||||
/>
|
||||
<Button
|
||||
label="ОТПРАВИТЬ"
|
||||
onClick={handleSubmit}
|
||||
/>
|
||||
{/*<button
|
||||
className={styles.button}
|
||||
onClick={handleSubmit}
|
||||
disabled={loading}
|
||||
>
|
||||
{loading ? "..." : "ОТПРАВИТЬ"}
|
||||
</button>*/}
|
||||
|
||||
{error && <p className={styles.error}>{error}</p>}
|
||||
{success && <p className={styles.success}>Заявка отправлена!</p>}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default PhoneRequest;
|
||||
@@ -0,0 +1,101 @@
|
||||
.catalogWrapper {
|
||||
display: flex;
|
||||
padding: 20px;
|
||||
gap: 40px;
|
||||
}
|
||||
|
||||
/*.sidebar {
|
||||
width: 260px;
|
||||
}*/
|
||||
|
||||
.productsSection {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
|
||||
gap: 24px;
|
||||
}
|
||||
|
||||
.card {
|
||||
background: #fff;
|
||||
border: 1px solid #e5e5e5;
|
||||
padding: 20px;
|
||||
position: relative;
|
||||
transition: all 0.3s;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.card:hover {
|
||||
transform: translateY(-3px);
|
||||
box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
.card img {
|
||||
max-width: 160px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
.name {
|
||||
margin-top: 10px;
|
||||
font-size: 14px;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.plus {
|
||||
position: absolute;
|
||||
right: 20px;
|
||||
bottom: 20px;
|
||||
font-size: 22px;
|
||||
background: none;
|
||||
border: none;
|
||||
cursor: pointer;
|
||||
color: #ffcc00;
|
||||
}
|
||||
|
||||
/*SidebarCategories*/
|
||||
.sidebar { width: 260px; padding: 20px 0; }
|
||||
.title { font-weight:700; font-size:14px; margin-bottom:16px; }
|
||||
.list { list-style:none; padding:0; margin:0; }
|
||||
.item { padding:8px 0; color:#666; cursor:pointer; transition:color .15s; }
|
||||
.item:hover { color:#000; }
|
||||
.active { color:#000; font-weight:700; }
|
||||
/*SidebarCategories*/
|
||||
|
||||
/*Pagination*/
|
||||
.wrap{ display:flex; gap:12px; align-items:center; justify-content:center; margin:30px 0;}
|
||||
.go{ padding:8px 14px; background:#fff;border:1px solid #ddd; cursor:pointer;}
|
||||
.pages{ display:flex; gap:8px;}
|
||||
.page{ padding:8px 12px; background:#fff;border:1px solid #ddd; cursor:pointer;}
|
||||
.active{ background:#ffd400; font-weight:700; border-color:#ffd400;}
|
||||
button:disabled{ opacity:.5; cursor:default;}
|
||||
/*Pagination*/
|
||||
|
||||
/*CategoryFilters*/
|
||||
.filtersWrap { margin:24px 0; }
|
||||
.title { font-weight:700; margin-bottom:12px; }
|
||||
.block { margin-bottom:16px; }
|
||||
.blockTitle{ font-weight:600; margin-bottom:8px; }
|
||||
.opt { display:block; margin:6px 0; font-size:14px; }
|
||||
.actions { margin-top:12px; display:flex; gap:12px; }
|
||||
.apply { background:#ffd400; border:none; padding:10px 22px; border-radius:26px; cursor:pointer;}
|
||||
.reset { background:#fff; border:1px solid #ddd; padding:8px 16px; cursor:pointer;}
|
||||
/*CategoryFilters*/
|
||||
|
||||
.categoryGrid { display:grid; grid-template-columns:repeat(3, 1fr); gap:20px; }
|
||||
.categoryCard { border:1px solid #e7e7e7; padding:26px; text-align:center; cursor:pointer; transition:box-shadow .15s; }
|
||||
.categoryCard:hover { box-shadow:0 6px 18px rgba(0,0,0,0.06); }
|
||||
.categoryImg { max-width:160px; height:auto; display:block; margin:0 auto 14px; }
|
||||
.categoryName { font-weight:700; }
|
||||
@media(max-width:900px){ .grid{grid-template-columns:repeat(2,1fr)} }
|
||||
@media(max-width:600px){ .grid{grid-template-columns:1fr} }
|
||||
|
||||
@media (max-width: 900px) {
|
||||
.catalogWrapper {
|
||||
flex-direction: column;
|
||||
}
|
||||
.sidebar {
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
import React from "react";
|
||||
import styles from "./Catalog.module.css";
|
||||
import { useAppSelector } from "../../app/hooks";
|
||||
|
||||
interface Props { onSelect?: (id:number) => void }
|
||||
const CategoryCards: React.FC<Props> = ({ onSelect }) => {
|
||||
const categories = useAppSelector(s => s.categories.items);
|
||||
|
||||
return (
|
||||
<div className={styles.categoryGrid}>
|
||||
{categories.map(c => (
|
||||
<div key={c.id} className={styles.categoryGard} onClick={() => onSelect?.(c.id)}>
|
||||
{c.image ? <img src={c.image} alt={c.name} className={styles.categoryImg} /> : <img src="/mnt/data/c9552f5e-1741-4845-8d5f-9d438f068636.png" alt={c.name} className={styles.categoryImg} />}
|
||||
<div className={styles.categoryName}>{c.name}</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
export default CategoryCards;
|
||||
@@ -0,0 +1,23 @@
|
||||
import React from "react";
|
||||
import styles from "./Catalog.module.css";
|
||||
import { useAppSelector } from "../../app/hooks";
|
||||
|
||||
interface Props {
|
||||
onSelect?: (id:number) => void
|
||||
}
|
||||
|
||||
const CategoryCards: React.FC<Props> = ({ onSelect }) => {
|
||||
const categories = useAppSelector(s => s.categories.items);
|
||||
|
||||
return (
|
||||
<div className={styles.grid}>
|
||||
{categories.map(c => (
|
||||
<div key={c.id} className={styles.card} onClick={() => onSelect?.(c.id)}>
|
||||
{c.image ? <img src={c.image} alt={c.name} className={styles.img} /> : <img src="/mnt/data/c9552f5e-1741-4845-8d5f-9d438f068636.png" alt={c.name} className={styles.img} />}
|
||||
<div className={styles.name}>{c.name}</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
export default CategoryCards;
|
||||
@@ -0,0 +1,58 @@
|
||||
import { useAppSelector, useAppDispatch } from "../../app/hooks";
|
||||
import { setSelectedCategory } from "./categoriesSlice";
|
||||
import styles from "./Catalog.module.css";
|
||||
import { setFilters, fetchProductsByCategory, setPage } from "./productsSlice";
|
||||
import { useState } from "react";
|
||||
|
||||
export const CategoryFilters = () => {
|
||||
const dispatch = useAppDispatch();
|
||||
const { items: cats, selectedCategoryId } = useAppSelector(s => s.categories);
|
||||
const products = useAppSelector(s => s.products);
|
||||
const cat = cats.find(x => x.id === selectedCategoryId);
|
||||
const [local, setLocal] = useState<Record<string, (string|number)[]>>({});
|
||||
|
||||
const apply = () => {
|
||||
dispatch(setFilters(local));
|
||||
dispatch(setPage(1));
|
||||
if (selectedCategoryId) dispatch(fetchProductsByCategory({ categoryId: selectedCategoryId, page: 1, limit: products.limit, filters: local }));
|
||||
};
|
||||
|
||||
if (!cat) return null;
|
||||
return (
|
||||
<div className={styles.filtersWrap}>
|
||||
<h4 className={styles.title}>ПАРАМЕТРЫ</h4>
|
||||
<div className={styles.blocks}>
|
||||
{cat.atributes.map(attr => (
|
||||
<div key={attr.id} className={styles.block}>
|
||||
<div className={styles.blockTitle}>{`${attr.name}:`}</div>
|
||||
<div className={styles.options}>
|
||||
{attr.vals.map(v => {
|
||||
const key = `attr_${attr.id}`;
|
||||
const active = local[key]?.includes(v.val);
|
||||
return (
|
||||
<label key={v.id} className={styles.opt}>
|
||||
<input type="checkbox"
|
||||
checked={!!active}
|
||||
onChange={() => {
|
||||
const cur = local[key] ?? [];
|
||||
const next = cur.includes(v.val) ? cur.filter(x => x !== v.val) : [...cur, v.val];
|
||||
setLocal({ ...local, [key]: next });
|
||||
}} />
|
||||
{v.val}
|
||||
</label>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
|
||||
<div className={styles.actions}>
|
||||
<button className={styles.apply} onClick={apply}>Показать</button>
|
||||
<button className={styles.reset} onClick={() => { setLocal({}); dispatch(setFilters({})); dispatch(setPage(1)); if (selectedCategoryId) dispatch(fetchProductsByCategory({ categoryId: selectedCategoryId, page: 1, limit: products.limit })); }}>Сбросить</button>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default CategoryFilters;
|
||||
@@ -0,0 +1,34 @@
|
||||
import React from "react";
|
||||
import styles from "./Catalog.module.css";
|
||||
import { useAppSelector, useAppDispatch } from "../../app/hooks";
|
||||
import { setPage, fetchProductsByCategory } from "./productsSlice";
|
||||
|
||||
interface Props { categoryId: number }
|
||||
|
||||
const Pagination: React.FC<Props> = ({ categoryId }) => {
|
||||
const dispatch = useAppDispatch();
|
||||
const { total, page, limit } = useAppSelector(s => s.products);
|
||||
const totalPages = Math.ceil(total / limit);
|
||||
if (totalPages <= 1) return null;
|
||||
|
||||
const go = (p:number) => {
|
||||
dispatch(setPage(p));
|
||||
dispatch(fetchProductsByCategory({ categoryId, page: p, limit }));
|
||||
window.scrollTo({ top: 200, behavior: "smooth" });
|
||||
}
|
||||
|
||||
return (
|
||||
<div className={styles.wrap}>
|
||||
<button className={styles.go} onClick={() => go(1)} disabled={page===1}>В НАЧАЛО</button>
|
||||
|
||||
<div className={styles.pages}>
|
||||
{Array.from({length: totalPages}, (_,i) => i+1).map(p => (
|
||||
<button key={p} className={`${styles.page} ${p===page?styles.active:""}`} onClick={() => go(p)}>{p}</button>
|
||||
))}
|
||||
</div>
|
||||
|
||||
<button className={styles.go} onClick={() => go(totalPages)} disabled={page===totalPages}>В КОНЕЦ</button>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
export default Pagination;
|
||||
@@ -0,0 +1,25 @@
|
||||
import React from "react";
|
||||
import type { Product } from "../../types/product";
|
||||
import styles from "./Catalog.module.css";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
|
||||
interface Props {
|
||||
product: Product;
|
||||
}
|
||||
|
||||
const ProductCard: React.FC<Props> = ({ product }) => {
|
||||
const navigate = useNavigate();
|
||||
|
||||
return (
|
||||
<div
|
||||
className={styles.card}
|
||||
onClick={() => navigate(`/product/${product.id}`)}
|
||||
>
|
||||
<img src={product.image} alt={product.name} />
|
||||
<p className={styles.name}>{product.name}</p>
|
||||
<button className={styles.plus}>+</button>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default ProductCard;
|
||||
@@ -0,0 +1,19 @@
|
||||
import React from "react";
|
||||
import ProductCard from "./ProductCard";
|
||||
import styles from "./Catalog.module.css";
|
||||
import { useAppSelector } from "../../app/hooks";
|
||||
|
||||
|
||||
const ProductGrid: React.FC = () => {
|
||||
const {items: products} = useAppSelector(p => p.products)
|
||||
|
||||
return (
|
||||
<div className={styles.grid}>
|
||||
{products.map((p) => (
|
||||
<ProductCard key={p.id} product={p} />
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default ProductGrid;
|
||||
@@ -0,0 +1,39 @@
|
||||
import React, { useEffect } from "react";
|
||||
import styles from "./Catalog.module.css";
|
||||
import { useAppDispatch, useAppSelector } from "../../app/hooks";
|
||||
import { fetchCategories, setSelectedCategory } from "./categoriesSlice";
|
||||
import { fetchProductsByCategory, setFilters, setPage } from "./productsSlice";
|
||||
|
||||
const SidebarCategories: React.FC = () => {
|
||||
const dispatch = useAppDispatch();
|
||||
const { items, selectedCategoryId, loading } = useAppSelector(s => s.categories);
|
||||
|
||||
useEffect(() => {
|
||||
dispatch(fetchCategories());
|
||||
}, [dispatch]);
|
||||
|
||||
const onClick = (catId: number) => {
|
||||
dispatch(setSelectedCategory(catId));
|
||||
dispatch(setFilters({})); // сброс фильтров
|
||||
dispatch(setPage(1));
|
||||
dispatch(fetchProductsByCategory({ categoryId: catId, page: 1, limit: 9 }));
|
||||
};
|
||||
return(
|
||||
<aside className={styles.sidebar}>
|
||||
<h3 className={styles.title}>КАТЕГОРИИ ТОВАРОВ</h3>
|
||||
{loading ? <p>Загрузка...</p> : (
|
||||
<ul className={styles.list}>
|
||||
{items.map(cat => (
|
||||
<li key={cat.id}
|
||||
className={`${styles.item} ${selectedCategoryId === cat.id ? styles.active : ""}`}
|
||||
onClick={() => onClick(cat.id)}>
|
||||
{cat.name}
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
)}
|
||||
</aside>
|
||||
)
|
||||
}
|
||||
|
||||
export default SidebarCategories;
|
||||
@@ -0,0 +1,52 @@
|
||||
import { createSlice, createAsyncThunk } from "@reduxjs/toolkit";
|
||||
import type { Category } from "../../types/categories";
|
||||
import axios from "axios";
|
||||
|
||||
export const fetchCategories = createAsyncThunk<Category[]>(
|
||||
"categories/fetchCategories",
|
||||
async () => {
|
||||
const res = await axios.get<Category[]>("/api/categories");
|
||||
return res.data;
|
||||
}
|
||||
);
|
||||
|
||||
interface CategoriesState {
|
||||
items: Category[];
|
||||
loading: boolean;
|
||||
error: string | null;
|
||||
selectedCategoryId: number | null;
|
||||
}
|
||||
|
||||
const initialState: CategoriesState = {
|
||||
items: [],
|
||||
loading: false,
|
||||
error: null,
|
||||
selectedCategoryId: null
|
||||
};
|
||||
|
||||
const categoriesSlice = createSlice({
|
||||
name: "categories",
|
||||
initialState,
|
||||
reducers: {
|
||||
setSelectedCategory(state, action) {
|
||||
state.selectedCategoryId = action.payload;
|
||||
}
|
||||
},
|
||||
extraReducers: builder => {
|
||||
builder
|
||||
.addCase(fetchCategories.pending, state => {
|
||||
state.loading = true;
|
||||
})
|
||||
.addCase(fetchCategories.fulfilled, (state, action) => {
|
||||
state.items = action.payload;
|
||||
state.loading = false;
|
||||
})
|
||||
.addCase(fetchCategories.rejected, (state) => {
|
||||
state.loading = false;
|
||||
state.error = "Ошибка загрузки категорий";
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
export const { setSelectedCategory } = categoriesSlice.actions;
|
||||
export default categoriesSlice.reducer;
|
||||
@@ -0,0 +1,110 @@
|
||||
import { createAsyncThunk, createSlice } from "@reduxjs/toolkit";
|
||||
import type {PayloadAction} from "@reduxjs/toolkit";
|
||||
import client from "../../api/client";
|
||||
import type { Product } from "../../types/product";
|
||||
import axios from "axios";
|
||||
|
||||
interface FetchParams {
|
||||
categoryId: number;
|
||||
page?: number;
|
||||
limit?: number;
|
||||
filters?: Record<string, string | number | (string | number)[]>;
|
||||
}
|
||||
|
||||
interface FetchResponce{
|
||||
items: Product[],
|
||||
total: number,
|
||||
page: number,
|
||||
limit: number,
|
||||
}
|
||||
|
||||
export const fetchProductsByCategory = createAsyncThunk(
|
||||
"products/fetchByCategory",
|
||||
async (params: FetchParams) => {
|
||||
const { categoryId, page = 1, limit = 9, filters} = params;
|
||||
const qp = new URLSearchParams();
|
||||
qp.append("categoryId", String(categoryId));
|
||||
qp.append("page", String(page));
|
||||
qp.append("limit", String(limit));
|
||||
if (filters) {
|
||||
Object.keys(filters).forEach((k) => {
|
||||
const v = filters[k];
|
||||
if (Array.isArray(v)) qp.append(k, v.join(","));
|
||||
else qp.append(k, String(v));
|
||||
});
|
||||
}
|
||||
const res = await client.get<FetchResponce>(`/products?${qp.toString()}`);
|
||||
// ожидаем { items: Product[], total: number, page: number, limit: number }
|
||||
return res.data;
|
||||
}
|
||||
);
|
||||
|
||||
export const fetchProductById = createAsyncThunk(
|
||||
"product/fetchById",
|
||||
async (id: string) => {
|
||||
const response = await axios.get(`/api/products/${id}`);
|
||||
return response.data;
|
||||
}
|
||||
);
|
||||
|
||||
interface ProductsState {
|
||||
items: Product[];
|
||||
total: number;
|
||||
page: number;
|
||||
limit: number;
|
||||
loading: boolean;
|
||||
error: string | null;
|
||||
filtersApplied: Record<string, (string|number)[]>;
|
||||
}
|
||||
|
||||
const initialState: ProductsState = {
|
||||
items: [],
|
||||
total: 0,
|
||||
page: 1,
|
||||
limit: 9,
|
||||
loading: false,
|
||||
error: null,
|
||||
filtersApplied: {},
|
||||
};
|
||||
|
||||
const slice = createSlice({
|
||||
name: "products",
|
||||
initialState,
|
||||
reducers: {
|
||||
setPage(state, action: PayloadAction<number>) {
|
||||
state.page = action.payload;
|
||||
},
|
||||
setLimit(state, action: PayloadAction<number>) {
|
||||
state.limit = action.payload;
|
||||
},
|
||||
setFilters(state, action: PayloadAction<ProductsState["filtersApplied"]>) {
|
||||
state.filtersApplied = action.payload;
|
||||
},
|
||||
resetProducts(state) {
|
||||
state.items = [];
|
||||
state.total = 0;
|
||||
state.page = 1;
|
||||
}
|
||||
},
|
||||
extraReducers: (builder) => {
|
||||
builder
|
||||
.addCase(fetchProductsByCategory.pending, (s) => {
|
||||
s.loading = true;
|
||||
s.error = null;
|
||||
})
|
||||
.addCase(fetchProductsByCategory.fulfilled, (s, a) => {
|
||||
s.loading = false;
|
||||
s.items = a.payload.items;
|
||||
s.total = a.payload.total;
|
||||
s.page = a.payload.page ?? s.page;
|
||||
s.limit = a.payload.limit ?? s.limit;
|
||||
})
|
||||
.addCase(fetchProductsByCategory.rejected, (s, a) => {
|
||||
s.loading = false;
|
||||
s.error = a.error.message ?? "Ошибка";
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
export const { setPage, setLimit, setFilters, resetProducts } = slice.actions;
|
||||
export default slice.reducer;
|
||||
@@ -0,0 +1,77 @@
|
||||
:root {
|
||||
font-family: system-ui, Avenir, Helvetica, Arial, sans-serif;
|
||||
line-height: 1.5;
|
||||
font-weight: 400;
|
||||
|
||||
color-scheme: light dark;
|
||||
color: rgba(255, 255, 255, 0.87);
|
||||
background-color: #242424;
|
||||
|
||||
font-synthesis: none;
|
||||
text-rendering: optimizeLegibility;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
-moz-osx-font-smoothing: grayscale;
|
||||
|
||||
--darkblue: #1e11a9;
|
||||
--lightblue: #00adef;
|
||||
|
||||
}
|
||||
|
||||
/*a {
|
||||
font-weight: 500;
|
||||
color: #646cff;
|
||||
text-decoration: inherit;
|
||||
}
|
||||
a:hover {
|
||||
color: #535bf2;
|
||||
}*/
|
||||
|
||||
#root {
|
||||
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
body {
|
||||
margin: 0;
|
||||
/*display: flex;
|
||||
place-items: center;*/
|
||||
min-width: 320px;
|
||||
min-height: 100vh;
|
||||
}
|
||||
|
||||
/*h1 {
|
||||
font-size: 3.2em;
|
||||
line-height: 1.1;
|
||||
}
|
||||
|
||||
button {
|
||||
border-radius: 8px;
|
||||
border: 1px solid transparent;
|
||||
padding: 0.6em 1.2em;
|
||||
font-size: 1em;
|
||||
font-weight: 500;
|
||||
font-family: inherit;
|
||||
background-color: #1a1a1a;
|
||||
cursor: pointer;
|
||||
transition: border-color 0.25s;
|
||||
}
|
||||
button:hover {
|
||||
border-color: #646cff;
|
||||
}
|
||||
button:focus,
|
||||
button:focus-visible {
|
||||
outline: 4px auto -webkit-focus-ring-color;
|
||||
}*/
|
||||
|
||||
@media (prefers-color-scheme: light) {
|
||||
:root {
|
||||
color: #213547;
|
||||
background-color: #ffffff;
|
||||
}
|
||||
a:hover {
|
||||
color: #747bff;
|
||||
}
|
||||
button {
|
||||
background-color: #f9f9f9;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
import { StrictMode } from 'react'
|
||||
import { createRoot } from 'react-dom/client'
|
||||
import './index.css'
|
||||
import { BrowserRouter } from 'react-router'
|
||||
import AppRoutes from './app/routes.tsx'
|
||||
import { Provider } from "react-redux";
|
||||
import { store } from "./app/store";
|
||||
|
||||
createRoot(document.getElementById('root')!).render(
|
||||
<StrictMode>
|
||||
<Provider store={store}>
|
||||
<BrowserRouter>
|
||||
<AppRoutes />
|
||||
</BrowserRouter>
|
||||
</Provider>
|
||||
</StrictMode>,
|
||||
)
|
||||
@@ -0,0 +1,9 @@
|
||||
const About = () =>{
|
||||
return(
|
||||
<>
|
||||
<p>gggggggg</p>
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
export default About;
|
||||
@@ -0,0 +1,93 @@
|
||||
.page {
|
||||
background: #f5f5f5;
|
||||
min-height: 100vh;
|
||||
}
|
||||
|
||||
.top {
|
||||
background: #000;
|
||||
padding: 15px 40px;
|
||||
}
|
||||
|
||||
.back {
|
||||
color: white;
|
||||
background: none;
|
||||
border: none;
|
||||
cursor: pointer;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.hero {
|
||||
display: flex;
|
||||
min-height: 500px;
|
||||
}
|
||||
|
||||
.left {
|
||||
flex: 1;
|
||||
background: #fff;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.left img {
|
||||
max-width: 400px;
|
||||
}
|
||||
|
||||
.right {
|
||||
flex: 1;
|
||||
background: linear-gradient(
|
||||
rgba(0, 0, 0, 0.7),
|
||||
rgba(0, 0, 0, 0.7)
|
||||
),
|
||||
url("/bg.jpg");
|
||||
color: white;
|
||||
padding: 80px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.breadcrumbs {
|
||||
color: #f5c400;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.download {
|
||||
margin-top: 30px;
|
||||
background: #f5c400;
|
||||
border: none;
|
||||
padding: 15px 40px;
|
||||
border-radius: 30px;
|
||||
font-weight: bold;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.tabs {
|
||||
display: flex;
|
||||
border-top: 1px solid #ddd;
|
||||
}
|
||||
|
||||
.tabs button {
|
||||
flex: 1;
|
||||
padding: 20px;
|
||||
border: none;
|
||||
background: #eee;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.active {
|
||||
background: white;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.content {
|
||||
padding: 40px;
|
||||
background: white;
|
||||
}
|
||||
|
||||
.attrRow {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
padding: 10px 0;
|
||||
border-bottom: 1px solid #eee;
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
import { useEffect, useState } from "react";
|
||||
import { useParams, useNavigate } from "react-router-dom";
|
||||
import { useAppDispatch, useAppSelector } from "../../app/hooks";
|
||||
import { fetchProductById } from "../../features/catalog/productsSlice";
|
||||
import styles from "./ProductPage.module.css";
|
||||
import type { CategoryAtributes, CategoryAtrVals } from "../../types/categories";
|
||||
|
||||
const ItemPage = () => {
|
||||
const { id } = useParams();
|
||||
const dispatch = useAppDispatch();
|
||||
const navigate = useNavigate();
|
||||
const { items, loading } = useAppSelector((state) => state.products);
|
||||
const { items: cats, selectedCategoryId } = useAppSelector(s => s.categories);
|
||||
|
||||
const [activeTab, setActiveTab] = useState<"desc" | "chars">("desc");
|
||||
|
||||
useEffect(() => {
|
||||
if (id) dispatch(fetchProductById(id));
|
||||
}, [id]);
|
||||
|
||||
const product = items.find((item) => item.id === Number(id));
|
||||
const category = cats.find((cat) => cat.id === Number(selectedCategoryId))
|
||||
|
||||
if ((loading || !product)) return <div>Загрузка...</div>;
|
||||
if(!category) return <div>Загрузка...</div>;
|
||||
|
||||
return (
|
||||
<div className={styles.page}>
|
||||
<div className={styles.top}>
|
||||
<button className={styles.back} onClick={() => navigate(-1)}>
|
||||
← НАЗАД В КАТАЛОГ
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div className={styles.hero}>
|
||||
<div className={styles.left}>
|
||||
<img src={product.image} alt={product.name} />
|
||||
</div>
|
||||
|
||||
<div className={styles.right}>
|
||||
<div className={styles.breadcrumbs}>
|
||||
ГЛАВНАЯ / {category?.name} / {product.name}
|
||||
</div>
|
||||
|
||||
<h1>{product.name}</h1>
|
||||
|
||||
<p className={styles.short}>{product.description}</p>
|
||||
|
||||
<button className={styles.download}>
|
||||
СКАЧАТЬ ПРАЙС-ЛИСТ
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className={styles.tabs}>
|
||||
<button
|
||||
className={activeTab === "desc" ? styles.active : ""}
|
||||
onClick={() => setActiveTab("desc")}
|
||||
>
|
||||
ОПИСАНИЕ
|
||||
</button>
|
||||
<button
|
||||
className={activeTab === "chars" ? styles.active : ""}
|
||||
onClick={() => setActiveTab("chars")}
|
||||
>
|
||||
ХАРАКТЕРИСТИКИ
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div className={styles.content}>
|
||||
{activeTab === "desc" && (
|
||||
<div>
|
||||
<h2>ОПИСАНИЕ</h2>
|
||||
<p>{product.description}</p>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{activeTab === "chars" && (
|
||||
<div>
|
||||
<h2>ХАРАКТЕРИСТИКИ</h2>
|
||||
{category.atributes?.map((attr: CategoryAtributes) => (
|
||||
<div key={attr.id} className={styles.attrRow}>
|
||||
<span>{attr.name}</span>
|
||||
{attr.vals?.map((val: CategoryAtrVals) => (
|
||||
<div key={val.id}>
|
||||
<span>{val.val}</span>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default ItemPage;
|
||||
@@ -0,0 +1,4 @@
|
||||
.content{
|
||||
background-color: white;
|
||||
margin: 0;
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
import Header from "../../components/Header/Header";
|
||||
import { Outlet } from "react-router-dom";
|
||||
import styles from './Layout.module.css'
|
||||
import Footer from "../../components/Footer/Footer";
|
||||
|
||||
const Layout = () =>{
|
||||
|
||||
return(
|
||||
/*token ?*/ <div className="dashboard">
|
||||
<div className="content-wrapper">
|
||||
<Header />
|
||||
<main className={styles.content}>
|
||||
<Outlet />
|
||||
</main>
|
||||
<footer>
|
||||
<Footer/>
|
||||
</footer>
|
||||
</div>
|
||||
</div> /*: <Navigate to="/login" replace />*/
|
||||
|
||||
);
|
||||
};
|
||||
|
||||
export default Layout;
|
||||
@@ -0,0 +1,13 @@
|
||||
.container{
|
||||
width: 80%;
|
||||
margin: 0;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.main{
|
||||
margin: 0;
|
||||
align-items: center;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
import React from 'react';
|
||||
import { Button, Row, Col } from 'antd';
|
||||
import { RocketOutlined, ArrowRightOutlined } from '@ant-design/icons';
|
||||
import styles from './Main.module.css'
|
||||
import BannerSlider from '../../components/Banner/Banner';
|
||||
import CategoriesGrid from '../../components/Categories/Categories';
|
||||
import ProductionBanner from '../../components/ContactProduct/ContactProduct';
|
||||
import QuestionsBlock from '../../components/QuestionsBlock/QuestionsBlock';
|
||||
|
||||
const Main: React.FC = () =>{
|
||||
return (
|
||||
<>
|
||||
<BannerSlider/>
|
||||
<main className={styles.main}>
|
||||
<div className={styles.container}>
|
||||
<CategoriesGrid/>
|
||||
{<ProductionBanner/>}
|
||||
<QuestionsBlock/>
|
||||
</div>
|
||||
</main>
|
||||
</>
|
||||
|
||||
);
|
||||
}
|
||||
|
||||
export default Main;
|
||||
@@ -0,0 +1,36 @@
|
||||
import React from "react";
|
||||
import styles from "./Products.module.css";
|
||||
import SidebarCategories from "../../features/catalog/SidebarCategories";
|
||||
import CategoryCards from "../../features/catalog/CategoryCards";
|
||||
import Filters from "../../features/catalog/CategoryFilters";
|
||||
import ProductGrid from "../../features/catalog/ProductGrid";
|
||||
import Pagination from "../../features/catalog/Pagination";
|
||||
import { useAppSelector } from "../../app/hooks";
|
||||
|
||||
const ProductsPage: React.FC = () => {
|
||||
const { selectedCategoryId } = useAppSelector(s => s.categories);
|
||||
|
||||
return (
|
||||
<div className={styles.wrapper}>
|
||||
<SidebarCategories />
|
||||
<div className={styles.content}>
|
||||
{!selectedCategoryId ? (
|
||||
<CategoryCards onSelect={(id) => {}} />
|
||||
) : (
|
||||
<>
|
||||
<div className={styles.leftControls}>
|
||||
<Filters />
|
||||
</div>
|
||||
|
||||
<div className={styles.productsArea}>
|
||||
<ProductGrid />
|
||||
<Pagination categoryId={selectedCategoryId} />
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default ProductsPage;
|
||||
@@ -0,0 +1,18 @@
|
||||
export interface CategoryAtrVals{
|
||||
id: number;
|
||||
val: string;
|
||||
}
|
||||
|
||||
export interface CategoryAtributes {
|
||||
id: number;
|
||||
name: string;
|
||||
vals: CategoryAtrVals[];
|
||||
}
|
||||
|
||||
export interface Category {
|
||||
id: number;
|
||||
name: string;
|
||||
image?: string;
|
||||
atributes: CategoryAtributes[];
|
||||
}
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
export interface Product {
|
||||
id: number;
|
||||
name: string;
|
||||
image: string;
|
||||
description: string;
|
||||
}
|
||||