diff --git a/src/frontend/src/components/QrcodeComponent.jsx b/src/frontend/src/components/QrcodeComponent.jsx index cd7e12a0da..38d96bdbfd 100755 --- a/src/frontend/src/components/QrcodeComponent.jsx +++ b/src/frontend/src/components/QrcodeComponent.jsx @@ -1,143 +1,33 @@ -import React, { useState } from 'react'; -import BasicCard from '@/utilities/BasicCard'; -// import Activities from "./Activities"; -import environment from '@/environment'; -import { ProjectFilesById } from '@/api/Files'; +import React from 'react'; import CoreModules from '@/shared/CoreModules'; import AssetModules from '@/shared/AssetModules'; -import { HomeActions } from '@/store/slices/HomeSlice'; - -const TasksComponent = ({ type, task, defaultTheme }) => { - const dispatch = CoreModules.useAppDispatch(); - const [open, setOpen] = useState(false); - const params = CoreModules.useParams(); - const projectName = CoreModules.useAppSelector((state) => state.project.projectInfo.title); - const projectTaskData = CoreModules.useAppSelector((state) => state.project.projectTaskBoundries); - const currentProjectId = environment.decode(params.id); - const projectIndex = projectTaskData.findIndex((project) => project.id == currentProjectId); - const token = CoreModules.useAppSelector((state) => state.login.loginToken); - const selectedTask = { - ...projectTaskData?.[projectIndex]?.taskBoundries?.filter((indTask, i) => { - return indTask.id == task; - })?.[0], - }; - const checkIfTaskAssignedOrNot = - selectedTask?.locked_by_username === token?.username || selectedTask?.locked_by_username === null; - - // TODO fix multiple renders of component (6 times) - const { qrcode } = ProjectFilesById(selectedTask.odk_token, projectName, token?.username, task); - - // const socialStyles = { - // copyContainer: { - // border: `1px solid ${defaultTheme.palette.info['main']}`, - // background: defaultTheme.palette.info['info'], - // color: defaultTheme.palette.info['main'], - // }, - // title: { - // color: defaultTheme.palette.info['main'], - // fontStyle: 'italic', - // }, - // }; +const TasksComponent = ({ qrcode }) => { return ( - - {checkIfTaskAssignedOrNot && ( - - - - {`Qrcode`} - - - - {qrcode == '' ? ( - - - - - - ) : ( - qrcode - )} - - - - - { - const downloadLink = document.createElement('a'); - downloadLink.href = qrcode; - downloadLink.download = `Task_${task}`; - downloadLink.click(); - }} - disabled={qrcode == '' ? true : false} - color="info" - aria-label="download qrcode" - > - - - - { - document.location.href = - 'intent://getodk.org/#Intent;scheme=app;package=org.odk.collect.android;end'; - }} - > - Go To ODK - - - { - dispatch( - HomeActions.SetSnackBar({ - open: true, - message: `not implemented`, - variant: 'warning', - duration: 3000, - }), - ); - // setOpen(true); - }} - disabled={qrcode == '' ? true : false} - color="info" - aria-label="share qrcode" - > - - - - {/* console.log(data)} - style={socialStyles} - /> - } - onClose={() => { - setOpen(false); - }} - open={open} - /> */} - - - - } - /> - - )} - +
+
+ {qrcode == '' ? ( + + ) : ( + qrcode + )} +
+ +
+
+
); };