mirror of
https://git.v0id.ovh/n3wt-innov/n3wt-school.git
synced 2026-01-29 16:03:21 +00:00
fix: correction des redirections vers la login page
This commit is contained in:
@ -30,7 +30,6 @@ import {
|
||||
} from '@/utils/Url';
|
||||
|
||||
import { disconnect } from '@/app/actions/authAction';
|
||||
import { useSession } from 'next-auth/react';
|
||||
import ProtectedRoute from '@/components/ProtectedRoute';
|
||||
import { getGravatarUrl } from '@/utils/gravatar';
|
||||
import Footer from '@/components/Footer';
|
||||
@ -41,9 +40,8 @@ import { useEstablishment } from '@/context/EstablishmentContext';
|
||||
export default function Layout({ children }) {
|
||||
const t = useTranslations('sidebar');
|
||||
const [isSidebarOpen, setIsSidebarOpen] = useState(false);
|
||||
const { data: session } = useSession();
|
||||
const {
|
||||
selectedEstablishmentId,
|
||||
setSelectedRoleId,
|
||||
setSelectedEstablishmentId,
|
||||
profileRole,
|
||||
setProfileRole,
|
||||
@ -163,17 +161,17 @@ export default function Layout({ children }) {
|
||||
currentPage={currentPage}
|
||||
items={Object.values(sidebarItems)}
|
||||
onCloseMobile={toggleSidebar}
|
||||
onEstablishmentChange={(establishmentId) => {
|
||||
const parsedEstablishmentId = parseInt(establishmentId, 10);
|
||||
setSelectedEstablishmentId(parsedEstablishmentId);
|
||||
let roleIndex = session.user.roles.findIndex(
|
||||
(role) => role.establishment__id === parsedEstablishmentId
|
||||
);
|
||||
if (roleIndex === -1) {
|
||||
roleIndex = 0;
|
||||
onRoleChange={(roleId) => {
|
||||
let parsedRoleId = parseInt(roleId, 10);
|
||||
if (parsedRoleId === -1) {
|
||||
parsedRoleId = 0;
|
||||
}
|
||||
const role = session.user.roles[roleIndex].role_type;
|
||||
const role = user.roles[parsedRoleId].role_type;
|
||||
const establishmentId =
|
||||
user.roles[parsedRoleId].establishment__id;
|
||||
setProfileRole(role);
|
||||
setSelectedRoleId(parsedRoleId);
|
||||
setSelectedEstablishmentId(establishmentId);
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
|
||||
@ -8,6 +8,7 @@ import { Search } from 'lucide-react';
|
||||
import Popup from '@/components/Popup';
|
||||
import Loader from '@/components/Loader';
|
||||
import AlertWithModal from '@/components/AlertWithModal';
|
||||
import { useRouter } from 'next/navigation';
|
||||
import DropdownMenu from '@/components/DropdownMenu';
|
||||
import {
|
||||
MoreVertical,
|
||||
@ -112,6 +113,7 @@ export default function Page({ params: { locale } }) {
|
||||
const [isOpenAddGuardian, setIsOpenAddGuardian] = useState(false);
|
||||
|
||||
const csrfToken = useCsrfToken();
|
||||
const router = useRouter();
|
||||
const { selectedEstablishmentId } = useEstablishment();
|
||||
|
||||
const openModal = () => {
|
||||
@ -670,7 +672,9 @@ export default function Page({ params: { locale } }) {
|
||||
{
|
||||
icon: <Edit className="w-5 h-5 text-blue-500 hover:text-blue-700" />,
|
||||
onClick: () =>
|
||||
(window.location.href = `${FE_ADMIN_SUBSCRIPTIONS_EDIT_URL}?studentId=${row.student.id}&id=1`),
|
||||
router.push(
|
||||
`${FE_ADMIN_SUBSCRIPTIONS_EDIT_URL}?studentId=${row.student.id}`
|
||||
),
|
||||
},
|
||||
{
|
||||
icon: (
|
||||
@ -688,7 +692,9 @@ export default function Page({ params: { locale } }) {
|
||||
{
|
||||
icon: <Edit className="w-5 h-5 text-blue-500 hover:text-blue-700" />,
|
||||
onClick: () =>
|
||||
(window.location.href = `${FE_ADMIN_SUBSCRIPTIONS_EDIT_URL}?studentId=${row.student.id}&id=1`),
|
||||
router.push(
|
||||
`${FE_ADMIN_SUBSCRIPTIONS_EDIT_URL}?studentId=${row.student.id}`
|
||||
),
|
||||
},
|
||||
],
|
||||
3: [
|
||||
@ -697,7 +703,9 @@ export default function Page({ params: { locale } }) {
|
||||
<CircleCheck className="w-5 h-5 text-green-500 hover:text-green-700" />
|
||||
),
|
||||
onClick: () =>
|
||||
(window.location.href = `${FE_ADMIN_SUBSCRIPTIONS_VALIDATE_URL}?studentId=${row.student.id}&firstName=${row.student.first_name}&lastName=${row.student.last_name}&paymentMode=${row.registration_payment}&file=${row.registration_file}`),
|
||||
router.push(
|
||||
`${FE_ADMIN_SUBSCRIPTIONS_VALIDATE_URL}?studentId=${row.student.id}&firstName=${row.student.first_name}&lastName=${row.student.last_name}&paymentMode=${row.registration_payment}&file=${row.registration_file}`
|
||||
),
|
||||
},
|
||||
],
|
||||
5: [
|
||||
|
||||
@ -14,13 +14,7 @@ export default function ParentHomePage() {
|
||||
const [children, setChildren] = useState([]);
|
||||
const [userId, setUserId] = useState(null);
|
||||
const [currentPage, setCurrentPage] = useState(1);
|
||||
const {
|
||||
user,
|
||||
setProfileRole,
|
||||
selectedEstablishmentId,
|
||||
setSelectedEstablishmentId,
|
||||
establishments,
|
||||
} = useEstablishment();
|
||||
const { user, selectedEstablishmentId } = useEstablishment();
|
||||
|
||||
const router = useRouter();
|
||||
|
||||
@ -33,14 +27,6 @@ export default function ParentHomePage() {
|
||||
});
|
||||
}, [selectedEstablishmentId]);
|
||||
|
||||
const handleEstablishmentChange = (e) => {
|
||||
const establishmentId = parseInt(e.target.value, 10);
|
||||
setSelectedEstablishmentId(establishmentId);
|
||||
const role = establishments.find(
|
||||
(est) => est.id === establishmentId
|
||||
)?.role_type;
|
||||
setProfileRole(role);
|
||||
};
|
||||
function handleEdit(eleveId) {
|
||||
// Logique pour éditer le dossier de l'élève
|
||||
logger.debug(`Edit dossier for student id: ${eleveId}`);
|
||||
|
||||
Reference in New Issue
Block a user