-
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.2: Implementa conexão com endpoint de secretarias
- Loading branch information
1 parent
e6c042f
commit 5f5e1d3
Showing
5 changed files
with
89 additions
and
12 deletions.
There are no files selected for viewing
10 changes: 10 additions & 0 deletions
10
frontend/packages/volto-portal-governo/src/actions/secretarias/secretarias.js
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,10 @@ | ||
import { LIST_SECRETARIAS } from '../../constants/ActionTypes'; | ||
export function listSecretarias() { | ||
return { | ||
type: LIST_SECRETARIAS, | ||
request: { | ||
op: 'get', | ||
path: '@secretarias', | ||
}, | ||
}; | ||
} |
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
1 change: 1 addition & 0 deletions
1
frontend/packages/volto-portal-governo/src/constants/ActionTypes.js
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 @@ | ||
export const LIST_SECRETARIAS = 'LIST_SECRETARIAS'; |
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
31 changes: 31 additions & 0 deletions
31
frontend/packages/volto-portal-governo/src/reducers/secretarias/secretarias.js
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,31 @@ | ||
import { LIST_SECRETARIAS } from '../../constants/ActionTypes'; | ||
const initialState = { | ||
data: [], | ||
loading: false, | ||
error: null, | ||
}; | ||
export default function secretarias(state = initialState, action = {}) { | ||
switch (action.type) { | ||
case `${LIST_SECRETARIAS}_PENDING`: | ||
return { | ||
...state, | ||
data: [], | ||
error: null, | ||
loading: true, | ||
}; | ||
case `${LIST_SECRETARIAS}_SUCCESS`: | ||
return { | ||
...state, | ||
data: action.result, | ||
error: null, | ||
}; | ||
case `${LIST_SECRETARIAS}_FAIL`: | ||
return { | ||
...state, | ||
data: [], | ||
error: action.error.response.error, | ||
}; | ||
default: | ||
return state; | ||
} | ||
} |