-
Notifications
You must be signed in to change notification settings - Fork 0
/
Submissions.jsx
65 lines (50 loc) · 1.89 KB
/
Submissions.jsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import React, { useState} from 'react';
import { useNavigate } from 'react-router-dom';
import './Submissions.css';
function Submissions({submissions, favsubmissions, searchQuery, sortBy}) {
const navigate = useNavigate();
const [selectedCardId, setSelectedCardId] = useState(null);
const filteredSubmissions = (submissions || favsubmissions).filter((submission) =>
submission.title.toLowerCase().includes((searchQuery || '').toLowerCase())
);
const sortedSubmissions =
sortBy === 'newest'
? [...filteredSubmissions].sort((a, b) => b.id - a.id)
: [...filteredSubmissions].sort((a, b) => a.id - b.id);
const handleClick = (submission) => {
setSelectedCardId(submission.id);
navigate(`/Description/${submission.id}`, {
state: {
submission: submission,
id: submission.id,
title: submission.title,
summary: submission.summary,
description: submission.description,
img: submission.img,
startdate: submission.startdate,
enddate: submission.enddate,
gitlink: submission.gitlink,
linklink: submission.linklink
}
});
};
return (
<div className='container'>
<div className="card-list">
{sortedSubmissions.map((submission) => (
<div key={submission.id} className="card" onClick={() => handleClick(submission)} >
<div className="card-image">
<img src={submission.img.preview} alt={submission.title} />
</div>
<div className="card-content">
<div className="card-title">{submission.title}</div>
<div className="card-desc">{submission.summary}</div>
</div>
<div className="card-modify">uploaded just now</div>
</div>
))}
</div>
</div>
);
}
export default Submissions;