mirror of
https://github.com/SamyRai/turash.git
synced 2025-12-26 23:01:33 +00:00
- Remove nested git repository from bugulma/frontend/.git - Add all frontend files to main repository tracking - Convert from separate frontend/backend repos to unified monorepo - Preserve all frontend code and development history as tracked files - Eliminate nested repository complexity for simpler development workflow This creates a proper monorepo structure with frontend and backend coexisting in the same repository for easier development and deployment.
62 lines
1.7 KiB
TypeScript
62 lines
1.7 KiB
TypeScript
import React from 'react';
|
|
import { useNavigate } from 'react-router-dom';
|
|
import { useAuth } from '@/contexts/AuthContext';
|
|
import { useTranslation } from '@/hooks/useI18n';
|
|
import { LogIn } from 'lucide-react';
|
|
import Button from '@/components/ui/Button';
|
|
import LanguageSwitcher from '@/components/ui/LanguageSwitcher';
|
|
import ThemeToggle from '@/components/ui/ThemeToggle';
|
|
|
|
interface HeaderActionsProps {
|
|
showThemeToggle?: boolean;
|
|
showLanguageSwitcher?: boolean;
|
|
showAuthButton?: boolean;
|
|
className?: string;
|
|
}
|
|
|
|
export const HeaderActions: React.FC<HeaderActionsProps> = ({
|
|
showThemeToggle = true,
|
|
showLanguageSwitcher = true,
|
|
showAuthButton = true,
|
|
className = ''
|
|
}) => {
|
|
const { t } = useTranslation();
|
|
const { isAuthenticated, user } = useAuth();
|
|
const navigate = useNavigate();
|
|
|
|
const handleAuthClick = () => {
|
|
if (!isAuthenticated) {
|
|
navigate('/login');
|
|
} else if (user?.role === 'admin') {
|
|
navigate('/admin');
|
|
} else {
|
|
navigate('/dashboard');
|
|
}
|
|
};
|
|
|
|
return (
|
|
<div className={`flex items-center gap-2 ${className}`}>
|
|
{showThemeToggle && <ThemeToggle />}
|
|
{showLanguageSwitcher && <LanguageSwitcher />}
|
|
{showAuthButton && (
|
|
<Button
|
|
onClick={handleAuthClick}
|
|
variant="primary-ghost"
|
|
aria-label={t('topBar.loginButton')}
|
|
>
|
|
<LogIn className="h-4 sm:mr-2 text-current w-4" />
|
|
<span className="hidden sm:inline">
|
|
{isAuthenticated
|
|
? user?.role === 'admin'
|
|
? t('topBar.adminButton')
|
|
: t('topBar.dashboardButton')
|
|
: t('topBar.loginButton')}
|
|
</span>
|
|
</Button>
|
|
)}
|
|
</div>
|
|
);
|
|
};
|
|
|
|
export default HeaderActions;
|