-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #40 from mikeiken/dev
Enhance UI and API integration with routing
- Loading branch information
Showing
22 changed files
with
170 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
import React from 'react' | ||
|
||
export default function Form() { | ||
return ( | ||
<div className='wrapper'> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,6 +35,7 @@ | |
.modal-content img { | ||
margin: 20px; | ||
width: 400px; | ||
border-radius: 20px; | ||
} | ||
|
||
.modal-content p { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,29 @@ | ||
import React from 'react' | ||
import './style.css' | ||
import { Routes, Route, Link } from 'react-router-dom'; | ||
import AuthForm from '../auth/auth'; | ||
|
||
export default function Header() { | ||
return ( | ||
<> | ||
<div className='header'> | ||
<img className='logo' src={process.env.PUBLIC_URL + '/logo.png'}></img> | ||
<nav className='navbar'> | ||
<a href='#'>Участки</a> | ||
<a href='#'>Подрядчики</a> | ||
<a href='#'>Лицензия</a> | ||
<a href='#'>О нас</a> | ||
|
||
<Link to=''>Участки</Link> | ||
<Link to=''>Подрядчики</Link> | ||
<Link to=''>Лицензия</Link> | ||
<Link to=''>О нас</Link> | ||
|
||
</nav> | ||
<button className='login-btn'>Войти</button> | ||
<Link to='/login'> | ||
<button className='login-btn'>Войти</button> | ||
</Link> | ||
|
||
</div> | ||
<Routes> | ||
<Route path='/login' element={<AuthForm />} /> | ||
</Routes> | ||
</> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,60 @@ | ||
import React, { useState } from 'react'; | ||
import React, { useState, useEffect } from 'react'; | ||
import Header from '../header/Header'; | ||
import Footer from '../footer/Footer'; | ||
import Card from '../card/Card'; | ||
import AddItemButton from '../add-item/AddItemButton'; | ||
import './style.css'; | ||
import axios from 'axios'; | ||
|
||
export default function MainPage() { | ||
const [cards, setCards] = useState([{ label: 'картошка', description: 'омерзительная тварь (нет)' }]); | ||
const [data, setData] = useState([]); | ||
const [loading, setLoading] = useState(true); | ||
const [error, setError] = useState(null); | ||
|
||
const addCard = () => { | ||
// Добавляем новую карточку, можно сделать динамичнее | ||
setCards([...cards, { label: 'новая карточка', description: 'описание новой карточки' }]); | ||
}; | ||
useEffect(() => { | ||
const fetchData = async () => { | ||
try { | ||
setLoading(true); | ||
const response = await axios.get('http://homelab.kerasi.ru/api/v1/plant/?format=json'); | ||
setData(response.data); | ||
} catch (err) { | ||
setError(err); | ||
} finally { | ||
setLoading(false); | ||
} | ||
}; | ||
|
||
fetchData(); | ||
|
||
return () => { | ||
console.log(data); | ||
}; | ||
}, []); | ||
|
||
return ( | ||
<div> | ||
<div className='max-height'> | ||
<Header /> | ||
<div className='h-container'> | ||
<div className='box1'> | ||
наверное выбор всякой всячины | ||
|
||
</div> | ||
<div className='box2'> | ||
{cards.map((card, index) => ( | ||
<Card key={index} label={card.label + ` ${index}`} description={card.description} /> | ||
))} | ||
<AddItemButton onAdd={addCard} /> | ||
{loading ? ( | ||
<div className='centered-spinner'> | ||
<div className="spinner"></div> | ||
</div> | ||
) : error ? ( | ||
<p className='centered-spinner'>Error: {error.message}</p> | ||
) : data.length === 0 ? ( | ||
<p>Пусто</p> | ||
) : ( | ||
data.map(item => ( | ||
<Card key={item.id} label={item.name} description={item.nutrients} /> | ||
)) | ||
)} | ||
{/* <AddItemButton onAdd={''} /> */} | ||
</div> | ||
|
||
</div> | ||
<Footer /> | ||
</div> | ||
); | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters