This project is an admin dashboard boilerplate for Restaurant reservation platform built using React. It follows a modular architecture to maintain code organization and scalability.
- Dashboard: restaurant-reservation-self.vercel.app
- Installation
- Project Dependencies
- Contributing Guidelines
- Authentication
- Usage
- Localization & Internationalization
- Environment
- License
Ensure you have Node.js and npm installed on your machine.
-
Clone the repository:
git clone https://github.com/yacinebkt/restaurant-reservation.git cd restaurant-reservation
-
Install dependencies:
npm install
-
Set up environment variables:
cp .env.example .env
-
Configure the .env file with the appropriate values.:
VITE_API_URL=API_ENDPOINT
-
To start the development server:
npm run dev
-
To build the project for production:
npm run build
-
To serve the built project:
npm run serve
This project uses the following major dependencies:
- React for building the user interface.
- React Router for managing routing.
- React Query for data fetching and caching.
- Redux for state management.
- Material-UI and Tailwind CSS for styling and UI components.
- Vite as the build tool.
Contributions are welcome! Please follow these steps:
- Fork the repository.
- Create a new branch with a descriptive name.
- Make your changes.
- Commit your changes.
- Push to the branch.
- Open a pull request for review.
Here's an example of how the authentication context is managed in this project:
The AuthGuard component is used to protect routes that require authentication.
import React from 'react';
import { useNavigate } from 'react-router-dom';
import { useSelector } from 'react-redux';
import { RootState } from '@/store/types/authTypes';
interface AuthGuardProps {
children: React.ReactNode;
redirectTo: string;
requireAuth: boolean;
}
const AuthGuard: React.FC<AuthGuardProps> = ({ children, redirectTo, requireAuth }) => {
const navigate = useNavigate();
const isAuthenticated = useSelector((state: RootState) => state.auth.isAuthenticated);
if (requireAuth && !isAuthenticated) {
navigate(redirectTo);
return null;
}
if (!requireAuth && isAuthenticated) {
navigate(redirectTo);
return null;
}
return <>{children}</>;
};
export default AuthGuard;
import AuthGuard from '@/guards/AuthGuard';
// ...
<Routes>
<Route path="/signin" element={<SignIn />} />
<Route path="/signup" element={<SignUp />} />
<Route path="/forgot-password" element={<ForgotPassword />} />
<Route path="/dashboard" element={
<AuthGuard requireAuth redirectTo="/signin">
<Dashboard />
</AuthGuard>
} />
</Routes>
The dashboard is designed to support multiple languages to cater to a global audience. We use i18n for internationalization, allowing easy addition of new languages.
- Create a new locale file in the
src/modules/i18/translations
directory. - Add translations for the new language.
- Update the language selector component to include the new language.
- Test the application to ensure translations are correctly applied.
{
"welcome": "Bienvenido a Dashboard",
"dashboard": "Tablero de mandos",
"settings": "Configuraciones"
}
This project requires the following environment variables to be set:
# production, development, or test
VITE_API_URL=API_ENDPOINT
To start the application, use the following command:
npm start
##License
____________