Archived
time
This commit is contained in:
1 parent
9490243314
commit
4421795787
3 files changed
+26
-8
No files matched your search
@@ -7,16 +7,27 @@ export const EventPreview = (props) => {
|
|||||||
const [label, setLabel] = useState("");
|
const [label, setLabel] = useState("");
|
||||||
const [color, setColor] = useState("white");
|
const [color, setColor] = useState("white");
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
console.log(props)
|
||||||
switch (props.type) {
|
switch (props.type) {
|
||||||
case 1:
|
case 1:
|
||||||
setColor("#53d188");
|
setColor("#53d188");
|
||||||
|
setLabel("sadzenie drzew")
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
setColor("#FBBEBE");
|
setColor("#FBBEBE");
|
||||||
|
setLabel("zbieranie śmieci")
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
}, [label,color,props.type]);
|
}, [label,color,props.type]);
|
||||||
|
const getDate = (time) =>{
|
||||||
|
var date = new Date(time);
|
||||||
|
return date.toLocaleDateString()
|
||||||
|
}
|
||||||
|
const getTime = (time) =>{
|
||||||
|
var date = new Date(time);
|
||||||
|
return date.toLocaleTimeString(navigator.language, {hour: '2-digit', minute:'2-digit'});
|
||||||
|
}
|
||||||
return (
|
return (
|
||||||
<Link to={`/event/${props.id}`} className={styles.link}>
|
<Link to={`/event/${props.id}`} className={styles.link}>
|
||||||
<div className={styles.item}>
|
<div className={styles.item}>
|
||||||
@@ -26,10 +37,13 @@ export const EventPreview = (props) => {
|
|||||||
<BIcon icon="calendar" /> {props.date ?? ""}
|
<BIcon icon="calendar" /> {props.date ?? ""}
|
||||||
</span>{" "}
|
</span>{" "}
|
||||||
<br></br>
|
<br></br>
|
||||||
|
<div className="d-flex justify-content-between align-items-center ">
|
||||||
<div style={{ background: color }} className={styles.block}>
|
<div style={{ background: color }} className={styles.block}>
|
||||||
{label}
|
{label}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
<span className={styles.createdSpan}>utworzone {getDate(props.createdTime)} o godzinie {getTime(props.createdTime)}</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</Link>
|
</Link>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
@@ -4,7 +4,11 @@
|
|||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
color: black !important;
|
color: black !important;
|
||||||
}
|
}
|
||||||
|
.created{
|
||||||
|
}
|
||||||
|
.createdSpan{
|
||||||
|
font-size: 0.8em;
|
||||||
|
}
|
||||||
.item {
|
.item {
|
||||||
border: 1px solid black;
|
border: 1px solid black;
|
||||||
border-radius: 15px;
|
border-radius: 15px;
|
||||||
@@ -30,10 +34,10 @@
|
|||||||
}
|
}
|
||||||
.block{
|
.block{
|
||||||
text-align: center;
|
text-align: center;
|
||||||
font-weight: 600;
|
font-weight: 400;
|
||||||
font-size: 0.8em;
|
font-size: 0.9em;
|
||||||
max-width:120px;
|
max-width:150px;
|
||||||
padding:3px;
|
padding:5px;
|
||||||
height:25px;
|
height:30px;
|
||||||
border-radius:10px;
|
border-radius:10px;
|
||||||
}
|
}
|
||||||
@@ -67,7 +67,7 @@ export const Home = () => {
|
|||||||
</Button>
|
</Button>
|
||||||
</Stack>
|
</Stack>
|
||||||
{list.map((e, i) => {
|
{list.map((e, i) => {
|
||||||
return <EventPreview name={e.name} type={e.type} date={e.date} id={e._id} key={i} />;
|
return <EventPreview name={e.name} type={e.type} createdTime={e.created.time} date={e.date} id={e._id} key={i} />;
|
||||||
})}
|
})}
|
||||||
</Stack>
|
</Stack>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in new issue
Block a user