);
});
const Title = observer(({ testId, siteId }: any) => {
const [truncate, setTruncate] = React.useState(true);
const { uxtestingStore } = useStore();
const history = useHistory();
const handleChange = (value: string) => {
uxtestingStore.updateTestStatus(value);
switch (value) {
case 'in-progress':
toast.success('The usability test is now live and accessible to participants.');
break;
case 'paused':
toast.success(
'Usability test is on \'Hold\'—participant activity paused. Switch it to “ongoing” to resume activity.'
);
break;
case 'closed':
toast.success(
'The usability test has been marked as completed. All participant interactions are now finalized.'
);
break;
}
};
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));
});
}
}
};
if (!uxtestingStore.instance) {
return null;
}
const truncatedDescr = uxtestingStore.instance?.description &&
uxtestingStore.instance.description.length > 250 && truncate
? uxtestingStore.instance?.description.substring(0, 250) + '...'
: uxtestingStore.instance?.description;
const redirectToEdit = async () => {
const confirmationTitle =
uxtestingStore.instance!.status === 'in-progress'
? 'Editing Active Usability Test'
: 'Editing Test on Hold';
const confirmationStr =
uxtestingStore.instance!.status === 'in-progress'
? 'You\'re editing a test that\'s currently active. Please be aware that you can only modify the test title and objective. Editing test steps is not permitted to avoid confusion with existing responses. Proceed with caution! 🚧'
: 'This usability test is on hold. You can only update the title and descriptions. Task editing is not allowed to avoid confusion with existing responses.';
if (
await confirm({
header: confirmationTitle,
confirmation: confirmationStr,
confirmButton: 'Edit'
})
) {
history.push(withSiteId(usabilityTestingEdit(testId), siteId));
}
};
// @ts-ignore
const getColor = (status) => colors[status];
const isActive = ['in-progress', 'preview'].includes(uxtestingStore.instance!.status);
return (