diff --git a/src/frontend/src/api/Files.ts b/src/frontend/src/api/Files.ts index 79e69b468..f130f6818 100755 --- a/src/frontend/src/api/Files.ts +++ b/src/frontend/src/api/Files.ts @@ -16,13 +16,14 @@ export const GetProjectQrCode = ( osmUser: string, ): { qrcode: string } => { const [qrcode, setQrcode] = useState(''); + useEffect(() => { const fetchProjectFileById = async ( odkToken: string | undefined, projectName: string | undefined, osmUser: string, ) => { - if (odkToken === '') { + if (!odkToken || !projectName) { setQrcode(''); return; } @@ -46,18 +47,11 @@ export const GetProjectQrCode = ( // Note: pako.deflate zlib encodes to content code.addData(base64zlibencode(odkCollectJson)); code.make(); - // Note: cell size = 3, margin = 5 setQrcode(code.createDataURL(3, 5)); }; fetchProjectFileById(odkToken, projectName, osmUser); - - const cleanUp = () => { - setQrcode(''); - }; - - return cleanUp; }, [projectName, odkToken, osmUser]); return { qrcode }; }; diff --git a/src/frontend/src/components/QrcodeComponent.tsx b/src/frontend/src/components/QrcodeComponent.tsx index ec3288073..a0f0b9255 100755 --- a/src/frontend/src/components/QrcodeComponent.tsx +++ b/src/frontend/src/components/QrcodeComponent.tsx @@ -26,7 +26,7 @@ const QrcodeComponent = ({ projectId, taskIndex }: tasksComponentType) => {
{qrcode == '' ? ( - + ) : ( qrcode )}