import { durationFormatted } from 'App/date';
import { numberWithCommas } from 'App/utils';
import { getPdf2 } from 'Components/AssistStats/pdfGenerator';
import { useModal } from 'Components/Modal';
import React from 'react';
import { Button, Typography, Select, Space, Popover, Dropdown } from 'antd';
import { withSiteId, usabilityTesting, usabilityTestingEdit } from 'App/routes';
import { useParams, useHistory } from 'react-router-dom';
import Breadcrumb from 'Shared/Breadcrumb';
import { observer } from 'mobx-react-lite';
import { useStore } from 'App/mstore';
import {
EditOutlined,
ShareAltOutlined,
ArrowRightOutlined,
MoreOutlined,
UserOutlined,
UserDeleteOutlined,
CheckCircleOutlined,
FastForwardOutlined,
PauseCircleOutlined,
StopOutlined,
HourglassOutlined,
FilePdfOutlined,
DeleteOutlined,
ClockCircleOutlined,
} from '@ant-design/icons';
import SessionItem from 'Shared/SessionItem';
import { Loader, NoContent, Pagination } from 'UI';
import copy from 'copy-to-clipboard';
import { Stage } from 'Components/Funnels/FunnelWidget/FunnelWidget';
import { confirm } from 'UI';
import ResponsesOverview from './ResponsesOverview';
const { Option } = Select;
const statusItems = [
{ value: 'preview', label: 'Preview', icon: },
{ value: 'in-progress', label: 'In Progress', icon: },
{ value: 'paused', label: 'Pause', icon: },
{ value: 'closed', label: 'End Testing', icon: },
];
const menuItems = [
{
key: '1',
label: 'Download Results',
icon: ,
},
{
key: '2',
label: 'Edit',
icon: ,
},
{
key: '3',
label: 'Delete',
icon: ,
},
];
function TestOverview() {
// @ts-ignore
const { siteId, testId } = useParams();
const { showModal } = useModal();
const { uxtestingStore } = useStore();
React.useEffect(() => {
uxtestingStore.getTest(testId);
}, [testId]);
if (!uxtestingStore.instance) {
return No data.;
}
const onPageChange = (page: number) => {
uxtestingStore.setSessionsPage(page);
};
return (
<>
{uxtestingStore.instance.liveCount ? (
{uxtestingStore.instance.liveCount} participants are engaged in this usability test at
the moment.
) : null}
Open-ended task responses
{uxtestingStore.instance.responsesCount ? (
) : (
0 at the moment.
)}
Sessions
{/*
in your selection*/}
{/*
clear selection
*/}
{uxtestingStore.testSessions.list.map((session) => (
// @ts-ignore
))}
Showing{' '}
{(uxtestingStore.testSessions.page - 1) * 10 + 1}
{' '}
to{' '}
{(uxtestingStore.page - 1) * 10 + uxtestingStore.testSessions.list.length}
{' '}
of{' '}
{numberWithCommas(uxtestingStore.testSessions.total)}
{' '}
tests.
>
);
}
const ParticipantOverview = observer(() => {
const { uxtestingStore } = useStore();
return (
Participant Overview
{uxtestingStore.testStats ? (
Total Participants
{uxtestingStore.testStats.tests_attempts}
Completed all tasks
{uxtestingStore.testStats.tests_attempts > 0 ? (
{Math.round(
(uxtestingStore.testStats.completed_all_tasks /
uxtestingStore.testStats.tests_attempts) *
100
)}
%
) : null}
{uxtestingStore.testStats.completed_all_tasks}
Skipped tasks
{uxtestingStore.testStats.tests_attempts > 0 ? (
{Math.round(
(uxtestingStore.testStats.tasks_skipped /
uxtestingStore.testStats.tests_attempts) *
100
)}
%
) : null}
{uxtestingStore.testStats.tasks_skipped}
Aborted the test
{uxtestingStore.testStats.tests_attempts > 0 ? (
{Math.round(
(uxtestingStore.testStats.tests_skipped /
uxtestingStore.testStats.tests_attempts) *
100
)}
%
) : null}
{uxtestingStore.testStats.tests_skipped}
) : null}
)
})
const TaskSummary = observer(() => {
const { uxtestingStore } = useStore();
return (
Task Summary
{uxtestingStore.taskStats.length ? (
Average completion time for all tasks:
{uxtestingStore.taskStats
? durationFormatted(
uxtestingStore.taskStats.reduce(
(stats, task) => stats + task.avgCompletionTime,
0
) / uxtestingStore.taskStats.length
)
: null}
) : null}
{!uxtestingStore.taskStats.length ?
: null}
{uxtestingStore.taskStats.map((tst, index) => (
))}
)
})
const Title = observer(({ testId, siteId }: any) => {
const { uxtestingStore } = useStore();
const history = useHistory();
const handleChange = (value: string) => {
uxtestingStore.updateTestStatus(value);
};
const onMenuClick = async ({ key }: any) => {
if (key === '1') {
void getPdf2();
}
if (key === '2') {
await redirectToEdit();
}
if (key === '3') {
if (
await confirm({
confirmation:
'Are you sure you want to delete this usability test? This action cannot be undone.',
})
) {
uxtestingStore.deleteTest(testId).then(() => {
history.push(withSiteId(usabilityTesting(), siteId));
});
}
}
};
const redirectToEdit = async () => {
if (
await confirm({
confirmation:
'This test already has responses, making edits at this stage may result in confusing outcomes.',
confirmButton: 'Edit',
})
) {
history.push(withSiteId(usabilityTestingEdit(testId), siteId));
}
};
return (
{uxtestingStore.instance!.title}
{uxtestingStore.instance!.description}
{`${uxtestingStore.instance!.startingPath}?oruxt=${
uxtestingStore.instance!.testId
}`}
}
>
}>
)
})
export default observer(TestOverview);