Skip to content

Commit

Permalink
Exercicio 39.3: Conecta action de listSecretarias a view do bloco
Browse files Browse the repository at this point in the history
  • Loading branch information
samoel-silva committed Sep 19, 2024
1 parent 5f5e1d3 commit 8c1baca
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
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);
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export default function secretarias(state = initialState, action = {}) {
case `${LIST_SECRETARIAS}_SUCCESS`:
return {
...state,
data: action.result,
data: action.result.items,
error: null,
};
case `${LIST_SECRETARIAS}_FAIL`:
Expand Down

0 comments on commit 8c1baca

Please sign in to comment.