Skip to content

Commit

Permalink
Merge pull request #1813 from hotosm/fix/staging-bugs
Browse files Browse the repository at this point in the history
Fix QR code issue
  • Loading branch information
NSUWAL123 authored Sep 27, 2024
2 parents 54d4231 + 4226d24 commit fdcb88f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 9 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
2 changes: 1 addition & 1 deletion src/frontend/src/components/QrcodeComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const QrcodeComponent = ({ projectId, taskIndex }: tasksComponentType) => {
<div className="fmtm-flex fmtm-justify-center sm:fmtm-py-5 fmtm-border-t-[1px]">
<div className="fmtm-relative fmtm-hidden sm:fmtm-block fmtm-bg-white fmtm-p-2 !fmtm-w-[9rem] fmtm-rounded-tl-lg fmtm-rounded-bl-lg">
{qrcode == '' ? (
<CoreModules.Skeleton width={170} height={170} />
<CoreModules.Skeleton width={128} height={128} />
) : (
<img id="qrcodeImg" src={qrcode} alt="qrcode" className="" />
)}
Expand Down

0 comments on commit fdcb88f

Please sign in to comment.