) : null}
);
});
const Title = observer(({ testId, siteId }: any) => {
const { t } = useTranslation();
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(
t(
'The test is now live. Use the distribution link to share it with participants.',
),
);
break;
case 'paused':
toast.success(
t(
"The test is on 'Hold'—participant activity paused. Toggle back to “ongoing” to resume activity.",
),
);
break;
case 'closed':
toast.success(t('The test is complete and closed.'));
break;
}
};
const onMenuClick = async ({ key }: any) => {
if (key === '1') {
void getPdf2();
}
if (key === '2') {
await redirectToEdit();
}
if (key === '3') {
if (
await confirm({
confirmation: t(
'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'
? t('Editing Active Usability Test')
: t('Editing Test on Hold');
const confirmationStr =
uxtestingStore.instance!.status === 'in-progress'
? t(
"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! 🚧",
)
: t(
'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: t('Edit'),
})
) {
history.push(withSiteId(usabilityTestingEdit(testId), siteId));
}
};
// @ts-ignore
const getColor = (status) => colors[status];
const isActive = ['in-progress', 'preview'].includes(
uxtestingStore.instance!.status,
);
return (