lab 8 p6/7 done

This commit is contained in:
2026-04-23 16:49:22 +10:00
parent 80e4415e44
commit cb7fecffc9
5 changed files with 65 additions and 32 deletions

View File

@@ -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>
);