Skip to content

Commit

Permalink
immedeate load of data
Browse files Browse the repository at this point in the history
  • Loading branch information
Vishala09 committed Jan 5, 2024
1 parent 205e547 commit 6534c97
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,22 +1,33 @@
import { useEffect, useState } from 'react';
import { useSelector } from 'react-redux';
import { useSelector, useDispatch } from 'react-redux';
import { Table, Button } from 'reactstrap';
import { BiPencil } from 'react-icons/bi';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { faSortDown, faSortUp } from '@fortawesome/free-solid-svg-icons';
import './Consumables.css';
import ReactTooltip from 'react-tooltip';
import ConsumablesViewModal from './ConsumablesViewModal';
import { fetchAllConsumables } from 'actions/bmdashboard/consumableActions';

Check failure on line 10 in src/components/BMDashboard/Consumables/ConsumablesList/ConsumablesTable.jsx

View workflow job for this annotation

GitHub Actions / build (14.x)

`actions/bmdashboard/consumableActions` import should occur before import of `./ConsumablesViewModal`

function ConsumablesTable({ consumable, project }) {
// Data fetched in the parent component : ConsumablesView
const dispatch = useDispatch();

const consumables = useSelector(state => state.bmConsumables.consumableslist);
const [recordType, setRecordType] = useState(null);
const [modal, setModal] = useState(false);
const [selectedRow, setSelectedRow] = useState(null);
const [sortOrder, setSortOrder] = useState({ project: 'asc', itemType: 'asc' });
const [iconToDisplay, setIconToDisplay] = useState({ project: faSortUp, itemType: faSortUp });
const [consumablesViewData, setConsumablesViewData] = useState(consumables);
const [consumablesViewData, setConsumablesViewData] = useState(null);

useEffect(() => {
dispatch(fetchAllConsumables());
}, []);

useEffect(() => {
setConsumablesViewData(consumables)

Check failure on line 29 in src/components/BMDashboard/Consumables/ConsumablesList/ConsumablesTable.jsx

View workflow job for this annotation

GitHub Actions / build (14.x)

Insert `;`
}, [consumables])

Check failure on line 30 in src/components/BMDashboard/Consumables/ConsumablesList/ConsumablesTable.jsx

View workflow job for this annotation

GitHub Actions / build (14.x)

Insert `;`

const handleSort = column => {
if (!column || consumables.length === 0) return;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,12 @@
import { useState, useEffect } from 'react';

Check failure on line 1 in src/components/BMDashboard/Consumables/ConsumablesList/ConsumablesView.jsx

View workflow job for this annotation

GitHub Actions / build (14.x)

'useEffect' is defined but never used
import { useDispatch } from 'react-redux';
import { fetchAllConsumables } from 'actions/bmdashboard/consumableActions';
import ConsumablesTable from './ConsumablesTable';
import ConsumablesInputs from './ConsumablesInputs';
import './Consumables.css';

function ConsumablesView() {
const dispatch = useDispatch();
const [consumable, setConsumable] = useState({ label: 'All Consumables', value: '0' });
const [project, setProject] = useState({ label: 'All Projects', value: '0' });

useEffect(() => {
dispatch(fetchAllConsumables());
}, []);

return (
<div className="PageViewContainer">
<div className="Page">
Expand Down

0 comments on commit 6534c97

Please sign in to comment.