"Добавлен frontend с TSX, Tailwind и ЛК

This commit is contained in:
Georgiy Syralev
2025-09-14 22:50:58 +03:00
parent 56292a0b10
commit ca4d7abc18
11 changed files with 148 additions and 168 deletions

34
ospabhost/.gitignore vendored
View File

@@ -1,23 +1,17 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
# dependencies
/node_modules
/.pnp
.pnp.js
# testing
/coverage
# production
/build
# misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local
# Node
node_modules/
npm-debug.log*
yarn-debug.log*
yarn-error.log*
# Build
dist/
build/
# Editor
.vscode/
.idea/
# System
.DS_Store
Thumbs.db

View File

@@ -1,70 +1 @@
# Getting Started with Create React App
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
## Available Scripts
In the project directory, you can run:
### `npm start`
Runs the app in the development mode.\
Open [http://localhost:3000](http://localhost:3000) to view it in your browser.
The page will reload when you make changes.\
You may also see any lint errors in the console.
### `npm test`
Launches the test runner in the interactive watch mode.\
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
### `npm run build`
Builds the app for production to the `build` folder.\
It correctly bundles React in production mode and optimizes the build for the best performance.
The build is minified and the filenames include the hashes.\
Your app is ready to be deployed!
See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
### `npm run eject`
**Note: this is a one-way operation. Once you `eject`, you can't go back!**
If you aren't satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you're on your own.
You don't have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn't feel obligated to use this feature. However we understand that this tool wouldn't be useful if you couldn't customize it when you are ready for it.
## Learn More
You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
To learn React, check out the [React documentation](https://reactjs.org/).
### Code Splitting
This section has moved here: [https://facebook.github.io/create-react-app/docs/code-splitting](https://facebook.github.io/create-react-app/docs/code-splitting)
### Analyzing the Bundle Size
This section has moved here: [https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size](https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size)
### Making a Progressive Web App
This section has moved here: [https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app](https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app)
### Advanced Configuration
This section has moved here: [https://facebook.github.io/create-react-app/docs/advanced-configuration](https://facebook.github.io/create-react-app/docs/advanced-configuration)
### Deployment
This section has moved here: [https://facebook.github.io/create-react-app/docs/deployment](https://facebook.github.io/create-react-app/docs/deployment)
### `npm run build` fails to minify
This section has moved here: [https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify](https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify)
Ospab.host site version 8

View File

@@ -1,9 +1,9 @@
import React from 'react';
export default function Footer() {
const Footer: React.FC = () => {
return (
<footer className="bg-gray-900 text-gray-400 py-6 text-center mt-10">
<p>© {new Date().getFullYear()} ospab.host All rights reserved</p>
<footer className="bg-gray-900 text-white p-4 text-center">
© {new Date().getFullYear()} osapab.host. Все права защищены.
</footer>
);
}
};
export default Footer;

View File

@@ -1,18 +1,30 @@
import React from 'react';
import { Link } from 'react-router-dom';
import { Link } from "react-router-dom";
export default function Navbar() {
interface NavbarProps {
user: { email: string } | null;
logout: () => void;
}
const Navbar: React.FC<NavbarProps> = ({ user, logout }) => {
return (
<nav className="bg-gray-900 text-white px-6 py-4 flex items-center justify-between shadow-md">
<Link to="/" className="text-xl font-bold text-blue-400">
ospab.host
</Link>
<div className="space-x-6">
<Link to="/" className="hover:text-blue-400">Home</Link>
<Link to="/pricing" className="hover:text-blue-400">Pricing</Link>
<Link to="/login" className="hover:text-blue-400">Login</Link>
<Link to="/dashboard" className="hover:text-blue-400">Dashboard</Link>
<nav className="bg-gray-800 text-white p-4 flex justify-between items-center">
<div className="text-xl font-bold">ospab.host</div>
<div className="space-x-4">
<Link to="/">Главная</Link>
<Link to="/pricing">Цены</Link>
{user ? (
<>
<Link to="/dashboard">ЛК</Link>
<button onClick={logout} className="bg-red-600 px-2 py-1 rounded">
Выйти
</button>
</>
) : (
<Link to="/login">Вход</Link>
)}
</div>
</nav>
);
}
};
export default Navbar;

View File

@@ -0,0 +1,15 @@
import { Navigate } from "react-router-dom";
interface ProtectedRouteProps {
user: { email: string } | null;
children: React.ReactNode;
}
const ProtectedRoute: React.FC<ProtectedRouteProps> = ({ user, children }) => {
if (!user) {
return <Navigate to="/login" />;
}
return <>{children}</>;
};
export default ProtectedRoute;

View File

@@ -8,12 +8,19 @@ import Dashboard from './pages/dashboard/index';
import './styles/tailwind.css';
const root = ReactDOM.createRoot(document.getElementById('root')!);
// Заглушка для функции login
const login = (email: string) => {
// Здесь может быть логика авторизации
console.log('Вход для:', email);
};
root.render(
<BrowserRouter>
<Routes>
<Route path="/" element={<Index />} />
<Route path="/pricing" element={<Pricing />} />
<Route path="/login" element={<Login />} />
<Route path="/login" element={<Login login={login} />} />
<Route path="/dashboard/*" element={<Dashboard />} />
</Routes>
</BrowserRouter>

View File

@@ -1,28 +1,25 @@
import React from 'react';
import Navbar from '../../components/Navbar';
import Footer from '../../components/Footer';
import Button from '../../components/Button';
import { Link, Routes, Route } from "react-router-dom";
import Servers from "./servers";
import Billing from "./billing";
import Support from "./support";
export default function Index() {
const Dashboard: React.FC = () => {
return (
<div className="min-h-screen flex flex-col bg-gray-50">
<Navbar />
<main className="flex-grow flex flex-col items-center justify-center text-center px-6">
<h1 className="text-5xl font-extrabold text-gray-900 mb-6">
Next-Gen VPS Hosting
</h1>
<p className="text-lg text-gray-600 max-w-2xl mb-8">
Deploy and manage virtual servers with ease. Powered by DigitalOcean and AWS.
</p>
<div className="space-x-4">
<Button>Get Started</Button>
{/* Для поддержки variant="secondary" нужно доработать компонент Button */}
<Button>View Pricing</Button>
</div>
</main>
<Footer />
<div>
<h1 className="text-3xl font-bold mb-4">Личный кабинет</h1>
<div className="flex space-x-4 mb-4">
<Link className="underline" to="servers">Сервера</Link>
<Link className="underline" to="billing">Биллинг</Link>
<Link className="underline" to="support">Поддержка</Link>
</div>
<Routes>
<Route path="servers" element={<Servers />} />
<Route path="billing" element={<Billing />} />
<Route path="support" element={<Support />} />
<Route path="/" element={<div>Выберите раздел</div>} />
</Routes>
</div>
);
}
};
export default Dashboard;

View File

@@ -1,5 +1,5 @@
import React from 'react';
const Servers: React.FC = () => {
return <div>Здесь будут ваши VPS</div>;
};
export default function Servers() {
return <div>Your VPS servers list</div>;
}
export default Servers;

View File

@@ -4,11 +4,11 @@ import Footer from '../components/Footer';
export default function Index() {
return (
<div>
<Navbar />
<main className="p-10">
<h1 className="text-4xl font-bold">Welcome to ospab.host</h1>
<p className="mt-4 text-lg">Your VPS hosting control panel</p>
<div className="min-h-screen flex flex-col bg-white">
<Navbar user={null} logout={() => {}} />
<main className="flex-grow p-10">
<h1 className="text-4xl font-bold">Добро пожаловать в ospab.host</h1>
<p className="mt-4 text-lg">Ваша панель управления VPS-хостингом</p>
</main>
<Footer />
</div>

View File

@@ -1,23 +1,47 @@
import React from 'react';
import Navbar from '../components/Navbar';
import Footer from '../components/Footer';
import Button from '../components/Button';
import { useState } from "react";
import { useNavigate } from "react-router-dom";
interface LoginProps {
login: (email: string) => void;
}
const Login: React.FC<LoginProps> = ({ login }) => {
const [email, setEmail] = useState("");
const [password, setPassword] = useState("");
const navigate = useNavigate();
const handleSubmit = (e: React.FormEvent) => {
e.preventDefault();
login(email);
navigate("/dashboard");
};
export default function Login() {
return (
<div className="min-h-screen flex flex-col bg-gray-50">
<Navbar />
<main className="flex-grow flex items-center justify-center px-6">
<div className="bg-white shadow-lg rounded-xl p-8 w-full max-w-md">
<h1 className="text-2xl font-bold mb-6 text-center">Login</h1>
<input className="border p-3 w-full mb-4 rounded-lg" placeholder="Email" />
<input className="border p-3 w-full mb-6 rounded-lg" placeholder="Password" type="password"/>
<Button>Login</Button>
</div>
</main>
<Footer />
<div className="max-w-md mx-auto mt-20 p-6 bg-gray-800 text-white rounded">
<h1 className="text-2xl font-bold mb-4">Вход</h1>
<form onSubmit={handleSubmit} className="space-y-4">
<input
type="email"
placeholder="Email"
value={email}
onChange={(e) => setEmail(e.target.value)}
className="w-full p-2 rounded text-black"
required
/>
<input
type="password"
placeholder="Пароль"
value={password}
onChange={(e) => setPassword(e.target.value)}
className="w-full p-2 rounded text-black"
required
/>
<button className="w-full bg-blue-600 py-2 rounded font-bold hover:bg-blue-700">
Войти
</button>
</form>
</div>
);
}
};
export default Login;

View File

@@ -5,17 +5,17 @@ import Button from '../components/Button';
export default function Pricing() {
const plans = [
{ name: "Basic", price: "$5/mo", features: ["1 vCPU", "1GB RAM", "25GB SSD"] },
{ name: "Standard", price: "$10/mo", features: ["2 vCPU", "2GB RAM", "50GB SSD"] },
{ name: "Pro", price: "$20/mo", features: ["4 vCPU", "8GB RAM", "100GB SSD"] },
{ name: "Мини", price: "200 р/мес", features: ["1 vCPU", "1GB RAM", "25GB SSD"] },
{ name: "Стандарт", price: "500 р/мес", features: ["2 vCPU", "2GB RAM", "50GB SSD"] },
{ name: "Профессионал", price: "700 р/мес", features: ["4 vCPU", "8GB RAM", "100GB SSD"] },
];
return (
<div className="min-h-screen flex flex-col bg-gray-50">
<Navbar />
<Navbar user={null} logout={() => {}} />
<main className="flex-grow px-6 py-12 text-center">
<h1 className="text-4xl font-bold mb-6">Choose Your Plan</h1>
<h1 className="text-4xl font-bold mb-6">Выбери свой тариф</h1>
<div className="grid md:grid-cols-3 gap-6 max-w-5xl mx-auto">
{plans.map(plan => (
<div key={plan.name} className="bg-white shadow-md rounded-xl p-6 hover:shadow-xl transition">
@@ -24,7 +24,7 @@ export default function Pricing() {
<ul className="text-gray-600 mb-6 space-y-2">
{plan.features.map(f => <li key={f}> {f}</li>)}
</ul>
<Button>Get {plan.name}</Button>
<Button>Заказать</Button>
</div>
))}
</div>