-
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.
рефакторинг: переделал страницу питомцев
- Loading branch information
1 parent
c4e7602
commit 8de3735
Showing
9 changed files
with
180 additions
and
75 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
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 |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import React from 'react'; | ||
import { useOutletContext } from 'react-router-dom'; | ||
import Button from '../../ui/Button/Button'; | ||
import ShelterPetsType from '../ShelterPetsType/ShelterPetsType'; | ||
import './ShelterAllPets.scss'; | ||
|
||
const ShelterAllPets = () => { | ||
const { shelter, countPets, setCountPets, isLoading } = useOutletContext(); | ||
|
||
if (isLoading) { | ||
return null; | ||
} | ||
|
||
return ( | ||
<section className='shelter-all-pets'> | ||
<div className='shelter-all-pets__header'> | ||
<h1 className='shelter-all-pets__title'>Питомцы приюта {shelter.name}</h1> | ||
<Button className='shelter-all-pets__add-pets-button'>Добавить питомца</Button> | ||
</div> | ||
<p className='shelter-all-pets__count-pets'>Всего питомцев: <span>{countPets}</span></p> | ||
{shelter.animal_types && shelter.animal_types.length ? ( | ||
<> | ||
{shelter.animal_types.map((type) => { | ||
return ( | ||
<ShelterPetsType type={type} key={type} countPets={countPets} setCountPets={setCountPets} /> | ||
); | ||
})} | ||
<Button className='shelter-all-pets__load-more-button' theme='transparent'> | ||
Загрузить ещё | ||
</Button> | ||
</> | ||
) : ( | ||
<p className='standard-font_type_body'>На данный момент в приюте животных нет</p> | ||
)} | ||
</section> | ||
); | ||
}; | ||
|
||
export default ShelterAllPets; |
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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
.shelter-all-pets__header { | ||
display: flex; | ||
flex-wrap: wrap; | ||
justify-content: space-between; | ||
margin-bottom: 19px; | ||
} | ||
|
||
.shelter-all-pets__title { | ||
margin: 0; | ||
font-size: 40px; | ||
font-weight: 600; | ||
line-height: 49px; | ||
} | ||
|
||
.shelter-all-pets__count-pets { | ||
font-size: 24px; | ||
font-weight: 500; | ||
line-height: 30px; | ||
margin: 0; | ||
margin-bottom: 44px; | ||
|
||
span { | ||
color: var(--color-accent-base); | ||
} | ||
} | ||
|
||
.shelter-all-pets__load-more-button { | ||
align-self: center; | ||
margin-top: 40px; | ||
} |
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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import BaseApi from '../../utils/BaseApi'; | ||
import { baseUrl, apiHeaders } from '../../utils/constants'; | ||
|
||
class ShelterApi extends BaseApi { | ||
constructor({ _baseUrl, _headers }) { | ||
super({ _baseUrl }); | ||
this._headers = _headers; | ||
} | ||
|
||
getShelterById(id) { // загрузка информации о приюте по его id | ||
return fetch(`${this._baseUrl}/v1/shelters/${id}/`, { | ||
headers: this._headers, | ||
}).then((res) => { | ||
return super._processTheResponse(res); | ||
}); | ||
} | ||
} | ||
|
||
const shelterApi = new ShelterApi({ | ||
_baseUrl: baseUrl, | ||
_headers: apiHeaders, | ||
}); | ||
|
||
export default shelterApi; |