From 1ae441d62a9f61cd4c5dcd0ac460cc30dfdd1521 Mon Sep 17 00:00:00 2001
From: Vova <123321>
Date: Wed, 23 Apr 2025 14:34:56 +0300
Subject: [PATCH] creating a database importing it into registration and
logging in
---
src/App.js | 27 ++-
src/components/Header.js | 10 +-
src/components/LoginModal.js | 124 ++++++++++
src/components/LoginRegister.js | 385 +++++++++++++++++++++-----------
src/mockData.js | 14 ++
5 files changed, 425 insertions(+), 135 deletions(-)
create mode 100644 src/components/LoginModal.js
create mode 100644 src/mockData.js
diff --git a/src/App.js b/src/App.js
index 6b2ef07..13307db 100644
--- a/src/App.js
+++ b/src/App.js
@@ -1,4 +1,4 @@
-import React from 'react';
+import React, { useState } from 'react';
import { Route, Routes } from 'react-router-dom';
import Header from './components/Header';
import Footer from './components/Footer';
@@ -10,6 +10,9 @@ import SecureCheckout from './components/SecureCheckout';
import ShippingDetails from './components/ShippingDetails';
import DeliveryForm from './components/DeliveryForm';
import OrderTracking from './components/OrderTracking';
+import { users, addUser } from './mockData';
+import LoginRegister from './components/LoginRegister'; // Import LoginRegister
+
import './App.css';
function Home() {
@@ -21,15 +24,31 @@ function Home() {
-
+
>
);
}
function App() {
+ const [currentUser, setCurrentUser] = useState(null);
+
+ const handleLogin = (user) => {
+ setCurrentUser(user);
+ };
+
+ const handleLogout = () => {
+ setCurrentUser(null);
+ };
+
return (
{
border: 'none',
borderRadius: '10px',
boxShadow: '0px 0px 10px rgba(0,0,0,0.5)',
- backgroundColor: '#f8f8f8', // Светлый фон
+ backgroundColor: '#f8f8f8',
fontFamily: 'Arial, sans-serif',
},
}}
>
- Регистрация
-
-
- setName(e.target.value)}
- style={{
- width: '100%',
- padding: '8px',
- borderRadius: '5px',
- border: '1px solid #ddd',
- boxSizing: 'border-box',
- }}
- />
-
-
-
- setSurname(e.target.value)}
- style={{
- width: '100%',
- padding: '8px',
- borderRadius: '5px',
- border: '1px solid #ddd',
- boxSizing: 'border-box',
- }}
- />
-
-
-
- setPhone(e.target.value)}
- style={{
- width: '100%',
- padding: '8px',
- borderRadius: '5px',
- border: '1px solid #ddd',
- boxSizing: 'border-box',
- }}
- />
-
-
-
-
- setPassword(e.target.value)}
- style={{
- width: '100%',
- padding: '8px',
- borderRadius: '5px',
- border: '1px solid #ddd',
- boxSizing: 'border-box',
- }}
- />
-
-
-
-
-
- setConfirmPassword(e.target.value)}
- style={{
- width: '100%',
- padding: '8px',
- borderRadius: '5px',
- border: '1px solid #ddd',
- boxSizing: 'border-box',
- }}
- />
-
-
-
-
-
+ {isRegistering ? (
+ <>
+ Регистрация
+ {error && {error}
}
+
+
+ setName(e.target.value)}
+ style={{
+ width: '100%',
+ padding: '8px',
+ borderRadius: '5px',
+ border: '1px solid #ddd',
+ boxSizing: 'border-box',
+ }}
+ />
+
+
+
+ setSurname(e.target.value)}
+ style={{
+ width: '100%',
+ padding: '8px',
+ borderRadius: '5px',
+ border: '1px solid #ddd',
+ boxSizing: 'border-box',
+ }}
+ />
+
+
+
+ setPhone(e.target.value)}
+ style={{
+ width: '100%',
+ padding: '8px',
+ borderRadius: '5px',
+ border: '1px solid #ddd',
+ boxSizing: 'border-box',
+ }}
+ />
+
+
+
+
+ setPassword(e.target.value)}
+ style={{
+ width: '100%',
+ padding: '8px',
+ borderRadius: '5px',
+ border: '1px solid #ddd',
+ boxSizing: 'border-box',
+ }}
+ />
+
+
+
+
+
+ setConfirmPassword(e.target.value)}
+ style={{
+ width: '100%',
+ padding: '8px',
+ borderRadius: '5px',
+ border: '1px solid #ddd',
+ boxSizing: 'border-box',
+ }}
+ />
+
+
+
+
+
+ >
+ ) : (
+ <>
+ Вход
+ {loginError && {loginError}
}
+
+
+ setLoginPhone(e.target.value)}
+ style={{
+ width: '100%',
+ padding: '8px',
+ borderRadius: '5px',
+ border: '1px solid #ddd',
+ boxSizing: 'border-box',
+ }}
+ />
+
+
+
+
+ setLoginPassword(e.target.value)}
+ style={{
+ width: '100%',
+ padding: '8px',
+ borderRadius: '5px',
+ border: '1px solid #ddd',
+ boxSizing: 'border-box',
+ }}
+ />
+
+
+
+
+
+
+
+
+ >
+ )}
);
};
-export default RegistrationModal;
+export default LoginRegister;
diff --git a/src/mockData.js b/src/mockData.js
new file mode 100644
index 0000000..0477cf3
--- /dev/null
+++ b/src/mockData.js
@@ -0,0 +1,14 @@
+// mockData.js
+export let users = [{
+ id: 1,
+ name: 'Иван',
+ surname: 'Иванов',
+ phone: '1234567890',
+ password: 'password123',
+}, ];
+
+// Функция для добавления пользователя (имитация записи в БД)
+export const addUser = (user) => {
+ user.id = users.length + 1;
+ users.push(user);
+};