Skip to content

Commit

Permalink
fix display of board content display
Browse files Browse the repository at this point in the history
  • Loading branch information
Florent Mariotti committed Jan 9, 2025
1 parent c3550d0 commit dc11911
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 8 deletions.
11 changes: 10 additions & 1 deletion frontend/src/components/card-content/CardContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,20 @@ import { Box } from "@mui/material";
import { cardContentWrapperStyle } from "./style";
import { CardContentProps } from "./types";
import { displayContentByType, onClick } from "./utils";
import { useBoard } from "~/providers/BoardProvider";

export const CardContent: FC<CardContentProps> = ({ card }) => {
const { boardImages } = useBoard();

return (
<Box sx={cardContentWrapperStyle} onClick={() => onClick(card)}>
{displayContentByType(card)}
{card.resourceType === "board"
? displayContentByType(
card,
boardImages?.find((img: any) => img._id === card.resourceUrl)
?.imageUrl,
)
: displayContentByType(card)}
</Box>
);
};
4 changes: 3 additions & 1 deletion frontend/src/components/card-content/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export const onClick = (card: Card) => {
}
};

export const displayContentByType = (card: Card) => {
export const displayContentByType = (card: Card, src?: string) => {
const cardType = card.resourceType as RESOURCE_TYPE;
switch (cardType) {
case RESOURCE_TYPE.VIDEO:
Expand All @@ -51,5 +51,7 @@ export const displayContentByType = (card: Card) => {
extension={card.metadata ? card.metadata.extension : ""}
/>
);
case RESOURCE_TYPE.BOARD:
return <CardContentImageDisplay defaultImageSrc={src} />;
}
};
8 changes: 2 additions & 6 deletions frontend/src/providers/BoardProvider/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,6 @@ export const BoardProvider: FC<BoardProviderProps> = ({ children }) => {
skip: !boardResourceIds?.length,
});

console.log(boardImages);

useEffect(() => {
console.log("cc", boardImages);
}, [boardImages]);

const documents = useMemo(() => {
return documentsData ?? [];
}, [documentsData]);
Expand Down Expand Up @@ -189,6 +183,7 @@ export const BoardProvider: FC<BoardProviderProps> = ({ children }) => {
openActiveCardAction,
closeActiveCardAction,
behaviours,
boardImages,
}),
[
board,
Expand All @@ -201,6 +196,7 @@ export const BoardProvider: FC<BoardProviderProps> = ({ children }) => {
activeCard,
isModalDuplicate,
behaviours,
boardImages,
],
);

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 @@ -36,6 +36,7 @@ export type BoardContextType = {
openActiveCardAction: (card: Card, actionType: BOARD_MODAL_TYPE) => void;
closeActiveCardAction: (actionType: BOARD_MODAL_TYPE) => void;
behaviours: any;
boardImages: any; //TODO : type
};

export type Section = {
Expand Down

0 comments on commit dc11911

Please sign in to comment.