Use jwt officeId for query params
This commit is contained in:
parent
20a333c106
commit
520a77eafd
@ -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
|
||||
@ -64,6 +71,8 @@ export default function DefaultNotaryDashboard(props: IProps) {
|
||||
|
||||
const onSelectedBlock = (block: IBlock) => {
|
||||
const folder = folders.find((folder) => folder.uid === block.id);
|
||||
console.error("Folder list:", JSON.stringify(folders));
|
||||
console.error("JWT:", JSON.stringify(jwt));
|
||||
if (!folder) return;
|
||||
const path = redirectPath.replace("[folderUid]", folder.uid ?? "");
|
||||
router.push(path);
|
||||
@ -78,7 +87,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,
|
||||
|
Loading…
x
Reference in New Issue
Block a user