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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
159 changes: 122 additions & 37 deletions components/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,25 @@ import React, { useEffect } from 'react';
import Link from 'next/link';
import JustValidate from 'just-validate';
import { useRouter } from 'next/router';
import {Button} from "react-bootstrap";


function myFunction() {
var x = document.getElementById("myLinks");
if (x!=null){
if (x.style.display !== "block") {
x.style.display = "block";
} else {
x.style.display = "none";
}
}
}


const Header: React.FC = () => {
const router = useRouter();
useEffect(() => {

const search = document.querySelector('.header__search--disabled') as HTMLElement | null;
const nav = document.querySelector('.header__nav') as HTMLElement | null;
const searchContent = document.querySelector('.header__search-active') as HTMLElement | null;
Expand Down Expand Up @@ -39,8 +54,8 @@ const Header: React.FC = () => {
content.classList.remove('header__controls-active');
}
});
}
}

else {
console.error('One or more elements were not found.');
}
Expand Down Expand Up @@ -70,44 +85,46 @@ const Header: React.FC = () => {
validator
.addField('#name', [
{
rule: 'required',
errorMessage: 'You did not enter a login',
rule: 'required',
errorMessage: 'You did not enter a login',
},
{
rule: 'minLength',
value: 3,
errorMessage: '3 symbols minimum',
rule: 'minLength',
value: 3,
errorMessage: '3 symbols minimum',
},
{
rule: 'maxLength',
value: 30,
errorMessage: '30 symbols maximum',
rule: 'maxLength',
value: 30,
errorMessage: '30 symbols maximum',
},
])
.addField('#password', [
{
rule: 'required',
errorMessage: 'You did not enter a password',
rule: 'required',
errorMessage: 'You did not enter a password',
},
{
rule: 'minLength',
value: 3,
errorMessage: '3 symbols minimum',
rule: 'minLength',
value: 3,
errorMessage: '3 symbols minimum',
},
])
.onSuccess((event : Event) => {
event.preventDefault();
const formData = new FormData(event.target as HTMLFormElement);
const name = formData.get('name') as string;
const password = formData.get('password') as string;

if (name === 'admin' && password === 'admin') {
router.push('/apanel');
router.push('/apanel');
} else {
alert('Invalid login or password');
alert('Invalid login or password');
}
});
}, [router]);
});


}, [router]);

return (
<header className="header">
Expand Down Expand Up @@ -138,7 +155,7 @@ const Header: React.FC = () => {
<li className="header__item">
<Link href="/combo" legacyBehavior>
<a href="" className="header__link">
Combo
Combo
</a>
</Link>
</li>
Expand All @@ -154,27 +171,38 @@ const Header: React.FC = () => {
<div className="header__controls flex">
<button className="header__search header__search--disabled btn-reset">
<svg width="33" height="34" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M11 19C15.4183 19 19 15.4183 19 11C19 6.58172 15.4183 3 11 3C6.58172 3 3 6.58172 3 11C3 15.4183 6.58172 19 11 19Z" stroke="#fff" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"/>
<path d="M20.9999 21L16.6499 16.65" stroke="#fff" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"/>
<path
d="M11 19C15.4183 19 19 15.4183 19 11C19 6.58172 15.4183 3 11 3C6.58172 3 3 6.58172 3 11C3 15.4183 6.58172 19 11 19Z"
stroke="#fff" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"/>
<path d="M20.9999 21L16.6499 16.65" stroke="#fff" strokeWidth="2" strokeLinecap="round"
strokeLinejoin="round"/>
</svg>
</button>
<div className="header__search-active none">
<form action="https://jsonplaceholder.typicode.com/posts" method="POST" className="header__search-form flex">
<form action="https://jsonplaceholder.typicode.com/posts" method="POST"
className="header__search-form flex">
<input type="text" className="header__search-content" placeholder="Search"></input>
<button className="header__search-button header__search-button-active btn-reset">
<svg width="33" height="34" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M11 19C15.4183 19 19 15.4183 19 11C19 6.58172 15.4183 3 11 3C6.58172 3 3 6.58172 3 11C3 15.4183 6.58172 19 11 19Z" stroke="#fff" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"/>
<path d="M20.9999 21L16.6499 16.65" stroke="#fff" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"/>
<svg width="40" height="34" viewBox="0 0 24 24" fill="none"
xmlns="http://www.w3.org/2000/svg">
<path
d="M11 19C15.4183 19 19 15.4183 19 11C19 6.58172 15.4183 3 11 3C6.58172 3 3 6.58172 3 11C3 15.4183 6.58172 19 11 19Z"
stroke="#fff" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"/>
<path d="M20.9999 21L16.6499 16.65" stroke="#fff" strokeWidth="2"
strokeLinecap="round" strokeLinejoin="round"/>
</svg>
</button>
<button className="header__search-close none">111</button>
</form>
</div>
<button className="header__log btn-reset flex">
<svg width="28" height="28" viewBox="0 0 19 18" fill="#fff" xmlns="http://www.w3.org/2000/svg">
<path d="M9.5 1.5L2 5.25L9.5 9L17 5.25L9.5 1.5Z" stroke="#121723" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round"/>
<path d="M2 12.75L9.5 16.5L17 12.75" stroke="#121723" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round"/>
<path d="M2 9L9.5 12.75L17 9" stroke="#121723" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round"/>
<path d="M9.5 1.5L2 5.25L9.5 9L17 5.25L9.5 1.5Z" stroke="#121723" strokeWidth="1.5"
strokeLinecap="round" strokeLinejoin="round"/>
<path d="M2 12.75L9.5 16.5L17 12.75" stroke="#121723" strokeWidth="1.5"
strokeLinecap="round" strokeLinejoin="round"/>
<path d="M2 9L9.5 12.75L17 9" stroke="#121723" strokeWidth="1.5" strokeLinecap="round"
strokeLinejoin="round"/>
</svg>
<span>
Log-in
Expand All @@ -183,9 +211,11 @@ const Header: React.FC = () => {
<div className="header__log-content none flex">
<div>
<button className="header__log-close btn-reset">
<svg width="42" height="42" viewBox="0 0 42 42" fill="none" xmlns="http://www.w3.org/2000/svg">
<svg width="42" height="42" viewBox="0 0 42 42" fill="none"
xmlns="http://www.w3.org/2000/svg">
<circle cx="21" cy="21" r="19.5" stroke="#A1A6B4" strokeWidth="3"></circle>
<path d="M29.6777 12L12 29.6777M29.6777 29.6777L12 12" stroke="#A1A6B4" strokeWidth="3"></path>
<path d="M29.6777 12L12 29.6777M29.6777 29.6777L12 12" stroke="#A1A6B4"
strokeWidth="3"></path>
</svg>
</button>
<h2 className="header__log-title">
Expand All @@ -194,12 +224,15 @@ const Header: React.FC = () => {
<p className="header__log-info">
If you don't have an account yet, <a href="#">register here</a>.
</p>
<form action="https://jsonplaceholder.typicode.com/posts" method="POST" className="header__log-form flex" id="log-form">
<form action="https://jsonplaceholder.typicode.com/posts" method="POST"
className="header__log-form flex" id="log-form">
<label htmlFor="name" className="header__log-label">
<input type="text" className="header__log-input" placeholder="Login" name="name" id="name"></input>
<input type="text" className="header__log-input" placeholder="Login" name="name"
id="name"></input>
</label>
<label htmlFor="password" className="header__log-label">
<input type="password" className="header__log-input" placeholder="Password" name="password" id="password"></input>
<input type="password" className="header__log-input" placeholder="Password"
name="password" id="password"></input>
</label>
<button className="header__log-button btn-reset">
Enter
Expand All @@ -208,13 +241,65 @@ const Header: React.FC = () => {
</div>
</div>
<button className="header__basket btn-reset">
<svg fill="#fff" width="32px" height="30px" viewBox="0 0 32 32" version="1.1" xmlns="http://www.w3.org/2000/svg">
<path d="M31.739 8.875c-0.186-0.264-0.489-0.422-0.812-0.422h-21.223l-1.607-5.54c-0.63-2.182-2.127-2.417-2.741-2.417h-4.284c-0.549 0-0.993 0.445-0.993 0.993s0.445 0.993 0.993 0.993h4.283c0.136 0 0.549 0 0.831 0.974l5.527 20.311c0.12 0.428 0.511 0.724 0.956 0.724h13.499c0.419 0 0.793-0.262 0.934-0.657l4.758-14.053c0.11-0.304 0.064-0.643-0.122-0.907zM25.47 22.506h-12.046l-3.161-12.066h19.253zM23.5 26.504c-1.381 0-2.5 1.119-2.5 2.5s1.119 2.5 2.5 2.5 2.5-1.119 2.5-2.5c0-1.381-1.119-2.5-2.5-2.5zM14.5 26.504c-1.381 0-2.5 1.119-2.5 2.5s1.119 2.5 2.5 2.5 2.5-1.119 2.5-2.5c0-1.381-1.119-2.5-2.5-2.5z"></path>
<svg fill="#fff" width="35px" height="30px" viewBox="0 0 32 32" version="1.1"
xmlns="http://www.w3.org/2000/svg">
<path
d="M31.739 8.875c-0.186-0.264-0.489-0.422-0.812-0.422h-21.223l-1.607-5.54c-0.63-2.182-2.127-2.417-2.741-2.417h-4.284c-0.549 0-0.993 0.445-0.993 0.993s0.445 0.993 0.993 0.993h4.283c0.136 0 0.549 0 0.831 0.974l5.527 20.311c0.12 0.428 0.511 0.724 0.956 0.724h13.499c0.419 0 0.793-0.262 0.934-0.657l4.758-14.053c0.11-0.304 0.064-0.643-0.122-0.907zM25.47 22.506h-12.046l-3.161-12.066h19.253zM23.5 26.504c-1.381 0-2.5 1.119-2.5 2.5s1.119 2.5 2.5 2.5 2.5-1.119 2.5-2.5c0-1.381-1.119-2.5-2.5-2.5zM14.5 26.504c-1.381 0-2.5 1.119-2.5 2.5s1.119 2.5 2.5 2.5 2.5-1.119 2.5-2.5c0-1.381-1.119-2.5-2.5-2.5z"></path>
</svg>
</button>
</div>
</div>
<div className="header__back"></div>


<link rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css"/>


<div className="topnav">


<div id="myLinks">

<li className="header__item">
<Link href="/about" legacyBehavior>
<a href="" className="header__link">
About-us
</a>
</Link>
</li>

<li className="header__item">
<Link href="/products" legacyBehavior>
<a href="" className="header__link">
Products
</a>
</Link>
</li>

<li className="header__item">
<Link href="/combo" legacyBehavior>
<a href="" className="header__link">
Combo
</a>
</Link>
</li>

<li className="header__item">
<Link href="/news" legacyBehavior>
<a href="" className="header__link">
Newsletter
</a>
</Link>
</li>
</div>

<a href="javascript:void(0);" className="icon" onClick={() => myFunction()}>
<i className="fa fa-bars"></i>
</a>
</div>


</header>
);
};
Expand Down
Loading