Skip to content

Commit

Permalink
fixing bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
001elijah committed Apr 27, 2023
1 parent 05bc26a commit 692d763
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { Calendar } from '../../DateInput/DateInput';
import { useEffect, useState } from 'react';
import { useDispatch } from 'react-redux';
import { getCashflowStat } from '../../../redux/operations/cashflowOperations';
import shortid from 'shortid';
// import {Notify} from "notiflix"

export const Item = ({ id, amount, category, percentage }) => {
Expand Down Expand Up @@ -40,7 +41,7 @@ export const CategoriesList = () => {
<Calendar onDate={setDateFilter} />
<StatisticsNav />
<ul>
{transactionData?.map(item => <Item key={item.id} {...item} />)}
{transactionData?.map(item => <Item key={shortid.generate()} {...item} />)}
</ul>
</div>
</div>
Expand Down
11 changes: 7 additions & 4 deletions src/components/StatisticsComponents/PopUp/Select.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import { useEffect, useState } from 'react';
import { useDispatch, useSelector } from 'react-redux';
import {
// useDispatch,
useSelector
} from 'react-redux';
import Select from 'react-select';
import '../../../components/Select/SelectCategory.scss';
// import s from './Popup.module.scss';
Expand Down Expand Up @@ -35,13 +38,13 @@ const colourStyles = {

export default function SelectCategory({ currentCategory, changeCategory }) {
const [categoryValue, setCategoryValue] = useState('');
const dispatch = useDispatch();
// const dispatch = useDispatch();

const categories = useSelector(state => state?.categories?.categories);

useEffect(() => {
changeCategory(categoryValue);
}, [categoryValue]);
}, [categoryValue, changeCategory]);

const category = categories?.map(({ name, title }) => {
return {
Expand All @@ -56,7 +59,7 @@ export default function SelectCategory({ currentCategory, changeCategory }) {
return categoryId.value === currentCategory;
})
);
}, []);
}, [setCategoryValue, category, currentCategory]);

return (
<Select
Expand Down

0 comments on commit 692d763

Please sign in to comment.