-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1956 from OneCommunityGlobal/Chengyan-Phase2-Reus…
…ables-List-UI Chengyan phase2 reusables list UI
- Loading branch information
Showing
32 changed files
with
586 additions
and
821 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import axios from "axios"; | ||
import { | ||
SET_REUSABLES | ||
} from "constants/bmdashboard/reusableConstants" | ||
import { GET_ERRORS } from "constants/errors"; | ||
import { ENDPOINTS } from "utils/URL"; | ||
|
||
export const setReusables = payload => { | ||
return { | ||
type: SET_REUSABLES, | ||
payload | ||
} | ||
} | ||
|
||
export const setErrors = payload => { | ||
return { | ||
type: GET_ERRORS, | ||
payload | ||
} | ||
} | ||
|
||
export const fetchAllReusables = () => { | ||
return async dispatch => { | ||
axios.get(ENDPOINTS.BM_REUSABLES) | ||
.then(res => { | ||
dispatch(setReusables(res.data)) | ||
}) | ||
.catch(err => { | ||
dispatch(setErrors(err)) | ||
}) | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
src/components/BMDashboard/ConsumableList/ConsumableListView.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { useEffect } from 'react'; | ||
import { useDispatch, useSelector } from 'react-redux'; | ||
import { fetchAllConsumables } from 'actions/bmdashboard/consumableActions'; | ||
import ItemListView from '../ItemList/ItemListView'; | ||
import UpdateConsumableModal from '../UpdateConsumables/UpdateConsumableModal'; | ||
|
||
function ConsumableListView() { | ||
const dispatch = useDispatch(); | ||
const consumables = useSelector(state => state.bmConsumables.consumableslist); | ||
const errors = useSelector(state => state.errors); | ||
const postConsumableUpdateResult = useSelector(state => state.bmConsumables.updateConsumables); | ||
|
||
useEffect(() => { | ||
dispatch(fetchAllConsumables()); | ||
}, []); | ||
|
||
useEffect(() => { | ||
if (!postConsumableUpdateResult || postConsumableUpdateResult?.result == null) | ||
dispatch(fetchAllConsumables()); | ||
}, [postConsumableUpdateResult?.result]); | ||
|
||
const itemType = 'Consumables'; | ||
|
||
const dynamicColumns = [ | ||
{ label: 'Unit', key: 'itemType.unit' }, | ||
{ label: 'Bought', key: 'stockBought' }, | ||
{ label: 'Used', key: 'stockUsed' }, | ||
{ label: 'Available', key: 'stockAvailable' }, | ||
{ label: 'Waste', key: 'stockWasted' }, | ||
]; | ||
|
||
return ( | ||
<ItemListView | ||
itemType={itemType} | ||
items={consumables} | ||
errors={errors} | ||
UpdateItemModal={UpdateConsumableModal} | ||
dynamicColumns={dynamicColumns} | ||
/> | ||
); | ||
} | ||
|
||
export default ConsumableListView; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import ConsumableListView from './ConsumableListView'; | ||
|
||
export default ConsumableListView; |
59 changes: 0 additions & 59 deletions
59
src/components/BMDashboard/Consumables/ConsumablesList/Consumables.css
This file was deleted.
Oops, something went wrong.
101 changes: 0 additions & 101 deletions
101
src/components/BMDashboard/Consumables/ConsumablesList/ConsumablesInputs.jsx
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.