Skip to content

Commit

Permalink
feat(pci.private-network): rework on using mutation delete
Browse files Browse the repository at this point in the history
ref: -1826
Signed-off-by: tsiorifamonjena <[email protected]>
  • Loading branch information
Tsiorifamonjena committed Dec 6, 2024
1 parent 75f4218 commit 6df59c7
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,5 @@
"pci_projects_project_network_private_subnet_create": "Créer un sous-réseau",
"pci_projects_project_network_private_ip_version": "IP Version",
"pci_projects_project_network_private_action": "Actions",
"pci_projects_project_network_private_subnet_show": "Voir les sous-réseaux",
"ACTIVE": "actif",
"DISABLED": "désactivé"
"pci_projects_project_network_private_subnet_show": "Voir les sous-réseaux"
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { FC } from 'react';
import { ODS_CHIP_SIZE } from '@ovhcloud/ods-components';
import { ODS_THEME_COLOR_INTENT } from '@ovhcloud/ods-common-theming';
import { OsdsChip } from '@ovhcloud/ods-components/react';
import { useTranslation } from 'react-i18next';
import { ResourceStatus } from '@/types/network.type';

const color = {
Expand All @@ -11,19 +10,16 @@ const color = {
};

const StatusInfo: FC<{
label: ResourceStatus;
}> = ({ label }) => {
const { t } = useTranslation('listing');

return (
<OsdsChip
className="inline-flex m-3"
size={ODS_CHIP_SIZE.sm}
color={color[label]}
>
{t(label)}
</OsdsChip>
);
};
label: string;
status: ResourceStatus;
}> = ({ label, status }) => (
<OsdsChip
className="inline-flex m-3"
size={ODS_CHIP_SIZE.sm}
color={color[status]}
>
{label}
</OsdsChip>
);

export default StatusInfo;
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,8 @@ export const useDeletePrivateNetwork = ({
networkId,
onError,
onSuccess,
}: DeletePrivateNetworkProps) => {
const mutation = useMutation({
}: DeletePrivateNetworkProps) =>
useMutation({
mutationFn: () => apiDeleteNetwork(projectId, region, networkId),
onError,
onSuccess: async () => {
Expand All @@ -189,9 +189,3 @@ export const useDeletePrivateNetwork = ({
onSuccess();
},
});

return {
deletePrivateNetwork: () => mutation.mutate(),
...mutation,
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,11 @@ export function usePrivateNetworkLZColumns() {
<DataGridTextCell>
<StatusInfo
label={
dhcpEnabled
? t('pci_projects_project_network_private_dhcp_active')
: t('pci_projects_project_network_private_dhcp_disabled')
}
status={
dhcpEnabled ? ResourceStatus.ACTIVE : ResourceStatus.DISABLED
}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export default function DeleteLocalZone() {

const onClose = () => navigate('..');

const { deletePrivateNetwork, isPending } = useDeletePrivateNetwork({
const { mutate: deletePrivateNetwork, isPending } = useDeletePrivateNetwork({
projectId,
region,
networkId,
Expand Down

0 comments on commit 6df59c7

Please sign in to comment.