From 1335d34b075f0f565dc5dd4d9f8c26c26c3de03c Mon Sep 17 00:00:00 2001 From: Rakov Date: Thu, 21 Sep 2023 12:46:28 +0300 Subject: [PATCH] fix(preview): added preview width --- src/features/MatchCard/CardFrontside/hooks.tsx | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) 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))