Skip to content

Commit 927e964

Browse files
committed
add a toast
1 parent d96c27d commit 927e964

File tree

3 files changed

+62
-5
lines changed

3 files changed

+62
-5
lines changed

package-lock.json

Lines changed: 36 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
"react-scroll": "^1.8.0",
2424
"react-table": "^7.6.3",
2525
"react-test-renderer": "^16.14.0",
26+
"react-toastify": "^8.1.0",
2627
"react-toggle": "^4.1.1",
2728
"react-tooltip": "^3.11.2",
2829
"reactstrap": "^8.8.1",

src/components/Table/index.js

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,15 @@ import {
2323
FaRandom,
2424
FaQuestionCircle,
2525
} from 'react-icons/fa';
26+
import { ToastContainer, toast } from 'react-toastify';
27+
import 'react-toastify/dist/ReactToastify.css';
2628
import {
2729
DefaultColumnFilter,
2830
SelectDifficultyColumnFilter,
2931
SelectColumnFilter,
3032
SelectCheckedColumnFilter,
3133
} from './filters';
3234
import { Event } from '../Shared/Tracking';
33-
3435
import questions, { updated } from '../../data';
3536

3637
import 'react-toggle/style.css';
@@ -505,16 +506,24 @@ const Table = () => {
505506
disableFilters: true,
506507
Cell: ({ row }) => {
507508
const id = Number(row?.original?.id);
508-
console.log('⭐ Row ID:', id, row?.original);
509-
510509
if (Number.isNaN(id)) return '❌';
511510

512511
const handleKeyPress = e => {
513512
if (e.key === 'Enter' || e.key === ' ') {
514513
const updatedImportant = [...important];
515514
updatedImportant[id] = !updatedImportant[id];
516515
setImportant(updatedImportant);
517-
console.log('Toggled important:', updatedImportant);
516+
toast(
517+
updatedImportant[id]
518+
? 'Marked as Important'
519+
: 'Removed from Important',
520+
{
521+
type: updatedImportant[id] ? 'success' : 'info',
522+
autoClose: 1200,
523+
hideProgressBar: true,
524+
position: 'bottom-center',
525+
},
526+
);
518527
}
519528
};
520529

@@ -524,10 +533,20 @@ const Table = () => {
524533
tabIndex={0}
525534
style={{ cursor: 'pointer', fontSize: '1.2em' }}
526535
onClick={() => {
527-
console.log('Star clicked!', id); // add this
528536
const updatedImportant = [...important];
529537
updatedImportant[id] = !updatedImportant[id];
530538
setImportant(updatedImportant);
539+
toast(
540+
updatedImportant[id]
541+
? 'Marked as Important'
542+
: 'Removed from Important',
543+
{
544+
type: updatedImportant[id] ? 'success' : 'info',
545+
autoClose: 1200,
546+
hideProgressBar: true,
547+
position: 'bottom-center',
548+
},
549+
);
531550
}}
532551
onKeyDown={handleKeyPress}
533552
aria-label="Mark as important for revision"
@@ -609,6 +628,7 @@ const Table = () => {
609628

610629
return (
611630
<Container className="table">
631+
<ToastContainer />
612632
<ReactTooltip />
613633
<PatternFrequencies filters={filters} rows={filteredRows} />
614634

0 commit comments

Comments
 (0)