Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
FlorentMr committed Dec 3, 2024
1 parent b07c911 commit ebf30d4
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
12 changes: 1 addition & 11 deletions frontend/src/components/card-content-file/CardContentFile.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { FC, useEffect } from "react";
import { FC } from "react";

import { filesize } from "filesize";

Expand All @@ -9,18 +9,12 @@ import { PDFUploadViewer } from "../PdfUploadViewer/PdfUploadViewer";
import { PreviewContentImage } from "../preview-content-image/PreviewContentImage";
import { FILE_EXTENSION } from "~/core/enums/file-extension.enum";
import { ThemeBreakpoint } from "~/core/enums/theme-breakpoints.enum";
import { useEntcoreBehaviours } from "~/hooks/useEntcoreBehaviours";
import { useFileExtensionDescription } from "~/hooks/useFileExtensionDescription";
import { useBoard } from "~/providers/BoardProvider";
import { useCanEditDocumentQuery } from "~/services/api/magnetoWorkspace.service";

export const CardContentFile: FC<CardContentFileProps> = ({ card }) => {
const { documents, displayModals, hasEditRights } = useBoard();
const { behaviours, isLoading } = useEntcoreBehaviours();

const initLool = async () => {
await behaviours.applicationsBehaviours["lool"].init();
};

const cardDocument = documents.find((doc) => doc._id === card.resourceId);
const extensionText = useFileExtensionDescription(card.metadata.extension);
Expand All @@ -29,10 +23,6 @@ export const CardContentFile: FC<CardContentFileProps> = ({ card }) => {
);
const size = filesize(card.metadata.size);

useEffect(() => {
initLool();
}, [isLoading]);

const isOfficePdf = () => {
const ext = [
FILE_EXTENSION.DOC,
Expand Down
12 changes: 12 additions & 0 deletions frontend/src/providers/BoardProvider/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import { Board, IBoardItemResponse } from "~/models/board.model";
import { Card } from "~/models/card.model";
import { useGetBoardDataQuery } from "~/services/api/boardData.service";
import { useGetDocumentsQuery } from "~/services/api/workspace.service";
import { useEntcoreBehaviours } from "~/hooks/useEntcoreBehaviours";

const BoardContext = createContext<BoardContextType | null>(null);

Expand All @@ -47,6 +48,15 @@ export const BoardProvider: FC<BoardProviderProps> = ({ children }) => {
const { id = "" } = useParams();
const { data: boardData, isLoading, isFetching } = useGetBoardDataQuery(id);
const { data: documentsData } = useGetDocumentsQuery("stub");
const { behaviours, isLoading: isLoadingBehaviours } = useEntcoreBehaviours();

const initLool = async () => {
await behaviours.applicationsBehaviours["lool"].init();
};

useEffect(() => {
initLool();
}, [isLoadingBehaviours]);

const [boardRights, setBoardRights] = useState<Record<
RightRole,
Expand Down Expand Up @@ -155,6 +165,7 @@ export const BoardProvider: FC<BoardProviderProps> = ({ children }) => {
cleanActiveCard,
openActiveCardAction,
closeActiveCardAction,
behaviours,
}),
[
board,
Expand All @@ -166,6 +177,7 @@ export const BoardProvider: FC<BoardProviderProps> = ({ children }) => {
isFileDragging,
activeCard,
isModalDuplicate,
behaviours,
],
);

Expand Down
1 change: 1 addition & 0 deletions frontend/src/providers/BoardProvider/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export type BoardContextType = {
cleanActiveCard: () => void;
openActiveCardAction: (card: Card, actionType: BOARD_MODAL_TYPE) => void;
closeActiveCardAction: (actionType: BOARD_MODAL_TYPE) => void;
behaviours: any;
};

export type Section = {
Expand Down

0 comments on commit ebf30d4

Please sign in to comment.