Skip to content

General-Kaolin/user-dashboard

Repository files navigation

🎯 User Dashboard with Authentication / Дашборд пользователей с авторизацией

English | Русский


🇬🇧 English

Test assignment - React application with user authentication and user list display.

🖼️ Screenshots

Login Page

Login Page

Dashboard

Dashboard

✨ Features

  • ✅ Authentication via API (DummyJSON)
  • ✅ Protected routes (access only after login)
  • ✅ Display current user data
  • ✅ Sortable table with all users
  • ✅ Responsive design (mobile, tablet, desktop)
  • ✅ Logout functionality

🛠️ Technologies

  • React - UI library
  • Redux Toolkit - state management
  • React Router - page navigation
  • Ant Design - UI components
  • Axios - HTTP requests
  • SASS - styling
  • Vite - build tool

🚀 Installation and Setup

Requirements

  • Node.js (v16 or higher)
  • npm or yarn

Installation Steps

  1. Clone the repository:
git clone https://github.com/General-Kaolin/user-dashboard.git
cd user-dashboard
  1. Install dependencies:
npm install
  1. Run the project:
npm run dev
  1. Open browser: http://localhost:5173

🔐 Test Credentials

  • Username: emilys
  • Password: emilyspass

Or use any credentials from DummyJSON Users

📁 Project Structure

src/
├── hooks/             # Custom hooks
│   ├── useAuth.js     # Authentication hook
│   └── useFetchUsers.js # Users fetching hook
├── pages/             # Application pages
│   ├── Login.jsx      # Login page
│   ├── Login.scss     # Login page styles
│   ├── Dashboard.jsx  # Main dashboard
│   └── Dashboard.scss # Dashboard styles
├── store.js           # Redux store and slices
├── App.jsx            # Main component with routing
└── main.jsx           # Entry point

🎨 Implementation Details

Custom Hooks

useAuth - authentication management:

  • POST request to /auth/login
  • Save user data to Redux
  • Error handling
  • Redirect to Dashboard after successful login

useFetchUsers - fetch users list:

  • GET request to /users
  • Data caching (doesn't reload)
  • Loading and error state handling

Redux State

{
  userState: {
    currentUser: { id, username, firstName, lastName, age, email, ... },
    allUsers: [...]
  }
}

Protected Routes

ProtectedRoute component checks for currentUser in Redux. If user is not authenticated - redirects to login page.

📱 Responsiveness

The application displays correctly on:

  • 📱 Mobile devices (< 576px)
  • 📱 Tablets (576px - 768px)
  • 💻 Desktop (> 768px)

🔗 API

Project uses DummyJSON API:

  • POST https://dummyjson.com/auth/login - authentication
  • GET https://dummyjson.com/users - users list

👨‍💻 Author

Samuil Tartychnyi

📄 License

MIT License


🇷🇺 Русский

Тестовое задание - React-приложение с авторизацией пользователя и отображением списка пользователей.

🖼️ Скриншоты

Login Page

Login Page

Dashboard

Dashboard

✨ Функционал

  • ✅ Авторизация через API (DummyJSON)
  • ✅ Защищённые маршруты (доступ только после логина)
  • ✅ Отображение данных текущего пользователя
  • ✅ Таблица всех пользователей с сортировкой
  • ✅ Адаптивный дизайн (мобилки, планшеты, десктоп)
  • ✅ Кнопка выхода из системы

🛠️ Технологии

  • React - библиотека для создания UI
  • Redux Toolkit - управление состоянием
  • React Router - навигация между страницами
  • Ant Design - UI компоненты
  • Axios - HTTP запросы
  • SASS - стилизация
  • Vite - сборщик проекта

🚀 Установка и запуск

Требования

  • Node.js (v16 или выше)
  • npm или yarn

Шаги установки

  1. Клонируй репозиторий:
git clone https://github.com/General-Kaolin/user-dashboard.git
cd user-dashboard
  1. Установи зависимости:
npm install
  1. Запусти проект:
npm run dev
  1. Открой браузер: http://localhost:5173

🔐 Тестовые данные для входа

  • Username: emilys
  • Password: emilyspass

Или используй любые данные из DummyJSON Users

📁 Структура проекта

src/
├── hooks/             # Кастомные хуки
│   ├── useAuth.js     # Хук для авторизации
│   └── useFetchUsers.js # Хук для получения пользователей
├── pages/             # Страницы приложения
│   ├── Login.jsx      # Страница входа
│   ├── Login.scss     # Стили страницы входа
│   ├── Dashboard.jsx  # Главная страница
│   └── Dashboard.scss # Стили Dashboard
├── store.js           # Redux store и слайсы
├── App.jsx            # Главный компонент с роутингом
└── main.jsx           # Точка входа

🎨 Особенности реализации

Кастомные хуки

useAuth - управление аутентификацией:

  • Выполнение POST запроса на /auth/login
  • Сохранение данных пользователя в Redux
  • Обработка ошибок
  • Редирект на Dashboard после успешного входа

useFetchUsers - получение списка пользователей:

  • GET запрос на /users
  • Кэширование данных (не загружает повторно)
  • Обработка состояния загрузки и ошибок

Redux состояние

{
  userState: {
    currentUser: { id, username, firstName, lastName, age, email, ... },
    allUsers: [...]
  }
}

Защищённые маршруты

Компонент ProtectedRoute проверяет наличие currentUser в Redux. Если пользователь не авторизован - редирект на страницу входа.

📱 Адаптивность

Приложение корректно отображается на:

  • 📱 Мобильных устройствах (< 576px)
  • 📱 Планшетах (576px - 768px)
  • 💻 Десктопах (> 768px)

🔗 API

Проект использует DummyJSON API:

  • POST https://dummyjson.com/auth/login - авторизация
  • GET https://dummyjson.com/users - список пользователей

👨‍💻 Автор

Samuil Tartychnyi

📄 Лицензия

MIT License

About

React User Dashboard with authentication.test

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors