import React from 'react'; import { useStore } from 'App/mstore'; import { numberWithCommas } from 'App/utils'; import { Step } from 'Components/UsabilityTesting/TestEdit'; import OutsideClickDetectingDiv from 'Shared/OutsideClickDetectingDiv'; import { Loader, NoContent, Pagination } from 'UI'; import { Button, Typography, Input } from 'antd'; import { observer } from 'mobx-react-lite'; import { DownOutlined } from '@ant-design/icons'; import { debounce } from 'App/utils' let debounceUpdate: any = () => {} const ResponsesOverview = observer(() => { const { uxtestingStore } = useStore(); const [search, setSearch] = React.useState(''); const [page, setPage] = React.useState(1); const [showAll, setShowAll] = React.useState(false); const [taskId, setTaskId] = React.useState(undefined); React.useEffect(() => { setTaskId(uxtestingStore.instance?.tasks.filter((t) => t.allowTyping)[0].taskId); }, [uxtestingStore.instance?.tasks]); React.useEffect(() => { if (taskId) { void refreshData(); } }, [page, taskId]); debounceUpdate = debounce((text: string) => { void refreshData(text); }, 200) const refreshDataQuery = (text: string) => { setSearch(text) debounceUpdate(text) } const refreshData = (searchText?: string) => taskId ? uxtestingStore.fetchResponses(uxtestingStore.instance!.testId!, taskId, page, searchText || search) : null; const selectedIndex = uxtestingStore.instance?.tasks.findIndex((task) => task.taskId === taskId)!; const task = uxtestingStore.instance?.tasks.find((task) => task.taskId === taskId); return (
Open-ended task responses
Select Task / Question setShowAll(false)}>
setShowAll(!showAll)}>
} />
{showAll ? (
{uxtestingStore.instance?.tasks .filter((t) => t.taskId !== taskId && t.allowTyping) .map((task) => (
{ setShowAll(false); setTaskId(task.taskId); }} > t.taskId === task.taskId)!} title={task.title} description={task.description} />
))}
) : null}
# Response
Participant
Response
refreshDataQuery(e.target.value)} classNames={{ input: '!border-0 focus:!border-0' }} onSearch={() => refreshData()} />
No data yet} >
{uxtestingStore.responses[taskId!]?.list.map((r, i) => (
{i + 10 * (page - 1) + 1}
{r.user_id || 'Anonymous User'}
{r.comment}
))}
Showing {(page - 1) * 10 + 1} to{' '} {(page - 1) * 10 + uxtestingStore.responses[taskId!]?.list.length} {' '} of{' '} {numberWithCommas(uxtestingStore.responses[taskId!]?.total)} {' '} replies.
setPage(p)} />
); }); export default ResponsesOverview;