Skip to content

Commit 0cc695f

Browse files
committed
star toggle is working (not storing yet)
1 parent f7731a4 commit 0cc695f

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/components/Table/index.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ const iconPath = `${process.env.PUBLIC_URL}/static/icons/`;
4141

4242
const Table = () => {
4343
const [resetCount, setResetCount] = useState(0);
44+
4445
let checkedList =
4546
JSON.parse(localStorage.getItem('checked')) ||
4647
new Array(questions.length).fill(false);
@@ -114,11 +115,12 @@ const Table = () => {
114115
JSON.parse(localStorage.getItem('showPatterns')) || new Array(1).fill(true),
115116
);
116117

118+
const savedImportant = JSON.parse(localStorage.getItem('importantProblems'));
117119
const [important, setImportant] = useState(
118-
JSON.parse(localStorage.getItem('importantProblems')) ||
119-
new Array(questions.length).fill(false),
120+
savedImportant && savedImportant.length === questions.length
121+
? savedImportant
122+
: new Array(questions.length).fill(false),
120123
);
121-
122124
useEffect(() => {
123125
localStorage.setItem('importantProblems', JSON.stringify(important));
124126
}, [important]);
@@ -498,6 +500,8 @@ const Table = () => {
498500
disableFilters: true,
499501
Cell: ({ row }) => {
500502
const id = Number(row?.original?.id);
503+
console.log('⭐ Row ID:', id, row?.original);
504+
501505
if (Number.isNaN(id)) return '❌';
502506

503507
const handleKeyPress = e => {
@@ -546,7 +550,7 @@ const Table = () => {
546550
},
547551
],
548552
// eslint-disable-next-line
549-
[resetCount],
553+
[resetCount, important],
550554
);
551555

552556
const {

0 commit comments

Comments
 (0)