mirror of
https://git.rdcenter.ru/RDCenter/skb-kit.git
synced 2026-12-05 04:59:45 +00:00
Заменить заглушку иконок футера на полученную из API
This commit is contained in:
1 parent
0ff4077d08
commit
147ec547e9
3 files changed
+31
-10
No files matched your search
@@ -1,23 +1,27 @@
|
||||
import { useState, useEffect } from 'react';
|
||||
|
||||
import FooterLink from './FooterLink';
|
||||
import FooterContacts from './FooterContacts';
|
||||
import { getMedia } from '../../api';
|
||||
|
||||
import { scb as logo } from '../../assets/images';
|
||||
import { iconIctis, iconSfedu, iconVK } from '../../assets/images/footer';
|
||||
import './Footer.styles.scss';
|
||||
import FooterContacts from './FooterContacts';
|
||||
|
||||
const mockLinks = [
|
||||
{
|
||||
const mockLinks = {
|
||||
ictis: {
|
||||
icon: iconIctis,
|
||||
to: "https://ictis.sfedu.ru",
|
||||
},
|
||||
{
|
||||
sfedu: {
|
||||
icon: iconSfedu,
|
||||
to: "https://sfedu.ru",
|
||||
},
|
||||
{
|
||||
vk: {
|
||||
icon: iconVK,
|
||||
to: "https://vk.com/skbkit",
|
||||
},
|
||||
];
|
||||
};
|
||||
|
||||
const mockContacts = {
|
||||
email: "skb@sfedu.ru",
|
||||
@@ -26,6 +30,22 @@ const mockContacts = {
|
||||
};
|
||||
|
||||
function Footer({ links = mockLinks, contacts = mockContacts }) {
|
||||
const [mediaList, setMediaList] = useState(links);
|
||||
|
||||
useEffect(() => {
|
||||
const loadData = async () => {
|
||||
const footerMedia = await getMedia('footer');
|
||||
const newMediaList = mediaList;
|
||||
|
||||
for (let media of footerMedia) {
|
||||
newMediaList[media.name].icon = media.url;
|
||||
}
|
||||
|
||||
setMediaList(newMediaList);
|
||||
};
|
||||
loadData();
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<footer className="footer">
|
||||
<div className="logo-container">
|
||||
@@ -33,7 +53,7 @@ function Footer({ links = mockLinks, contacts = mockContacts }) {
|
||||
</div>
|
||||
<FooterContacts contacts={ contacts } />
|
||||
<div className="links">
|
||||
{ links.map((link, index) => <FooterLink link={link} key={index} />) }
|
||||
{ Object.keys(mediaList).forEach((link, index) => <FooterLink link={link} key={index} />) }
|
||||
</div>
|
||||
</footer>
|
||||
);
|
||||
|
||||
Reference in new issue
Block a user