lab 8 p6/7 done
This commit is contained in:
@@ -1,11 +1,22 @@
|
||||
import { Grid, List, ListItem, ListItemButton, ListItemText } from '@mui/material';
|
||||
import type {tTasks} from "../quizData"
|
||||
import SortableList from '../features/SortableList';
|
||||
import { useEffect } from 'react';
|
||||
import { useDispatch } from 'react-redux';
|
||||
import { addList } from './quizSlice';
|
||||
interface ComponentProps {
|
||||
tasks: tTasks;
|
||||
index: number;
|
||||
}
|
||||
|
||||
function Matching({tasks}: ComponentProps) {
|
||||
function Matching({tasks,index}: ComponentProps) {
|
||||
const dispatch = useDispatch();
|
||||
|
||||
// Добавляем список ответов очередного задания в хранилище
|
||||
useEffect(() => {
|
||||
dispatch(addList({ index, items: answers }));
|
||||
}, []);
|
||||
|
||||
const answers: string[] = tasks.map((item) => item.answer);
|
||||
return (
|
||||
<Grid container spacing={2}>
|
||||
@@ -26,8 +37,8 @@ function Matching({tasks}: ComponentProps) {
|
||||
</List>
|
||||
</Grid>
|
||||
|
||||
<Grid size={6}>
|
||||
<SortableList answers={answers} />
|
||||
<Grid size={6}>
|
||||
<SortableList index={index} answers={answers}/>
|
||||
</Grid>
|
||||
</Grid>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user