Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 1 addition & 15 deletions public/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,21 +61,7 @@
"importApplicationFile": "Import application file",
"leavePage": "Leave page",
"new": "New {{what}}",
"newApplication": "New application",
"newBusinessService": "New business service",
"newJobFunction": "New job function",
"newStakeholder": "New stakeholder",
"newStakeholderGroup": "New stakeholder group",
"newTag": "New Tag",
"newTagType": "New tag type",
"update": "Update {{what}}",
"updateApplication": "Update application",
"updateBusinessService": "Update business service",
"updateJobFunction": "Update job function",
"updateStakeholder": "Update stakeholder",
"updateStakeholderGroup": "Update stakeholder group",
"updateTag": "Update tag",
"updateTagType": "Update tag type"
"update": "Update {{what}}"
}
},
"efforts": {
Expand Down
16 changes: 1 addition & 15 deletions public/locales/es/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,21 +61,7 @@
"importApplicationFile": "Importar archivo con aplicaciones",
"leavePage": "Salir de página",
"new": "Nuevo(a) {{what}}",
"newApplication": "Nueva aplicación",
"newBusinessService": "Nuevo servicio de negocio",
"newJobFunction": "Nueva función laboral",
"newStakeholder": "Nuevo interesado",
"newStakeholderGroup": "Nuevo grupo de interesados",
"newTag": "Nueva etiqueta",
"newTagType": "Nuevo tipo de etiqueta",
"update": "Actualizar {{what}}",
"updateApplication": "Actualizar aplicación",
"updateBusinessService": "Actualizar servicio de negocio",
"updateJobFunction": "Actualizar función laboral",
"updateStakeholder": "Actualizar interesado",
"updateStakeholderGroup": "Actualizar grupo de interesados",
"updateTag": "Actualizar etiqueta",
"updateTagType": "Actualizar tipo de etiqueta"
"update": "Actualizar {{what}}"
}
},
"efforts": {
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

92 changes: 45 additions & 47 deletions src/pages/controls/business-services/business-services.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import { useTranslation } from "react-i18next";
import {
Button,
ButtonVariant,
Modal,
ModalVariant,
ToolbarChip,
ToolbarGroup,
ToolbarItem,
Expand Down Expand Up @@ -34,6 +36,7 @@ import {
useTableControls,
useFetchBusinessServices,
useDelete,
useEntityModal,
} from "shared/hooks";

import { BusinessService, SortByQuery } from "api/models";
Expand All @@ -44,8 +47,7 @@ import {
} from "api/rest";
import { getAxiosErrorMessage } from "utils/utils";

import { NewBusinessServiceModal } from "./components/new-business-service-modal";
import { UpdateBusinessServiceModal } from "./components/update-business-service-modal";
import { BusinessServiceForm } from "./components/business-service-form";

enum FilterKey {
NAME = "name",
Expand Down Expand Up @@ -106,8 +108,13 @@ export const BusinessServices: React.FC = () => {
new Map([])
);

const [isNewModalOpen, setIsNewModalOpen] = useState(false);
const [rowToUpdate, setRowToUpdate] = useState<BusinessService>();
const {
isOpen: isBusinessServiceModalOpen,
data: businessServiceToUpdate,
create: openCreateBusinessServiceModal,
update: openUpdateBusinessServiceModal,
close: closeBusinessServiceModal,
} = useEntityModal<BusinessService>();

const {
requestDelete: requestDeleteBusinessService,
Expand Down Expand Up @@ -227,7 +234,7 @@ export const BusinessServices: React.FC = () => {
// ];

const editRow = (row: BusinessService) => {
setRowToUpdate(row);
openUpdateBusinessServiceModal(row);
};

const deleteRow = (row: BusinessService) => {
Expand Down Expand Up @@ -296,41 +303,25 @@ export const BusinessServices: React.FC = () => {
);
};

// Create Modal

const handleOnOpenCreateNewBusinessServiceModal = () => {
setIsNewModalOpen(true);
};
// Create/update Modal

const handleOnBusinessServiceCreated = (
const handleOnBusinessServiceFormSaved = (
response: AxiosResponse<BusinessService>
) => {
setIsNewModalOpen(false);
if (!businessServiceToUpdate) {
dispatch(
alertActions.addSuccess(
// t('terms.businessService')
t("toastr.success.added", {
what: response.data.name,
type: t("terms.businessService").toLowerCase(),
})
)
);
}

closeBusinessServiceModal();
refreshTable();

dispatch(
alertActions.addSuccess(
t("toastr.success.added", {
what: response.data.name,
type: "business service",
})
)
);
};

const handleOnCancelCreateBusinessService = () => {
setIsNewModalOpen(false);
};

// Update Modal

const handleOnBusinessServiceUpdated = () => {
setRowToUpdate(undefined);
refreshTable();
};

const handleOnCancelUpdateBusinessService = () => {
setRowToUpdate(undefined);
};

return (
Expand Down Expand Up @@ -377,7 +368,7 @@ export const BusinessServices: React.FC = () => {
type="button"
aria-label="create-business-service"
variant={ButtonVariant.primary}
onClick={handleOnOpenCreateNewBusinessServiceModal}
onClick={openCreateBusinessServiceModal}
>
{t("actions.createNew")}
</Button>
Expand All @@ -401,16 +392,23 @@ export const BusinessServices: React.FC = () => {
/>
</ConditionalRender>

<NewBusinessServiceModal
isOpen={isNewModalOpen}
onSaved={handleOnBusinessServiceCreated}
onCancel={handleOnCancelCreateBusinessService}
/>
<UpdateBusinessServiceModal
businessService={rowToUpdate}
onSaved={handleOnBusinessServiceUpdated}
onCancel={handleOnCancelUpdateBusinessService}
/>
<Modal
// t('dialog.title.update')
// t('dialog.title.new')
// t('terms.businessService')
title={t(`dialog.title.${businessServiceToUpdate ? "update" : "new"}`, {
what: t("terms.businessService").toLowerCase(),
})}
variant={ModalVariant.medium}
isOpen={isBusinessServiceModalOpen}
onClose={closeBusinessServiceModal}
>
<BusinessServiceForm
businessService={businessServiceToUpdate}
onSaved={handleOnBusinessServiceFormSaved}
onCancel={closeBusinessServiceModal}
/>
</Modal>
</>
);
};

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading