Skip to content

Commit

Permalink
fix(files): cleanup function remove
Browse files Browse the repository at this point in the history
  • Loading branch information
NSUWAL123 authored and spwoodcock committed Oct 14, 2024
1 parent 2c3f06b commit 34aaddf
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions src/frontend/src/api/Files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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 };
};
Expand Down

0 comments on commit 34aaddf

Please sign in to comment.