-
Notifications
You must be signed in to change notification settings - Fork 0
/
Topics.js
37 lines (35 loc) · 1.11 KB
/
Topics.js
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
import React from "react";
import { Link } from "react-router-dom";
import ROUTES from "../../app/routes";
import { useSelector } from "react-redux";
// import selector
import { selectTopics } from "./topicsSlice";
export default function Topics() {
const topics = useSelector(selectTopics); // call to your selector to select all the topics in state
return (
<section className="center">
<h1>Topics</h1>
<ul className="topics-list">
{Object.values(topics).map((topic) => (
<li className="topic" key={topic.id}>
<Link to={ROUTES.topicRoute(topic.id)} className="topic-link">
<div className="topic-container">
<img src={topic.icon} alt="" />
<div className="text-content">
<h2>{topic.name}</h2>
<p>{topic.quizIds.length} Quizzes</p>
</div>
</div>
</Link>
</li>
))}
</ul>
<Link
to={ROUTES.newTopicRoute()}
className="button create-new-topic-button"
>
Create New Topic
</Link>
</section>
);
}