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 committed Sep 27, 2024
1 parent cb81772 commit 5a1d546
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 5a1d546

Please sign in to comment.