import { UxTest, UxTListEntry } from "App/services/UxtestingService"; import React from 'react'; import { observer } from 'mobx-react-lite'; import { useStore } from 'App/mstore'; import { numberWithCommas } from 'App/utils'; import { Button, Input, Typography, Tag, Avatar, Modal, Space } from 'antd'; import AnimatedSVG from 'Shared/AnimatedSVG'; import { ICONS } from 'Shared/AnimatedSVG/AnimatedSVG'; import { Loader, NoContent, Pagination, Link } from 'UI'; import { checkForRecent, getDateFromMill } from 'App/date'; import { UnorderedListOutlined, ArrowRightOutlined } from '@ant-design/icons'; import { useHistory, useParams } from 'react-router-dom'; import { withSiteId, usabilityTestingEdit, usabilityTestingView } from 'App/routes'; import { debounce } from 'App/utils'; const { Search } = Input; const PER_PAGE = 10; let debouncedSearch: any = () => null function TestsTable() { const [newTestTitle, setNewTestTitle] = React.useState(''); const [newTestDescription, setNewTestDescription] = React.useState(''); 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); setNewTestDescription(''); setNewTestTitle(''); redirect('new'); } setIsModalVisible(false); }; const openModal = () => { setIsModalVisible(true); }; const redirect = (path: string) => { history.push(withSiteId(usabilityTestingEdit(path), siteId)); }; return ( <> onClose(true)} onCancel={() => onClose(false)} footer={ } > Name this user test setNewTestTitle(e.target.value)} /> Test Objective (optional) setNewTestDescription(e.target.value)} placeholder="Share a brief statement about what you aim to discover through this study." />
Usability Tests
onSearch(v.target.value)} onSearch={onSearch} style={{ width: 200 }} />
Test Title
Created by
Updated at
Status
{uxtestingStore.searchQuery === '' ? "You haven't created any user tests yet" : 'No matching results'}
} > {uxtestingStore.tests.map((test) => ( ))}
{uxtestingStore.isLoading || uxtestingStore.tests?.length === 0 ? null : ( <>
Showing{' '} {(uxtestingStore.page - 1) * PER_PAGE + 1} to{' '} {(uxtestingStore.page - 1) * PER_PAGE + uxtestingStore.tests.length} {' '} of {numberWithCommas(uxtestingStore.total)}{' '} tests.
)}
); } const statusMap = { preview: "Preview", 'in-progress': "In progress", paused: "Paused", completed: "Completed", } function Row({ test }: { test: UxTListEntry }) { const link = usabilityTestingView(test.testId.toString()) return (
} />
{test.title}
{test.description}
{test.createdBy.name} {checkForRecent(getDateFromMill(test.updatedAt)!, 'LLL dd, yyyy, hh:mm a')} {statusMap[test.status]}
); } function Cell({ size, children }: { size: number; children?: React.ReactNode }) { return
{children}
; } export default observer(TestsTable);