diff --git a/src/features/MatchCard/CardFrontside/hooks.tsx b/src/features/MatchCard/CardFrontside/hooks.tsx index 7aa5309a..b8de0f6a 100644 --- a/src/features/MatchCard/CardFrontside/hooks.tsx +++ b/src/features/MatchCard/CardFrontside/hooks.tsx @@ -4,20 +4,20 @@ import { useState, } from 'react' -import { readToken } from 'helpers' - export type TUseCardFrontside = { preview?: string, previewURL?: string, } +const PREVIEW_WIDTH = 400 // макс. 1920 + export const useCardPreview = ({ preview, previewURL, }: TUseCardFrontside) => { const [previewImage, setPreviewImage] = useState('') const currentPreviewURL = useMemo(() => ( - previewURL ? `${previewURL}?access_token=${readToken()}` : preview + previewURL ? `${previewURL}?width=${PREVIEW_WIDTH}` : preview ), [preview, previewURL]) useEffect(() => { @@ -25,12 +25,11 @@ export const useCardPreview = ({ if (!currentPreviewURL) return try { - const image = await fetch(String(currentPreviewURL), { - headers: { Authorization: `Bearer ${readToken()}` }, - }).then(async (result) => ({ - blob: await result.blob(), - status: result.status, - })) + const image = await fetch(String(currentPreviewURL)) + .then(async (result) => ({ + blob: await result.blob(), + status: result.status, + })) if (image.status === 200) { setPreviewImage(URL.createObjectURL(image.blob))