Use jwt to set folders
This commit is contained in:
parent
22d585b14e
commit
92bf2ac9c3
@ -1,13 +1,14 @@
|
||||
import Folders, { IGetFoldersParams } from "@Front/Api/LeCoffreApi/Notary/Folders/Folders";
|
||||
import EFolderStatus from "le-coffre-resources/dist/Customer/EFolderStatus";
|
||||
import { OfficeFolder } from "le-coffre-resources/dist/Notary";
|
||||
import React, { useCallback, useEffect } from "react";
|
||||
import React, { useCallback, useEffect, useState } from "react";
|
||||
import { EDocumentStatus } from "le-coffre-resources/dist/Notary/Document";
|
||||
|
||||
import Module from "@Front/Config/Module";
|
||||
import { IBlock } from "@Front/Components/DesignSystem/SearchBlockList/BlockList/Block";
|
||||
import { useRouter } from "next/router";
|
||||
import DefaultDashboardWithList, { IPropsDashboardWithList } from "../DefaultDashboardWithList";
|
||||
import JwtService, { IUserJwtPayload } from "@Front/Services/JwtService/JwtService";
|
||||
|
||||
type IProps = IPropsDashboardWithList & {
|
||||
isArchived?: boolean;
|
||||
@ -18,6 +19,12 @@ export default function DefaultNotaryDashboard(props: IProps) {
|
||||
const router = useRouter();
|
||||
const [folders, setFolders] = React.useState<OfficeFolder[]>([]);
|
||||
const { folderUid } = router.query;
|
||||
const [jwt, setJwt] = useState<IUserJwtPayload | undefined>(undefined);
|
||||
|
||||
useEffect(() => {
|
||||
const jwt = JwtService.getInstance().decodeJwt();
|
||||
setJwt(jwt);
|
||||
}, []);
|
||||
|
||||
const redirectPath: string = isArchived
|
||||
? Module.getInstance().get().modules.pages.Folder.pages.FolderArchived.pages.FolderInformation.props.path
|
||||
@ -78,7 +85,7 @@ export default function DefaultNotaryDashboard(props: IProps) {
|
||||
if (isArchived) targetedStatus = EFolderStatus.ARCHIVED;
|
||||
const query: IGetFoldersParams = {
|
||||
q: {
|
||||
where: { status: targetedStatus },
|
||||
where: { status: targetedStatus, office: { uid: jwt?.office_Id } },
|
||||
include: {
|
||||
deed: { include: { deed_type: true } },
|
||||
office: true,
|
||||
@ -107,17 +114,9 @@ export default function DefaultNotaryDashboard(props: IProps) {
|
||||
},
|
||||
};
|
||||
|
||||
console.log('Query envoyée:', JSON.stringify(query, null, 2));
|
||||
|
||||
Folders.getInstance()
|
||||
.get(query)
|
||||
.then((folders) => {
|
||||
console.log('Dossiers reçus:', JSON.stringify(folders, null, 2));
|
||||
setFolders(folders);
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error('Erreur lors de la récupération des dossiers:', error);
|
||||
});
|
||||
.then((folders) => setFolders(folders));
|
||||
}, [isArchived]);
|
||||
|
||||
return (
|
||||
|
Loading…
x
Reference in New Issue
Block a user