-
Notifications
You must be signed in to change notification settings - Fork 4
Feature/companies list mui #910
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
6d675ec
3b2da41
08fba67
e1403b3
dc2ddf8
4616df3
f2aa623
13d54a4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,16 +20,14 @@ import { | |
| createAction, | ||
| stopLoading, | ||
| startLoading, | ||
| showMessage, | ||
| showSuccessMessage, | ||
| authErrorHandler, | ||
| escapeFilterValue, | ||
| fetchResponseHandler, | ||
| fetchErrorHandler | ||
| } from "openstack-uicore-foundation/lib/utils/actions"; | ||
| import debounce from "lodash/debounce" | ||
| import debounce from "lodash/debounce"; | ||
| import URI from "urijs"; | ||
| import history from "../history"; | ||
| import { snackbarErrorHandler, snackbarSuccessHandler } from "./base-actions"; | ||
| import { getAccessTokenSafely } from "../utils/methods"; | ||
| import { | ||
| DEBOUNCE_WAIT, | ||
|
|
@@ -92,9 +90,9 @@ export const getCompanies = | |
| createAction(REQUEST_COMPANIES), | ||
| createAction(RECEIVE_COMPANIES), | ||
| `${window.API_BASE_URL}/api/v1/companies`, | ||
| authErrorHandler, | ||
| { order, orderDir, page, term } | ||
| )(params)(dispatch).then(() => { | ||
| snackbarErrorHandler, | ||
| { order, orderDir, page, perPage, term } | ||
| )(params)(dispatch).finally(() => { | ||
| dispatch(stopLoading()); | ||
| }); | ||
| }; | ||
|
|
@@ -114,8 +112,8 @@ export const getCompany = (companyId) => async (dispatch) => { | |
| null, | ||
| createAction(RECEIVE_COMPANY), | ||
| `${window.API_BASE_URL}/api/v1/companies/${companyId}`, | ||
| authErrorHandler | ||
| )(params)(dispatch).then(() => { | ||
| snackbarErrorHandler | ||
| )(params)(dispatch).finally(() => { | ||
| dispatch(stopLoading()); | ||
| }); | ||
| }; | ||
|
|
@@ -134,8 +132,8 @@ export const deleteCompany = (companyId) => async (dispatch) => { | |
| createAction(COMPANY_DELETED)({ companyId }), | ||
| `${window.API_BASE_URL}/api/v1/companies/${companyId}`, | ||
| null, | ||
| authErrorHandler | ||
| )(params)(dispatch).then(() => { | ||
| snackbarErrorHandler | ||
| )(params)(dispatch).finally(() => { | ||
| dispatch(stopLoading()); | ||
| }); | ||
| }; | ||
|
|
@@ -155,38 +153,42 @@ export const saveCompany = (entity) => async (dispatch) => { | |
| const normalizedEntity = normalizeEntity(entity); | ||
|
|
||
| if (entity.id) { | ||
| putRequest( | ||
| return putRequest( | ||
| createAction(UPDATE_COMPANY), | ||
| createAction(COMPANY_UPDATED), | ||
| `${window.API_BASE_URL}/api/v1/companies/${entity.id}`, | ||
| normalizedEntity, | ||
| authErrorHandler, | ||
| snackbarErrorHandler, | ||
| entity | ||
| )(params)(dispatch).then(() => { | ||
| dispatch(showSuccessMessage(T.translate("edit_company.company_saved"))); | ||
| }); | ||
| } else { | ||
| const success_message = { | ||
| title: T.translate("general.done"), | ||
| html: T.translate("edit_company.company_created"), | ||
| type: "success" | ||
| }; | ||
| )(params)(dispatch) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [HIGH] Falta La función Consecuencias: el dialog se cierra antes de confirmar éxito, la lista se recarga con datos desactualizados, y la protección de doble-submit queda sin efecto. // ✅ agregar return en ambas ramas
return putRequest(...)(params)(dispatch)
.then(...)
.finally(...);
tomrndom marked this conversation as resolved.
tomrndom marked this conversation as resolved.
|
||
| .then(() => { | ||
| dispatch( | ||
| snackbarSuccessHandler({ | ||
| title: T.translate("general.success"), | ||
| html: T.translate("edit_company.company_saved") | ||
| }) | ||
| ); | ||
| }) | ||
| .finally(() => dispatch(stopLoading())); | ||
| } | ||
|
|
||
| postRequest( | ||
| createAction(UPDATE_COMPANY), | ||
| createAction(COMPANY_ADDED), | ||
| `${window.API_BASE_URL}/api/v1/companies`, | ||
| normalizedEntity, | ||
| authErrorHandler, | ||
| entity | ||
| )(params)(dispatch).then(() => { | ||
| return postRequest( | ||
| createAction(UPDATE_COMPANY), | ||
| createAction(COMPANY_ADDED), | ||
| `${window.API_BASE_URL}/api/v1/companies`, | ||
| normalizedEntity, | ||
| snackbarErrorHandler, | ||
| entity | ||
| )(params)(dispatch) | ||
| .then(() => { | ||
| dispatch( | ||
| showMessage(success_message, () => { | ||
| history.push("/app/companies"); | ||
| snackbarSuccessHandler({ | ||
| title: T.translate("general.success"), | ||
| html: T.translate("edit_company.company_created") | ||
| }) | ||
| ); | ||
| }); | ||
| } | ||
| }) | ||
| .finally(() => dispatch(stopLoading())); | ||
| }; | ||
|
|
||
| export const attachLogo = (entity, file, picAttr) => async (dispatch) => { | ||
|
|
@@ -210,7 +212,7 @@ export const attachLogo = (entity, file, picAttr) => async (dispatch) => { | |
| createAction(COMPANY_ADDED), | ||
| `${window.API_BASE_URL}/api/v1/companies`, | ||
| normalizedEntity, | ||
| authErrorHandler, | ||
| snackbarErrorHandler, | ||
| entity | ||
| )(params)(dispatch).then((payload) => { | ||
| dispatch(uploadFile(payload.response, file)); | ||
|
|
@@ -230,12 +232,13 @@ const uploadLogo = (entity, file) => async (dispatch) => { | |
| createAction(LOGO_ATTACHED), | ||
| `${window.API_BASE_URL}/api/v1/companies/${entity.id}/logo`, | ||
| file, | ||
| authErrorHandler, | ||
| snackbarErrorHandler, | ||
| { pic: entity.pic } | ||
| )(params)(dispatch).then(() => { | ||
| dispatch(stopLoading()); | ||
| history.push(`/app/companies/${entity.id}`); | ||
| }); | ||
| )(params)(dispatch) | ||
| .then(() => { | ||
| history.push(`/app/companies/${entity.id}`); | ||
| }) | ||
| .finally(() => dispatch(stopLoading())); | ||
| }; | ||
|
|
||
| const uploadBigLogo = (entity, file) => async (dispatch) => { | ||
|
|
@@ -250,12 +253,13 @@ const uploadBigLogo = (entity, file) => async (dispatch) => { | |
| createAction(BIG_LOGO_ATTACHED), | ||
| `${window.API_BASE_URL}/api/v1/companies/${entity.id}/logo/big`, | ||
| file, | ||
| authErrorHandler, | ||
| snackbarErrorHandler, | ||
| { pic: entity.pic } | ||
| )(params)(dispatch).then(() => { | ||
| dispatch(stopLoading()); | ||
| history.push(`/app/companies/${entity.id}`); | ||
| }); | ||
| )(params)(dispatch) | ||
| .then(() => { | ||
| history.push(`/app/companies/${entity.id}`); | ||
| }) | ||
| .finally(() => dispatch(stopLoading())); | ||
| }; | ||
|
|
||
| const normalizeEntity = (entity) => { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.