-
Notifications
You must be signed in to change notification settings - Fork 0
/
FavSubmissions.jsx
55 lines (50 loc) · 2.13 KB
/
FavSubmissions.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
import React, { useState } from 'react';
import { useNavigate } from 'react-router-dom';
import './Submissions.css';
function FavSubmissions({favsubmissions,searchQuery,sortBy}) {
const navigate = useNavigate();
const [selectedCardId, setSelectedCardId] = useState(null);
const sortedSubmissions =
sortBy === 'newest'
? [...favsubmissions].sort((a, b) => b.id - a.id)
: [...favsubmissions].sort((a, b) => a.id - b.id);
const filteredSubmissions = sortedSubmissions.filter((submission) =>
submission.title.toLowerCase().includes(searchQuery.toLowerCase())
);
const handleClick2 = (submission) => {
setSelectedCardId(submission.id);
navigate(`/FavDescription/${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">
{filteredSubmissions.map((submission) => (
<div key={submission.id} className="card" onClick={() => handleClick2(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 FavSubmissions;