-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Exercicio 39.3: Conecta action de listSecretarias a view do bloco
- Loading branch information
1 parent
5f5e1d3
commit 8c1baca
Showing
2 changed files
with
20 additions
and
3 deletions.
There are no files selected for viewing
21 changes: 19 additions & 2 deletions
21
frontend/packages/volto-portal-governo/src/components/Blocks/SecretariasBlock/View.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 |
---|---|---|
@@ -1,10 +1,27 @@ | ||
import React from 'react'; | ||
import React, { useEffect } from 'react'; | ||
import { useDispatch, useSelector } from 'react-redux'; | ||
import { withBlockExtensions } from '@plone/volto/helpers'; | ||
import { listSecretarias } from '../../../actions/secretarias/secretarias'; | ||
import SecretariasView from './DefaultView'; | ||
|
||
const SecretariasBlockView = (props) => { | ||
const { data, isEditMode, className } = props; | ||
const dispatch = useDispatch(); | ||
const secretarias = useSelector((state) => state.secretarias?.data); | ||
// Dispara chamada na criação da constante dispatch | ||
|
||
useEffect(() => { | ||
dispatch(listSecretarias()); | ||
}, [dispatch]); | ||
|
||
return ( | ||
<SecretariasView {...data} isEditMode={isEditMode} className={className} /> | ||
<SecretariasView | ||
{...data} | ||
secretarias={secretarias} | ||
isEditMode={isEditMode} | ||
className={className} | ||
/> | ||
); | ||
}; | ||
|
||
export default withBlockExtensions(SecretariasBlockView); |
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