diff --git a/cucumber-frontend/src/App.tsx b/cucumber-frontend/src/App.tsx index f3bfa31..f22ff4f 100644 --- a/cucumber-frontend/src/App.tsx +++ b/cucumber-frontend/src/App.tsx @@ -5,6 +5,7 @@ import {LoginPage} from './pages/Login'; import {RegisterPage} from './pages/Register'; import {AppLayout} from './components/Layout'; import { ProfilePage } from './pages/Profile'; +import { GreenHouseListPage } from './pages/GreenHouseListPage'; function App() { return ( @@ -15,6 +16,7 @@ function App() { } /> } /> } /> + } /> diff --git a/cucumber-frontend/src/models/IGreenGouse.tsx b/cucumber-frontend/src/models/IGreenGouse.tsx new file mode 100644 index 0000000..d63a71d --- /dev/null +++ b/cucumber-frontend/src/models/IGreenGouse.tsx @@ -0,0 +1,13 @@ +import IFarm from "./IFarm"; +import { HeatingMode } from "./Support/HeatingMode"; +import { WateringMode } from "./Support/WateringMode"; + +export interface IGreenhouse { + id: number; + recommendedTemperature: number; + wateringMode: WateringMode; + heatingMode: HeatingMode; + farmId: number; + farm?: IFarm; +} + diff --git a/cucumber-frontend/src/models/Support/HeatingMode.ts b/cucumber-frontend/src/models/Support/HeatingMode.ts new file mode 100644 index 0000000..57610d8 --- /dev/null +++ b/cucumber-frontend/src/models/Support/HeatingMode.ts @@ -0,0 +1,4 @@ +export enum HeatingMode { + Manual, + Auto +} \ No newline at end of file diff --git a/cucumber-frontend/src/models/Support/WateringMode.ts b/cucumber-frontend/src/models/Support/WateringMode.ts new file mode 100644 index 0000000..b3fe0bd --- /dev/null +++ b/cucumber-frontend/src/models/Support/WateringMode.ts @@ -0,0 +1,4 @@ +export enum WateringMode { + Manual, + Auto +} \ No newline at end of file diff --git a/cucumber-frontend/src/pages/GreenHouseListPage.tsx b/cucumber-frontend/src/pages/GreenHouseListPage.tsx new file mode 100644 index 0000000..e68ea81 --- /dev/null +++ b/cucumber-frontend/src/pages/GreenHouseListPage.tsx @@ -0,0 +1,128 @@ +import React, { useState, useEffect } from 'react'; +import { Modal, Button, Table, Form, Input, Select, Space } from 'antd'; + +interface IGreenhouse { + id: number; + name: string; + recommendedTemperature: number; + wateringMode: 'Manual' | 'Auto'; + heatingMode: 'Manual' | 'Auto'; +} + +export function GreenHouseListPage() { + const [greenhouses, setGreenhouses] = useState([]); + const [isModalVisible, setIsModalVisible] = useState(false); + const [editingGreenhouse, setEditingGreenhouse] = useState(null); + const [form] = Form.useForm(); + + + useEffect(() => { + fetchGreenhouses(); + }, []); + + const fetchGreenhouses = async () => { + // Fetch data from API + }; + + const handleAddOrEditSubmit = () => { + form.validateFields().then((values) => { + if (editingGreenhouse) { + setGreenhouses(greenhouses.map(g => g.id === editingGreenhouse.id ? { ...g, ...values } : g)); + } else { + setGreenhouses([...greenhouses, { id: Date.now(), ...values }]); + } + setIsModalVisible(false); + setEditingGreenhouse(null); + form.resetFields(); + }); + }; + + const handleDelete = (id: number) => { + setGreenhouses(greenhouses.filter(g => g.id !== id)); + }; + + const handleModalOpen = (greenhouse?: IGreenhouse) => { + setEditingGreenhouse(greenhouse || null); + setIsModalVisible(true); + if (greenhouse) { + form.setFieldsValue(greenhouse); + } + }; + const columns = [ + { + title: 'Название', + dataIndex: 'name', + key: 'name', + }, + { + title: 'Температура', + dataIndex: 'recommendedTemperature', + key: 'recommendedTemperature', + }, + { + title: 'Режим полива', + dataIndex: 'wateringMode', + key: 'wateringMode', + render: (text: string) => text === 'Manual' ? 'Вручную' : 'Автоматически', + }, + { + title: 'Режим отопления', + dataIndex: 'heatingMode', + key: 'heatingMode', + render: (text: string) => text === 'Manual' ? 'Вручную' : 'Автоматически', + }, + { + title: 'Действия', + key: 'action', + render: (_: any, record: IGreenhouse) => ( + + + + + ), + }, + ]; + return ( +
+

Список теплиц

+ + + + + + { + setIsModalVisible(false); + form.resetFields(); + setEditingGreenhouse(null); + }} + > +
+ + + + + + + + + + + + + +
+ + ); +}; \ No newline at end of file