feat: SPA pour les pages existantes
This commit is contained in:
parent
668702b1fb
commit
140cc14316
@@ -1,10 +1,23 @@
|
||||
import React from 'react';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
||||
|
||||
export function ToolbarButton({ icon, label, onClick, active = false }) {
|
||||
export function ToolbarButton({ icon, label, onClick, navigateTo, navigateBack = false, active = false }) {
|
||||
const navigate = useNavigate();
|
||||
|
||||
const handleClick = () => {
|
||||
if (navigateBack) {
|
||||
navigate(-1, { replace: true });
|
||||
} else if (navigateTo) {
|
||||
navigate(navigateTo, { replace: true });
|
||||
} else if (onClick) {
|
||||
onClick();
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<button
|
||||
onClick={onClick}
|
||||
onClick={handleClick}
|
||||
className={`
|
||||
flex items-center gap-2 px-4 py-2 rounded-lg transition-colors
|
||||
${active
|
||||
|
||||
Reference in New Issue
Block a user