diff --git a/front/src/components/Catalog.jsx b/front/src/components/Catalog.jsx
index 45a1807..6c1aec3 100644
--- a/front/src/components/Catalog.jsx
+++ b/front/src/components/Catalog.jsx
@@ -17,6 +17,11 @@ export default function Catalog(props) {
handleShow();
}
+ function handleChoose(itemId) {
+ setModalTitle("Выбрать");
+ props.onChoose(itemId);
+ handleShow();
+ }
function handleEdit(itemId) {
setModalTitle("Редактирование");
props.onEdit(itemId);
@@ -35,6 +40,7 @@ export default function Catalog(props) {
diff --git a/front/src/components/DrivingSchools.jsx b/front/src/components/DrivingSchools.jsx
index 9307bd8..7f662fc 100644
--- a/front/src/components/DrivingSchools.jsx
+++ b/front/src/components/DrivingSchools.jsx
@@ -27,6 +27,8 @@ export default function DrivingSchools(props) {
loadItems();
}, []);
+ const [selectedId, setSelectedId] = useState(null);
+
function loadItems() {
DataService.readAll(url, (data) => new DrivingSchool(data))
.then(data => setItems(data));
@@ -127,15 +129,13 @@ export default function DrivingSchools(props) {
}
const [chosenDrivingSchool, setChosenDrivingSchool] = useState(0);
const navigate = useNavigate();
- function redirectToDrivingSchool() {
-
- if (chosenDrivingSchool !== 0) {
- navigate(`/drivingSchool/${chosenDrivingSchool}`);
- }
+
+ function redirectToDrivingSchool(item) {
+ setSelectedId(item);
+ navigate(`/drivingSchool/${item}`);
}
return
-
diff --git a/front/src/components/commons/ItemTable.jsx b/front/src/components/commons/ItemTable.jsx
index 997d40e..307c6f4 100644
--- a/front/src/components/commons/ItemTable.jsx
+++ b/front/src/components/commons/ItemTable.jsx
@@ -6,12 +6,16 @@ export default function ItemTable(props) {
function remove() {
props.onDelete(props.item.id);
}
+ function chooseDrivingSchool() {
+ props.onChoose(props.item.id);
+ }
return
{
props.headers.map((header) => {props.item[header.name]} | )
}
{props.isOnlyView ||
+
| }
diff --git a/front/src/components/commons/Table.jsx b/front/src/components/commons/Table.jsx
index 2be8fc5..0b990d7 100644
--- a/front/src/components/commons/Table.jsx
+++ b/front/src/components/commons/Table.jsx
@@ -6,6 +6,10 @@ export default function Table(props) {
function remove(itemId) {
props.onDelete(itemId);
}
+ function chooseDrivingSchool(itemId) {
+ props.onChoose(itemId);
+ }
+
return
@@ -25,7 +29,8 @@ export default function Table(props) {
headers={props.headers}
item={item}
onDelete={remove}
- onEdit={edit}
+ onEdit={edit}
+ onChoose={chooseDrivingSchool}
isOnlyView={props.isOnlyView}/>)
}