adding the api

This commit is contained in:
2023-12-24 09:14:33 +03:00
parent 949e186112
commit 3c109d1619
22 changed files with 714 additions and 144 deletions

View File

@ -1,71 +1,71 @@
import React from 'react';
import './style.css'
import styled from 'styled-components';
import { HttpApiMethods } from '../utils/FetchUtils';
import {useState} from 'react'
import EditForm from '../post/PostForm';
import Grid from '@mui/material/Grid';
import Card from '../Card';
import Box from '@mui/material/Box';
// import React from 'react';
// import './style.css'
// import styled from 'styled-components';
// // import { HttpApiMethods } from '../utils/FetchUtils';
// import {useState} from 'react'
// import EditForm from '../post/Meets';
// import Grid from '@mui/material/Grid';
// import Card from '../Card';
// import Box from '@mui/material/Box';
function extractDateTime(dateString) {
const dateTime = new Date(dateString);
const date = dateTime.toLocaleDateString();
const time = dateTime.toLocaleTimeString();
// function extractDateTime(dateString) {
// const dateTime = new Date(dateString);
// const date = dateTime.toLocaleDateString();
// const time = dateTime.toLocaleTimeString();
return { date, time };
}
// return { date, time };
// }
const httpApiMethods = new HttpApiMethods()
// const httpApiMethods = new HttpApiMethods()
const meets = await httpApiMethods.GetMeetings()
// const meets = await httpApiMethods.GetMeetings()
const Home = () => {
const [count, setCount] = useState(7)
// const Home = () => {
// const [count, setCount] = useState(7)
const filterMeet = meets.filter( (item, index) => index <= count )
const allMeets = () => {
setCount(meets.length)
}
return (
<>
<Box sx={{ flexGrow: 1, display: 'flex', justifyContent: 'flex-end', alignItems:'center'}}>
<Grid container sx={{width: '96%'}}>
// const filterMeet = meets.filter( (item, index) => index <= count )
// const allMeets = () => {
// setCount(meets.length)
// }
// return (
// <>
// <Box sx={{ flexGrow: 1, display: 'flex', justifyContent: 'flex-end', alignItems:'center'}}>
// <Grid container sx={{width: '96%'}}>
{Array.isArray(meets) ? (
filterMeet.map((item, index) => (
// {Array.isArray(meets) ? (
// filterMeet.map((item, index) => (
<Grid item sm={6} xl={3} md={6} lg={4} key={index}>
<div className='event_card' >
<div className="event-card__photo"><img className='img' src={httpApiMethods.APIURL_FILES + item.speackerImage} alt="{item.speackerImage}" /></div>
<div className="taggs">
<div className='tagged'>{item.tags}</div>
<div className="feautures">{item.type}</div>
</div>
<h4 className="event-card__title">{item.title}</h4>
<p className="event-card__date">{extractDateTime(item.time).date}, в {extractDateTime(item.time).time} по Московскому времени</p>
</div>
</Grid>
// <Grid item sm={6} xl={3} md={6} lg={4} key={index}>
// <div className='event_card' >
// <div className="event-card__photo"><img className='img' src={httpApiMethods.APIURL_FILES + item.speackerImage} alt="{item.speackerImage}" /></div>
// <div className="taggs">
// <div className='tagged'>{item.tags}</div>
// <div className="feautures">{item.type}</div>
// </div>
// <h4 className="event-card__title">{item.title}</h4>
// <p className="event-card__date">{extractDateTime(item.time).date}, в {extractDateTime(item.time).time} по Московскому времени</p>
// </div>
// </Grid>
))
) : (
<p>Неверный тип данных с сервера!</p>
)}
{/* <EditForm></EditForm> */}
</Grid>
</Box>
<div className='allButton__container'>
<button onClick={allMeets} className='allButton'>Все мероприятия</button>
</div>
</>
// ))
// ) : (
// <p>Неверный тип данных с сервера!</p>
// )}
// {/* <EditForm></EditForm> */}
// </Grid>
// </Box>
// <div className='allButton__container'>
// <button onClick={allMeets} className='allButton'>Все мероприятия</button>
// </div>
// </>
);
}
// );
// }
export default Home;
// export default Home;