import React from 'react'; import { UxTListEntry } from 'App/services/UxtestingService'; import { observer } from 'mobx-react-lite'; import { useStore } from 'App/mstore'; import { numberWithCommas, debounce } from 'App/utils'; import { Button, Input, Typography, Tag, Modal, Space } from 'antd'; import AnimatedSVG from 'Shared/AnimatedSVG'; import { ICONS } from 'Shared/AnimatedSVG/AnimatedSVG'; import { Loader, NoContent, Pagination, Link, Icon } from 'UI'; import { checkForRecent, getDateFromMill } from 'App/date'; import { ArrowRightOutlined, PlusOutlined } from '@ant-design/icons'; import { useHistory, useParams } from 'react-router-dom'; import { withSiteId, usabilityTestingEdit, usabilityTestingView, } from 'App/routes'; import withPageTitle from 'HOCs/withPageTitle'; import { useTranslation } from 'react-i18next'; const { Search } = Input; const PER_PAGE = 10; let debouncedSearch: any = () => null; const defaultDescription = "To assess how easy it is to use [Feature Name], we'll look at how users interact with it, how efficient it is, and if they're happy using it."; function TestsTable() { const { t } = useTranslation(); const inputRef = React.useRef(null); const [newTestTitle, setNewTestTitle] = React.useState(''); const [newTestDescription, setNewTestDescription] = React.useState(defaultDescription); const [isModalVisible, setIsModalVisible] = React.useState(false); const { uxtestingStore } = useStore(); const onSearch = (value: string) => { uxtestingStore.setQuery(value); debouncedSearch(); }; React.useEffect(() => { uxtestingStore.getList(); debouncedSearch = debounce(uxtestingStore.getList, 500); }, []); const onPageChange = (page: number) => { uxtestingStore.setPage(page); uxtestingStore.getList(); }; // @ts-ignore const { siteId } = useParams(); const history = useHistory(); const onClose = (confirmed: boolean) => { if (confirmed) { uxtestingStore.initNewTest(newTestTitle, newTestDescription, siteId); setNewTestDescription(''); setNewTestTitle(''); redirect('new'); } setIsModalVisible(false); }; const openModal = () => { setIsModalVisible(true); setTimeout(() => { inputRef.current?.focus(); }, 10); }; const redirect = (path: string) => { history.push(withSiteId(usabilityTestingEdit(path), siteId)); }; return (
onClose(true)} onCancel={() => onClose(false)} footer={ } > {t('Title')} setNewTestTitle(e.target.value)} /> {t('Test Objective (optional)')} setNewTestDescription(e.target.value)} placeholder="Share a brief statement about what you aim to discover through this study." />

{t('Usability Tests')}

onSearch(v.target.value)} onSearch={onSearch} style={{ width: 200 }} />
{uxtestingStore.searchQuery === '' ? ( ) : ( )}
{uxtestingStore.searchQuery === '' ? 'Uncover real user insights through usability tests' : 'No matching results'}
{uxtestingStore.searchQuery === '' ? 'Conduct summative usability testing to observe task completion and iterate your product.' : ''}
} >
{t('Test Title')}
{t('Created by')}
{t('Updated at')}
{t('Status')}
{uxtestingStore.tests.map((test) => ( ))}
{uxtestingStore.isLoading || uxtestingStore.tests?.length === 0 ? null : ( <>
{t('Showing')}{' '} {(uxtestingStore.page - 1) * PER_PAGE + 1} {' '} {t('to')}{' '} {(uxtestingStore.page - 1) * PER_PAGE + uxtestingStore.tests.length} {' '} {t('of')}{' '} {numberWithCommas(uxtestingStore.total)} {' '} {t('tests.')}
)}
); } const statusMap = { preview: 'Draft', 'in-progress': 'Ongoing', paused: 'On Hold', closed: 'Closed', }; function Row({ test, siteId }: { test: UxTListEntry; siteId: string }) { const link = usabilityTestingView(test.testId.toString()); const editLink = usabilityTestingEdit(test.testId.toString()); const history = useHistory(); const redirect = () => { history.push( withSiteId(test.status === 'preview' ? editLink : link, siteId), ); }; return (
{test.title}
{test.description}
{test.createdBy.name} {checkForRecent( getDateFromMill(test.updatedAt)!, 'LLL dd, yyyy, hh:mm a', )} {statusMap[test.status]}
); } const colors = { 'in-progress': 'green', closed: '', paused: 'orange', preview: 'geekblue', } as const; function Cell({ size, children, }: { size: number; children?: React.ReactNode; }) { return
{children}
; } export default withPageTitle('Usability Tests')(observer(TestsTable));