feat(HeaderNavigation): update navigation to use user preferences for Jira configuration
- Replaced Jira configuration context with user preferences context to determine Jira setup. - Enhanced navigation links to reflect user-specific Jira project key. - Fixed CSS class syntax for hover effects and adjusted link display logic for larger screens.
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
|
||||
import Link from 'next/link';
|
||||
import { usePathname } from 'next/navigation';
|
||||
import { useJiraConfig } from '@/contexts/JiraConfigContext';
|
||||
import { useUserPreferences } from '@/contexts/UserPreferencesContext';
|
||||
|
||||
interface HeaderNavigationProps {
|
||||
variant: 'desktop' | 'mobile';
|
||||
@@ -15,10 +15,18 @@ export function HeaderNavigation({
|
||||
className = '',
|
||||
onLinkClick,
|
||||
}: HeaderNavigationProps) {
|
||||
const { isConfigured: isJiraConfigured, config: jiraConfig } =
|
||||
useJiraConfig();
|
||||
const { preferences } = useUserPreferences();
|
||||
const pathname = usePathname();
|
||||
|
||||
// Vérifier si Jira est configuré depuis les préférences utilisateur
|
||||
const isJiraConfigured = Boolean(
|
||||
preferences.jiraConfig?.enabled &&
|
||||
preferences.jiraConfig?.baseUrl &&
|
||||
preferences.jiraConfig?.email &&
|
||||
preferences.jiraConfig?.apiToken &&
|
||||
preferences.jiraConfig?.projectKey
|
||||
);
|
||||
|
||||
// Liste des liens de navigation
|
||||
const navLinks = [
|
||||
{ href: '/', label: 'Dashboard' },
|
||||
@@ -30,7 +38,7 @@ export function HeaderNavigation({
|
||||
? [
|
||||
{
|
||||
href: '/jira-dashboard',
|
||||
label: `Jira${jiraConfig?.projectKey ? ` (${jiraConfig.projectKey})` : ''}`,
|
||||
label: `Jira${preferences.jiraConfig?.projectKey ? ` (${preferences.jiraConfig.projectKey})` : ''}`,
|
||||
},
|
||||
]
|
||||
: []),
|
||||
@@ -66,7 +74,7 @@ export function HeaderNavigation({
|
||||
return `${baseClasses} text-[var(--primary)] bg-[var(--primary)]/10 border border-[var(--primary)]/30`;
|
||||
}
|
||||
|
||||
return `${baseClasses} text-[var(--muted-foreground)] hover:text-[var(--primary)] hover:bg-[var(--card-hover"]`;
|
||||
return `${baseClasses} text-[var(--muted-foreground)] hover:text-[var(--primary)] hover:bg-[var(--card-hover)]`;
|
||||
};
|
||||
|
||||
if (variant === 'mobile') {
|
||||
@@ -89,7 +97,7 @@ export function HeaderNavigation({
|
||||
// Desktop version
|
||||
return (
|
||||
<nav className={`flex items-center gap-1 xl:gap-2 flex-wrap ${className}`}>
|
||||
{navLinks.slice(0, 4).map(({ href, label }) => (
|
||||
{navLinks.slice(0, 5).map(({ href, label }) => (
|
||||
<Link
|
||||
key={href}
|
||||
href={href}
|
||||
@@ -100,8 +108,8 @@ export function HeaderNavigation({
|
||||
))}
|
||||
|
||||
{/* Plus d'éléments sur très grands écrans */}
|
||||
<div className="hidden 2xl:flex items-center gap-1">
|
||||
{navLinks.slice(4).map(({ href, label }) => (
|
||||
<div className="hidden xl:flex items-center gap-1">
|
||||
{navLinks.slice(5).map(({ href, label }) => (
|
||||
<Link key={href} href={href} className={getLinkClasses(href)}>
|
||||
{label}
|
||||
</Link>
|
||||
|
||||
Reference in New Issue
Block a user