This commit is contained in:
Vsevo;od
2023-12-23 11:29:24 +03:00
parent 85afad5327
commit 64317df44c
4 changed files with 74 additions and 22 deletions

View File

@ -2,16 +2,20 @@ import React from 'react';
import './style.css'
import styled from 'styled-components';
import { HttpApiMethods } from '../fetchUtils/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';
const httpApiMethods = new HttpApiMethods()
const meets = await httpApiMethods.GetMeetings()
const Home = () => {
const Home = () => {
const [count, setCount] = useState(7)
function extractDateTime(dateString) {
const dateTime = new Date(dateString);
const date = dateTime.toLocaleDateString();
@ -19,26 +23,47 @@ const Home = () => {
return { date, time };
}
const filterMeet = meets.filter( (item, index) => index <= count )
const allMeets = () => {
setCount(meets.length)
}
return (
<div className='wrapp'>
{Array.isArray(meets) ? (
meets.map((item, index) => (
<div className='event_card' key={index}>
<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>
<>
<Box sx={{ flexGrow: 1, display: 'flex', justifyContent: 'flex-end', alignItems:'center'}}>
<Grid container sx={{width: '96%'}}>
{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>
<h4 className="event-card__title">{item.title}</h4>
<p className="event-card__date">{extractDateTime(item.time).date}, в {extractDateTime(item.time).time} по Московскому времени</p>
</div>
))
) : (
<p>Неверный тип данных с сервера!</p>
)}
{/* <EditForm></EditForm> */}
</div>
</Grid>
))
) : (
<p>Неверный тип данных с сервера!</p>
)}
{/* <EditForm></EditForm> */}
</Grid>
</Box>
<div className='allButton__container'>
<button onClick={allMeets} className='allButton'>Все мероприятия</button>
</div>
</>
);
}